2

I realize this question might be closed with the "not enough research". However I did spent like 2 days googling for it and didn't find a conclusive answer.

Well I have an application that spawns a window, not written in c++. This application can have a c-interface with dlls. Now I wish to use the power of OpenCV, so I started on a dll to extend. Ss passing image data from/to the application is near impossible (only capable of passing c-strings & double values directly - using the hard drive for drawing is slowing down too much for real time image manipulation).

I am looking into letting opencv draw the image data directly - onto the window. I can gain the window handle easily, so would it then be possible to let openCV draw their data "over" the other window - or better into the other window? Is this even possible with any library (FFMPEG, or something else)?

paul23
  • 8,799
  • 12
  • 66
  • 149

1 Answers1

3

Yes, it's possible, but it's far from ideal. You can use GDI to draw on top of the other window (just convert IplImage to HBITMAP). Another technique is to do such drawing in a borderless layered window.

An easier approach is, since you own both applications, to write a function that passes an IplImage between them using standard C data types, after all, IplImage is nothing but a data type that is built from these standard types.

Here is how you will disassemble IplImage into 5 standard parameters:

  • The size (int, int) of the image (width/height);
  • The (int) bit depth of the image;
  • The number (int) of channels;
  • And the (unsigned char*) pixels of the image;

After receiving these parameters on the other side, you may wonder: how do I assemble a IplImage from scratch? Call cvCreateImageHeader() followed by cvSetData().

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • hmm the problem is the other application is interpreted and from testing creation of an image - even from a build in array- is slow as hell; not something you can do a hundred times a second. It is actually a multiple times as slow as using build-in-functions to read image data from a file. – paul23 Feb 02 '13 at 01:44