Replacing DirectShow with managed OpenCV. Video playback / capture / CV

how do you get the screencapture in there?

Having fun with the new libraries

@alg
yes, i hope if opencv implement opencl then all fine

@sebl
me? webcam focus to screen monitor and ImpPant in my keyboard (dual monitor) and cut region for post here

@sugokugenki:

I downloaded the openCV nodes, but they won’t behave as ‘dynamic plugin’, only the compiled ones work when I extract the Prerequisites zip-file. I can’t right)click on them and start editing the code…

Anyone knows what I am doing wrong?

I want to check out the code, to see if I could create another video player node that outputs to your custom ‘bitmap’ format, to make it compatible with these plugins…

@ft you can try my branch https://github.com/smakhtin/VVVV.Nodes.EmguCV . I think it’s would not behave like dynamic plugins, because project is not prepared. Just install Visual Studio and setup Debug properties in the project. I have your VLC plugin sources and planned to integrate it by myself, but i still not received latest changes from you and it’s would be nice, if you fork my branch on GitHub and just pull your changes. If you have some problems with dependencies or Git - msg me in skype. My skypename - algariol.

This .NET wrapper for FFMPEG looks super simple to implement as a plugin:
http://code.google.com/p/ffmpeg-sharp/source/browse/trunk/ffmpeg-sharp/#ffmpeg-sharp%2Fsrc%2FVideo
EDIT: and doesn’t have the harsh restrictions of vlc’s GPL license.

(just a suggestion!)

Thanks.

I’ll take a look at it.

Edit: project seems dead, doesn’t compile. Pity.

@ft are you checking my latest commits? I’m uploading only compiling builds.

@all looks like VideoPlayer works only with VFW codecs. All codecs integrated in Windows 7 x64 is not working. It’s can be solved by reassign all file formats to ffdshow i think.

Does anyone know how I can create a

new Emgu.CV.Image<Bgr, byte>()

It tells me it is not accessible due to the security level or something (I guess it’s not a public class). I don’t know anything about OpenCV (yet), or about EmguCV. Is there a way to get an Image, and then fill the bytes of that image with my data? Or a way to create an image, from some byte ptr or something?

From VideoInNode:

FBuffer = new Image<Bgr, byte>(new System.Drawing.Size(FCapture.Width, FCapture.Height));

UPD: AsTexture is slow as hell. We need to fix it.

Hello,

At this time, only ImageRGB has been implemented, which disables the possibility to load textures with an alpha channel for example.

I managed to alter Vlc so that it has an Image Output Pin, so that it can be rendered (or processed in between) using AsTexture. The Vlc plugin can also load image files, but the way it works now, I have to throw away the alpha channel, which is a shame (and I guess one day video codecs that can handle an alpha channel will exist too).

Should we make this more ‘open’, maybe generic like EmguCV’s own Image. That could make it somewhat harder to implement new nodes, since they have to be able to handle multiple formats, but I hope that EmguCV would take care of most of that?

Any ideas in that direction?

Another thing, there are 2 git repositories now. Is there a good reason to do so, or would it be better to merge them together? I think this could be more powerful, if we combine the efforts of multiple people.

Also, it would be nice to have an easy way to expose only the necessary ‘Image’ classes to people, such that this could become a uniform format to communicate color information. That way, everyone could produce dynamic plugins that fit into the chain, and they wouldn’t be forced to use any other EmguCV functionality. Maybe we should even pass a structure around that has no dependencies at all on EmguCV, but only uses Bitmap or something. Nodes that use EmguCV could wrap this Bitmap into an EmguCV Image, and do their thing with it. I don’t know if this would be a performance hit, but it would keep things even more open to everyone.

Elliot, Alg, others? What are your opinions on this?

Hey ft

Indeed a more generic Image type is more favorable

EmguCV doesn’t provide a single class with this capability, instead preferring to use template classes. In c++ this isn’t the case (but in c++ you can more generally type-cast pointers).

My suggestion is in the prototype new CVImage type class described in the ‘eventBased’ branch https://github.com/elliotwoods/VVVV.Nodes.EmguCV/blob/eventBased/Types/CVImage.cs

Multiple repositories / branches is the natural state from development on git/github.
Generally we should be looking to promote users and developers to look to the central branch (the upsream/master branch), which currently is defacto the master branch on my repo.

And I should then accept pull requests from other developers to bring their code into that branch. I’ve pulled in alg’s changes now so you can use the master branch there now.

However, please have a look also at the eventBased branch (as well as master branch). The eventBased branch sketches out a couple of ideas:

  • Abstract base classes for inputs and outputs (so people can make their own easily). I’m having issues with multiple inheritance, and need a clever elegant route around it, but this seems like it’d be an issue only for AsTexture / DX9output plugs, so we could work around specificically in this case
  • Thread in input node drives thread throughout graph using events.
  • CVImage can hold either 8bit Gray, RGB or RGBA. When a node accepts it as an input it requests one type, and CVImage either provides that type natively (if available) or automatically converts from what is inside (e.g. AsTexture requires RGBA, so if we have an RGB input, CVImage automatically converts to RGBA). So a video playback node can output RGBA if it likes, and nodes downstream can request whichever format they prefer.

Elliot

I will check CVImage out.

Something else I was thinking about.

I think including the lock in the image is a great idea. I would suggest to change that to a ReaderWriterLock though. This way, multiple nodes that are downstream from an ‘image-producing-node’ could be reading the image at the same time.
This wouldn’t be useful if everything is computed in vvvv’s main thread, but if also the detection-nodes (like ‘blob detection’ or something) would work outside the main thread, and only update the output pins when they successfully processed something, these nodes could give you information ‘as soon as possible’ without slowing down vvvv’s framerate.

In some situations this behaviour could be the desired behaviour.

What do you think of the ‘more loosely coupled to EmguCV’ idea, of passing a Bitmap or something similar around instead of an Emgu.CV.Image?

i cant open any of the example files, i have 26.1 win seven 64
i supose to put all the .dll on any vvvv subfolder or only on the same path as the v4p file ?

this is the tty output

Everything you know is wrong
  physical : in use= 29,  total =   4102908 kb,  avail =   2895744 kb
   virtual : in use=  5,  total =   2097024 kb,  avail =   1998192 kb
    paging : in use=  0,  total =   4194304 kb,  avail =   4194304 kb

00:00:00  -  : Hid (Human Interface Devices) DeviceController - OnDeviceChange
00:00:00  -  : Hid (Human Interface Devices) DeviceController - OnDeviceChange
00:00:00  -  : enumerating game devices
00:00:00  *  : ISO-10646-UCS-4 already exists in enum StringCodec.
00:00:00  *  : ISO-10646-UCS-4 already exists in enum StringCodec.
00:00:00  *  : ISO-10646-UCS-4 already exists in enum StringCodec.
00:00:00  *  : ISO-10646-UCS-2 already exists in enum StringCodec.
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\help\ to VVVV.Hosting.Factories.PatchFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\plugins to VVVV.Hosting.Factories.DotNetPluginFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\plugins to VVVV.Hosting.Factories.CSProjectFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\editors to VVVV.Hosting.Factories.EditorFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\effects to VVVV.Hosting.Factories.EffectsFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\modules to VVVV.Hosting.Factories.PatchFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\freeframe to VVVV.Hosting.FreeFrameFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\vst to VVVV.Hosting.VSTFactory (cached by C:\Program Files (x86)\vvvv_45beta26\nodelist.xml)
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.Factories.DotNetPluginFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.Factories.CSProjectFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.Factories.EditorFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.Factories.EffectsFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.Factories.PatchFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.FreeFrameFactory
00:00:01     : adding C:\Program Files (x86)\vvvv_45beta26\ to VVVV.Hosting.VSTFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\plugins to VVVV.Hosting.Factories.DotNetPluginFactory (cached by C:\Program Files (x86)\vvvv_45beta26\addonpack\nodelist.xml)
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\plugins to VVVV.Hosting.Factories.CSProjectFactory (cached by C:\Program Files (x86)\vvvv_45beta26\addonpack\nodelist.xml)
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\modules to VVVV.Hosting.Factories.PatchFactory (cached by C:\Program Files (x86)\vvvv_45beta26\addonpack\nodelist.xml)
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.Factories.DotNetPluginFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.Factories.CSProjectFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.Factories.EditorFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.Factories.EffectsFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.Factories.PatchFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.FreeFrameFactory
00:00:02     : adding C:\Program Files (x86)\vvvv_45beta26\addonpack\ to VVVV.Hosting.VSTFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.Factories.DotNetPluginFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.Factories.CSProjectFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.Factories.EditorFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.Factories.EffectsFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.Factories.PatchFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.FreeFrameFactory
00:00:02     : adding C:\Users\Andres\Desktop\opencv\tests\ to VVVV.Hosting.VSTFactory
00:00:02  -  : Texture  (Width: 1, Height: 1, Format: X8R8G8B8, Mip Map Count: 1) loaded in 0.002 seconds.
00:00:02  *  : couldn't connect pins of nodes IOBox (String) and ImageLoad (EmguCV). 
00:00:02  *  : couldn't connect pins of nodes ImageLoad (EmguCV) and AsTexture (EmguCV RGB). 
00:00:02  *  : couldn't connect pins of nodes AsTexture (EmguCV RGB) and Quad (DX9). 
00:00:02 ERR : Corrupt link-message in Patch C:\Users\Andres\Desktop\opencv\tests\test-ImageLoad.v4p. srcViewPin or dstViewPin is nil!
00:00:02 ERR : Corrupt link-message in Patch C:\Users\Andres\Desktop\opencv\tests\test-ImageLoad.v4p. srcViewPin or dstViewPin is nil!
00:00:02 ERR : Corrupt link-message in Patch C:\Users\Andres\Desktop\opencv\tests\test-ImageLoad.v4p. srcViewPin or dstViewPin is nil!
00:00:02  -  : Hid (Human Interface Devices) DeviceController - OnDeviceChange

@ft :
nice idea on the read/write lock
we’d then need to trigger events in listeners in seperate threads.
i’m not 100% sure how to use delegates properly for this (as we couldn’t use the existing Event model, as each downstream event listener would be activated in series)

but i presume we could have a List of delegates
and then trigger each delegate in a seperate Thread. With each Thread stored in a List.

@vjc4 : to confirm: the patch loads but you get red nodes?

make sure you have the dll’s from https://github.com/elliotwoods/VVVV.Nodes.EmguCV/blob/master/Prerequisites.zip in the same folder as the plugin (you might want to make sure you don’t copy the old version of the plugin from that download).

still the same
tested on beta 25 same issue, on another pc same problem
im doing something wrong for sure, but i dont know what

for some reason the node its looking for VVVV.Nodes.EmguCV.dll file into \bin\Debug

i already try creating that folder, and putting the dll into vvvv main folder, still the same,

http://andresc4.com/error.jpg

hi guys
still unable to run the face tracking nodes (cpu or gpu)
the other nodes works as expected in the last release
any tips welcome!
thx
C.

@vjc4)), ((user:circuitb sorry for the long answer, was on vacation and workshops. Hope i can check all code in a day or two and post something like binary release with installation instructions.

We also waiting for the new “Subgraph” framework from @vux, so expect big API changes in the future.

Hmm
this project is kind of in it’s worst state of rot right now
3 core models
2 of which are currently open
1 of which currently works (except when it doesn’t!)

It’s going to be great to get the subgraph stuff accessible enough to create our own flexible nodes, and for us properly to discuss points on the platform together.

In fact, this is looking like a really great experiment in distributed development on the VVVV platform of a near-core feature.
I really hope it stays open and flexible enough for lots of ideas / code / different ambitions to get on board and flesh out its success!

But we need to agree on a core, before we start chatting about bug-fixes.
Perhaps we could arrange a skype chat sometime over this/next week.

Propose Monday 7PM UK time / 8PM EU time?
invitations to alg, vux, ft + anyone else who’s either a user or developer. let’s keep the chat on track and make a proposal for what to do next.

I agree, we need a plan and roadmap. I will create a chatroom for you and vux, but don’t have ft contact in skype. For everyone interested, my skypename - algariol.