From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

opencv 248 for Labview 2011

Hi 

Lots of examples of using labview but working code examples seem to be sparce on the ground - 

Even though DLL wrapping seems to be the correct means of bridging to opencv most of the code when ran with VS2010 are in need of missing dependcies 

 

the LabView CVI approach seems to be deprecated as the examples are based on 2008 versions of Labview none of these work as dependiecies of files are missing 

 

all Im looking for is a consistance example of using opencv - can someone point me to a link or a code snippet

 

tks

M

0 Kudos
Message 1 of 9
(6,002 Views)

Hello,

 

there are some examples (source code, .dll and Labview) here:

 

https://decibel.ni.com/content/blogs/kl3m3n

 

It's OpenCV 2.4.6 (also 2.4.5 if I remember correctly), but you can simply rebuild the source code to create a compatible .dll.

 

Hope this helps.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 9
(5,992 Views)

Yeh I gone through these and have even compiled to opencv 248 but not all of these work - I have got some of them to work but a few are missing dependencies 

 

 

 there is not one clear means of defining the dll - all take a different approach in wrapping opencv...

 

this in my opinion adds to the confusion

 

tks for the link 🙂

M

0 Kudos
Message 3 of 9
(5,987 Views)

Hello,

 

you should first check if you can get the source code from the link to compile in OpenCV 2.4.8. How did you compile them, if dependencies are missing?

 

All of the examples posted at the provided linked were tested and definitely work (VS2010 and OpenCV 2.4.6). All .dlls are built using identical procedure. Cmake is used to generate a Visual Studio project, which configures the dependencies and libraries automatically.

 

Could you please explain what did you mean by " there is not one clear means of defining the dll - all take a different approach in wrapping opencv"?

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 4 of 9
(5,985 Views)

Out of all the examples on the link that you provided GrabCut was the only one I could get working - the other dll files require changing and Im not profucent enough to figure out what is missing - the examples are rather complex and are designed for a specific use case plus the source for the DLL the templates are different 

 

I dont think any of the examples actualy return an array object type - at the moment Im trying to return and unsign char from my opencv to Labview this is my issue at the moment 

 

" there is not one clear means of defining the dll"

DLL's can be writen in both Win API and C there may be a mixture of in the DLL's provided from what i can see - confusion for a noob

 

Also to complete the post there is another option of using Labview CVI in interfacing to opencv but I havent gotten much of this to work as of yet >> cant find a cv.h file that works

 

0 Kudos
Message 5 of 9
(5,980 Views)

Hello,

 

I am sorry, but I do not understand your problem completely. The examples are defined as C calling convention. Can you point out the confusion?

 

You should pass the pointer to an array, not the actual array. I attached a simple example on how to pass the u8 data. The program simply adds a constant to the passed data.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 6 of 9
(5,976 Views)

Hi thanks for the code 

 

I dont know how familar you are with opencv – but there is a Mat data type that is defined as an unsigned char Ive been trying to get it to return to Labview it a 2 dimesional data type– Im still stil trying to debug the data structure

 

I had found a basic example of using c++ code using a constant that is added to an image so I decided to add some opencv  to it and see what happens – All Im trying to do is load an image file using opencv

 

It may be the case that the size of the input and output arrays must the same – trying to work through that at the moment here is the code Im working on atm 

 

tks

M

0 Kudos
Message 7 of 9
(5,973 Views)

sorry typo in the line it should read 

 

unsigned char *pOutImage = (unsigned char*)(result.data);

0 Kudos
Message 8 of 9
(5,972 Views)

Hello,

 

I am a bit familiar with OpenCV, so I know Mat is not a datatype, but a class.

 

I suspect that you did not properly look at the examples at the link I provided. But anyway, here is an example of Canny edge detection .dll (or rather the source code that is used to build the .dll). Plese see the attachment.

 

And here is the result:

 

test_FP.png

 

 

 

P.S.: I always convert image to array in Labview, since I never noticed any performance degradation. You can alternatively use "map pixel pointer" function (this has been discussed on the forum before).

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 9 of 9
(5,960 Views)