1

I am getting video feed using DirectShow in my C# Web Form. Now i want to process the frames using OpenCV. (EmguCV Wrapper)

1) How would i collect frames from DirectShow feed.

2) Is there a Way to combine DS & OpenCV.

Thanks.

  • Do you know how to write your own direct show filter? – Micka Oct 03 '14 at 17:17
  • A Little Bit.. I found a DirectX code for my task (i.e. Extracting Frames).. What is the difference between the two approaches.. DirectShow vs DirectX – user3752779 Oct 03 '14 at 19:39
  • Afaik DirectX uses DirectShow for 2D rendering so there should be no difference but I'm quite new to DirectShow too so I might be wrong there. – Micka Oct 04 '14 at 09:24
  • You should be able to extract frames from a DirectShow feed. This might help you: http://www.codeproject.com/Articles/1353/Extracting-bitmaps-from-movies-using-DirectShow . You should be able to manipulate the pixel data from a captured frame using OpenCV (depending on the image format your frame is using you might need to tweak things a little bit). Here is a skeleton for OpenGL+OpenCV application, which might give you some pointers what to do next: http://www.cs.ucsb.edu/~holl/CS290I/opengl_cv.cpp I've used it myself and it's working. – rbaleksandar Oct 04 '14 at 11:45
  • @Micka, yes, as far as I know DirectShow is for 2D rendering only. But a 3D can easily be converted to 2D. After all this is what's actually happening when a 3D object is displayed on our 2D displays. :) – rbaleksandar Oct 04 '14 at 11:48
  • possible duplicate of [Get iplImage or Mat from directshow to opencv](http://stackoverflow.com/questions/16477314/get-iplimage-or-mat-from-directshow-to-opencv) – Roman R. Oct 06 '14 at 10:10
  • @user3752779 did you end up doing it? – Skynet094 Feb 17 '21 at 12:12

1 Answers1

2

From your description, using a SampleGrabber filter should suffice. The SampleGrabber will allow you to grab the individual frames, after which you can store and process it as you need.

Example usage can be found on MSDN

kdtong
  • 184
  • 2
  • 14