A change from a non-contact state to a contact state is determined. Until a change from the contact state to the non-contact state is determined, frame data is sequentially acquired. Volume data is configured with a plurality of pieces of acquired frame data. When the number of pieces of acquired frame data is small, error processing is executed. After determining the acquisition end, the volume data processing is automatically executed.