How to capture video data via capture devices

1. The internal memory of capture device

2. Event notification mechanism

3. Two methods to capture video data with SDK

(1) Capture according to the frame rate of signal source (byInput)

MWOpenChannel() → CreateEvent()  → MWRegisterNotify() → MWStartVideoCapture()  →  WaitForSingleObject()→ MWGetNotifyStatus() → MWCaptureVideoFrameToVirtualAddress() → WaitForSingleObject() → MWGetVideoCaptureStatus()

(2)Capture according to the customized frame rate (byTimer)

MWOpenChannel() → CreateEvent() → MWRegisterTimer() → MWStartVideoCapture() → MWScheduleTimer() → WaitForSingleObject()→ MWCaptureVideoFrameToVirtualAddress() → WaitForSingleObject() → MWGetVideoCaptureStatus()

For method 1, the captured frame rate is fixed, as it keeps the sane as the frame rate of input signal source; meanwhile, notification event object needs to be registered. By executing WaitForSingleObject(), when the status of event is “valid” and notification mode is MWCAP_NOTIFY_VIDEO_FRAME_BUFFERED or MWCAP_NOTIFY_VIDEO_FRAME_BUFFERING, it is ready to capture the video data.

For method 2, the frame rate can be customized, and time event object needs to be registered. Time value in MWScheduleTimer() should be set according to different frame rates. When the time event status of WaitForSingleObject() shows valid, it’s ready to capture video data .

If you want to capture with low latency, please only use 1 (byInput).

3. Two methods to capture video data with SDK

  1. Before capturing, you can prepare some memory area for the storage of captured video frames if necessary
  2. By executing MWCaptureVideoFrameToVirtualAddress(), import the video frames from onboard memory to system memory by DMA; Function pbFrame is the assigned memory pointer; iFrame is the serial number of to-be-captured frame, which can be set as iNewestBufferedFullFrame (the frame numbers of latest buffered frames) in MWCAP_VIDEO_BUFFER_INFO
  3. MWCaptureVideoFrameToPhysicalAddressEx() is a spread function, with which you can easily set more capture parameters and add OSD feature as well
  4. MWCaptureVideoFrameToVirtualAddress() is an asynchronous function. Users must use WaitForSingleObject() and wait until the capture is finished. By executing MWGetVideoCaptureStatus() users can know whether capture is finished or not

In all, capture device will firstly buffer the video frames into onboard memory, and then transmit the data to appointed memory address by DMA; capture parameters can be set with MWCaptureVideoFrameToVirtualAddress(), so as to achieve different capture effects.

Examples \ CmdLineTools\CaptureByInput is a demo for method 1;
Examples \ CmdLineTools\CaptureByTimer is a demo for method 2.