Getting Frames from Webcam
-
Hey there, I want to make a MFC app that will capture 6 frames per second from the webcam connected to the PC. And i want to get the frames as imageData, i.e., as bitmap or PNG. The idea is to get these frames/images and then update them live on a web browser, so that it gives a "look and feel" of live video streaming. I did a sample MFC app that shows webcam stream and then use the capGrabFrame & capFileSaveDIB to save the bmp to disk. This all works fine. But now rather than saving into disk, i need to get the Image Data, so that i could make changes and update in a browser window. Also, not sure whether it's possible to get 6 frames per second from the webcam. Is this possible? Please guide me with some code. Thanks in advance.
-
Hey there, I want to make a MFC app that will capture 6 frames per second from the webcam connected to the PC. And i want to get the frames as imageData, i.e., as bitmap or PNG. The idea is to get these frames/images and then update them live on a web browser, so that it gives a "look and feel" of live video streaming. I did a sample MFC app that shows webcam stream and then use the capGrabFrame & capFileSaveDIB to save the bmp to disk. This all works fine. But now rather than saving into disk, i need to get the Image Data, so that i could make changes and update in a browser window. Also, not sure whether it's possible to get 6 frames per second from the webcam. Is this possible? Please guide me with some code. Thanks in advance.
It looks like you have gone down the Video For Windows route. You might want to consider stepping up to DirectShow instead. They are both old technologies, but VFW is just too old and annoying to deal with (we were using it on Windows 98). Whether you will be able to achieve 6 FPS really depends on several factors, primarily if your camera supports that frame rate at your desired resolution. You should be able to acquire the images as JPEGs or another bitmap format (RGB or YUV), but which formats are available depends completely on your camera. Take a look at this totally awesome CP article: Realtime Webcam Sudoku Solver[^] As I recall, it uses Video For Windows, so it should be easy for you to jump into the code and see how to access the image data. For a DirectShow sample, check out this CP article: Video Preview and Frames Capture to Memory with SampleGrabber in Buffered Mode.[^] And also browse through his other articles[^], it will not be a waste of your time. Here are a couple more DirectShow related CP articles: Simultaneous Previewing & Video Capture using DirectShow[^] DirectX Video Stream and frame capture[^] Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty