Thomas Kist
Thomas Kist

Reputation: 21

How do I get video frames from the camera on Windows 10 system into my C++ application?

I'm writing a C++ application using Visual Studio 2019. I want to experiment with neural network processing of real time video. To do this, I need raw RGB video data. I would like the solution to accept either real time camera video or video playback frames.

Many google searches find deprecated functions, so I'm looking for the current best framework that comes standard with Windows 10. For example, the first item in my google search in the deprecated MFPlay.

This looks promising: https://learn.microsoft.com/en-us/windows/win32/multimedia/using-video-capture. However, while the Microsoft documentation gives the syntax of many functions, it does not explain the function's purpose very well.

  1. For example, it often talks about a capture window, but what is a capture window for? Why do I need a window when I just want a video frame stream for my command line application?

  2. capSetCallbackOnFrame looks interesting, but then says "This callback function is not used during streaming video capture." So... what's its point?

I would expect my final code to look like:

setup thread:

  1. find a video capture device
  2. setup video capture for RGB mode
  3. register a frame callback function

callback thread:

  1. buffer the frame

processing thread:

  1. do my stuff on the saved buffer without blocking the callback thread

Upvotes: 2

Views: 1646

Answers (1)

Philiste
Philiste

Reputation: 171

As mentionned in comment, OpenCv is a great library you can use for this work.

You can use openFrameWorks as well. It contains many examples, and a template code for realtime video processing (with or without video capture), with callback.

Upvotes: 1

Related Questions