Capturing Still Frames from a USB Camera

USBCAMD2 provides the capability for a separate Still Image driver to retrieve still frames from the camera through the camera's bulk pipe.

To support still frame capture a USBCAMD2 minidriver must perform the following

  • Call USBCAMD_BulkReadWrite from the PROPSETID_VIDCAP_VIDEOCONTROL property handler and pass a pointer to a minidriver-allocated buffer into which the still image can be captured. The pointer must not be NULL.

  • USBCAMD2 then calls the minidriver's CamNewVideoFrameEx callback function before starting the bulk transfer. The camera minidriver can reduce the requested size of the bulk transfer if it determines that the actual still frame is smaller than the maximum size allocated by DirectShow.

  • After the bulk transfer completes, USBCAMD2 calls the minidriver's CamProcessRawVideoFrameEx callback function to allow the minidriver to perform additional processing.

Still frame data flow is intended for use with a pull model. A pull occurs when an application requests a still frame. Alternately, still frame data flow also works in a push model. A push occurs when the user pushes the button on the camera, triggering the device event.

To use the pull** model to retrieve still frames from an STI minidriver**

  • Open the WDM video capture source filter associated with the camera.

  • Open the still pin on the filter handle obtained in the previous step.

  • Call ReadFile on that pin with the maximum-sized buffer.

  • Set the stream state from Pause to Run.

  • Get an interface pointer to the USBCAMD2 camera minidriver's PROPSETID_VIDCAP_VIDEOCONTROL property set.

  • Set the KS_VideoControlFlag_Trigger flag associated with KSPROPERTY_VIDEOCONTROL_MODE.

To support the push** model to retrieve still frames from a camera**

  • Pass the USBCAMD_CamControlFlag_EnableDeviceEvents flag when you call USBCAMD_InitializeNewInterface from within the minidriver's SRB_INITIALIZE_DEVICE handler. The minidriver handles SRB_INITIALIZE_DEVICE from within its AdapterReceivePacket callback function.

  • USBCAMD2 sends a KSEVENT_VIDCAPTOSTI_EXT_TRIGGER event to the registered imaging application when the user pushes the trigger button on the camera.

To cancel a requested bulk read or write, an application should call CancelIO with a handle to the still pin. If tables need to be transferred to the camera (through a USB bulk-out pipe), an application should call WriteFile with a handle to the still pin.