LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCV on NI1752 Smart Camera - VxWorks cross compilation

Solved!
Go to solution

Hi,

    I would like to use opencv dll in labview to be used on my NI1752 smart camera.  I understand that I have to compile opencv for VxWorks.  Has anyone done this before?  Or has anyone compiled any library like OpenCV for VxWorks?  I am new to this and would appreciate any help..

 

Best,

Joe

0 Kudos
Message 1 of 10
(4,084 Views)

Hi Joe,

 

I have not personally tried to compile OpenCV for VxWorks but from a quick search, the codebase for the OpenCV library has a lot of x86 assemblies which will make porting it to PowerPC processors like VxWorks very difficult. This forum post goes over this topic: https://www.chiefdelphi.com/forums/showthread.php?t=69494

 

Which functions are you looking to use? You can look at whether those are available with our Vision Development Module.

 

I hope this helps!

T. Le
Vision Product Support Engineer
National Instruments
0 Kudos
Message 2 of 10
(4,017 Views)

While that discussion you link to is interesting, it is pretty outdated (2008). At least in respect to ARM support, OpenCV officially has an OpenCV4Android SDK with an armv7a architecture. So for the newer ARM based cRIO it should be possible to recompile the OpenCV libraries in the NI provided Eclipse IDE. And of course the same applies even more for the x86_64 based high end cRIOs.

A recompilation with the NI Linux Realtime specifc Eclipse toolchain is most likely unavoidable and there are most likely some additional config changes that need to be done to the make/configure scripts to make it all work.

 

You are in so far correct that porting of the OpenCV library to the PowerPC/VxWorks based cRIOs is most likely a herculean undertaking with little prospect for success. 

 

Rolf Kalbermatter
My Blog
Message 3 of 10
(4,009 Views)

@rolfk wrote:

 

 

You are in so far correct that porting of the OpenCV library to the PowerPC/VxWorks based cRIOs is most likely a herculean undertaking with little prospect for success. 

 


I agree with this statement 100%. While not impossible, it's not something I would want to try unless there were no other options.

 

OP, you've made a few forum posts (and I think an SR or two) over the past few weeks all with the goal of trying to port OpenCV code to the smart camera. I haven't seen any explanation of why you need to get this particular method working and I think that should be discussed. 

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 10
(4,002 Views)

     Thanks for your quick replies.  I am working on a project that uses NI1752 smart camera on an assembly line (graduate school project).  I would like to use OpenCV for real time image processing as I have prior experience in it.  I find it more flexible to use for my application as I have analyze some complex images.  

     Is it possible to use the dll on the host computer rather than the camera?  I would like to get the image from the camera and run the vi on the host computer.  When I tried to do this, i got the following error..

 

LabVIEW: Failed to load shared library dll_32.dll:img_show:C. Ensure that the library is present on the RT target. Use either MAX to install NI software or FTP to transfer custom libraries to the RT target.
Deployment completed with errors

 

The vi was made under the smart camera in the project.  I tried making a llb with dll included, and transferring it to the camera.  But its still showing the same error.

 

Best,

Joe

 

 

0 Kudos
Message 5 of 10
(3,991 Views)

I am doing a project in my graduate school which requires me to analyze the images from NI1752 smart camera on an assembly line.  I would like to do the real time image processing using OpenCV as I have prior experience in it and my project requires high flexibility in the image processing.

 

Is it possible to do the computation on the host computer?  I tried to write a VI to get the image from the camera and then send the image to the opencv dll for analysis.  I included the vi under the smart camera in the project.  I got the following error

LabVIEW: Failed to load shared library dll_32.dll:img_show:C. Ensure that the library is present on the RT target. Use either MAX to install NI software or FTP to transfer custom libraries to the RT target.
Deployment completed with errors

 

I created an LLB and uploaded to the camera, but the problem persists.  Can you suggest a way to do this?  I have seen some projects where they have done this..

 

Best,

Joe

0 Kudos
Message 6 of 10
(3,991 Views)

It's completely unimportant where you store the DLL. The VxWorks based OS on the Smart Camera doesn't understand it and can't load it into memory. The DLL is a Windows specific executable format that only Windows knows how to properly load into memory to execute it. Even more so, Windows DLLs are binary executable code modules compiled for the Intel x86 processor. Even if your VxWorks system would know how to load the DLL into memory, its contents would be nothing more than unintelligent gibberish for the PowerPC processor in your smart camera.

It's akin to trying to load a JPG image in an application that only understands Windows bitmaps: The JPG image only contains random binary data for that application.

If you want to use OpenCV rather than IMAQ Vision on this smart camera, your only option is to have another program on a Windows PC which does your image analysis and then from your smart camera send the acquired images to that application (over direct TCP/IP communication or over a shared network drive as file) and eventually send the processed data back afterwards.

Another option would be to maybe use a different smart camera. NI has the NI 1772, NI 1772C, NI 1774, NI 1774C, NI1776, NI 1776C, NI 1778 line which use an Intel compatible processor and the Pharlap ETS OS, which with several caveats can load Windows compatible DLLs. One of the caveats is that the DLL and all its dependencies need to be compiled with one of the supported Visual C compilers, VC 6, VC 2003, VC 2008, or VC 2010. Any other compiler including MinGW and other Gnu C based compilers will generally not work unless you are a real Gnu C linker guru and know exactly what command lines to tweak to get the right binary.

There might be new NI Linux Realtime based smart cameras in the making, but I don't know. They would be likely the most trivial to get OpenCV running on, as the user space environment is very much Linux like. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(3,982 Views)

Hi,

    Thank you for the reply.  I understand that the camera cannot execute the dll but I want the labview to execute the dll on the desktop computer not on the camera.  I just need the image from the camera.  I have attached the pic of the vi i created.  

Thank you and Regards,

Joe

0 Kudos
Message 8 of 10
(3,972 Views)
Solution
Accepted by topic author phoenix_777

That obviously can't work. You need to write two independent applications. One for your Windows computer which receives the image through TCP/IP communication or through a shared network location as a file and calls your OpenCV DLL to do your analysis and another one that does the image acquisition on your smart camera and sends the images to the Windows application.

 

Maybe there is a possibility to access your smart camera directly from your Windows application by installing some drivers in your Windows system but I have no experience with the NI smart cameras, so can't tell you what can and cannot be done with them.

 

In any case you have to put the application for your Windows system under the My Computer group in your project, not under the NI1752 Smart Camera group for your device. If the smart camera can be accessed as a simple camera under Windows your program you show in the image should basically work, provided you can see the camera in NI MAX under "My System->Devices and Interfaces" and use the device name assigned there instead of img0.

 

This is explicitly not the name as shown in NI MAX under "Remote Systems".

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 10
(3,965 Views)

Hi,

   Thank you for the information.  That clarified a lot of doubts.  This is what I am thinking of doing.  I write a VI on the smart camera to send the acquired image over FTP to the desktop computer and then wait for the response.  The LabView VI on the computer will look for new image in the FTP folder and then send it to the opencv dll and then send the results back as a txt file or a numeric constant over FTP back to the camera.  Is this what you meant?  If so, can you tell me how I can make the VI wait for the response? 

 

Thank you and Regards,

Joe

0 Kudos
Message 10 of 10
(3,960 Views)