0
votes

I'm writing an OpenCV in C++ that using OpenCV that captures frames from multiple video devices, carries out a series of transforms on them, and then produces a new frame to display (in the form of an IplImage). This all works perfectly.

I then want to create an instance of a capture source filter and send it these frames, to create a virtual video device that's usable with programs like Skype. This is where I'm having some trouble.

I've had a look at Vivek's Vcam sample (capture source filter from here), which seems would be perfect, but I'm struggling to figure out how to modify it to use in my application:

  1. Vcam fills the buffer with random values, whereas I want to fill it with the data from my frame.

  2. Vcam produces a DLL file that needs to be registered before the filter is created, but I want to create the filter when my application starts, and then remove it when it ends

I'm completely new to DirectShow, and have only been programming in C++ for a few months, so I'm in over my head with this. Could someone outline the steps I'd need to take to implement the two changes above?

Thanks, Phil

1

1 Answers

1
votes

Your questions are somewhat broad for specific answer.

Vcam fills the buffer with random values, whereas I want to fill it with the data from my frame.

Video source advertises certain video formats, then agrees on one of them when it is connected to something else and then the payload data need to be of this agreed format. You need to take care of all the steps here. Presumably, your processing uses certain fixed format, or you can lock it at initial step of development. Then the filter need advertise it on its output pin and reject attempt to connect with any other format. Then you copy your data into buffers and as formats match, the connected party receives the data matching the connection media type.

Vcam produces a DLL file that needs to be registered before the filter is created, but I want to create the filter when my application starts, and then remove it when it ends

This is not how it is supposed to work. I assume that you need this filter because you want to integrate with another piece of software which looks for available "cameras", video sources. And you want to make your own available as such. This kind of trick requires that you register your camera, and then you are likely to take care of interprocess communication because source will be hosted by another process and you are to pass your data there somehow.

This basically requires to you fully register your source as a standalone device with capabilities to accept data from your app, and stream it further using standard API, and be internally aware of interprocess communication. Of course you can take it off (unregister) when your app terminates. I suppose you are underestimating the flow of data you will have to take care of.