LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stream Video from OpenCV/Pointers

I'm working on a piece of code which is intended to use the openCV functions.  There are numerous reasons I'm not using LabVIEW vision - one of which is that I'd need to pay $400 per deployment system, and that gets expensive.  At its most basic, the code is intended to capture pictures from a USB camera quickly and display them.  I  know OpenCV has its own camera display functions, and they are very nice, but I'm trying to display the images in LabVIEW for now for reasons I cannot, at this time, change.

 

So, my first order of business was to get opencv to communicate with LabVIEW at all.  I did so using the attached code.  This was straightforward.  Create the array containing the pixel values in LabVIEW, pass that array to my DLL, populate the array in the DLL, and return.  The trouble is that this code is fairly slow (it runs at about 1 Hz when I put a while loop around ).  It seems to me that there should be a quicker way to do it.  I have a few ideas, but I'd like to see if there are any better ones out there.  I have tried using the moveBlock dll to try to avoid copying the array element-by-element in the C code, but was unsuccessful.  If people think this is worth a shot, I'd be willing to give it another try.

 

One thing I was considering doing was having the C code run in parallel with LabVIEW.  C would have a pixel array it was constantly updating.  LabVIEW would have a pointer to that array and would read from the array every pass through its own loop.  This seems convoluted and error-prone to me, so I'm hoping someone else has another suggestion.  The idea behind this is somewhat related to having a producer-consumer loop, but is certainly not identical, because not every frame captured by the C program needs to be displayed in LabVIEW.  If I'm wrong about this being related to producer-consumer architecture, please forgive me.  I am just trying to make it clearer.

 

I'm very willing to further explain anything that I've glossed over (or that needs clarifying).  Additionally, if I should post more DLLs so you can run the code, I can, but there're a few megabytes of DLLs, and there's no need to bog down the server if nobody's going to use them anyway.  Also, the code would only work if you were using a 640x480 camera.

Download All
0 Kudos
Message 1 of 2
(2,979 Views)

There is a reason the Vision extension for LabVIEW costs something. That reason is that it is quite hard to write a good interface to any kind of vision API for LabVIEW that: works reliable, has a good performance and is comfortable to use.

 

Unless you are going to distribute hundreds of your application, the time spent to develop your own solution will NEVER be recovered in comparison to spending $400 for a runtime license.

 

That said there is a less expesive variant called IVision from Hytek Automation. They used OpenCV too and did all the work of creating the intermediate shared library, which is a lot more than a simple warpper around OpenCV.

Rolf Kalbermatter
My Blog
Message 2 of 2
(2,968 Views)