LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Linux OpenCV library wrapper

I downloaded and ran the installation script for Intel's OpenCV from http://sourceforge.net/projects/opencvlibrary/ .

I wrote a wrapper around OpenCV's libhighgui.so shared library file using LabVIEW's Call Library Function Node.
Within this wrapper, I called OpenCV's cvLoadImage function which is located in the libhighgui.so shared library file. I even verified that the function is within that by using the following Linux script: nm -D libhighgui.so | less
It displays the following as a result of running that script: 00014330 T cvLoadImage

I then make sure that I put in the correct parameters (CString filename, long iscolor) and the correct return type (unsigned long).

I also connected two wires into it for the inputs.

I get the following error message: Call Library Function Node: function not found within library

I do not know how I got this error. I attached the vi so that you can also check it.

Thanks,

Elliot
0 Kudos
Message 1 of 11
(4,913 Views)

@elliot.ee wrote:
I downloaded and ran the installation script for Intel's OpenCV from http://sourceforge.net/projects/opencvlibrary/ .

I wrote a wrapper around OpenCV's libhighgui.so shared library file using LabVIEW's Call Library Function Node.
Within this wrapper, I called OpenCV's cvLoadImage function which is located in the libhighgui.so shared library file. I even verified that the function is within that by using the following Linux script: nm -D libhighgui.so | less
It displays the following as a result of running that script: 00014330 T cvLoadImage

I then make sure that I put in the correct parameters (CString filename, long iscolor) and the correct return type (unsigned long).

I also connected two wires into it for the inputs.

I get the following error message: Call Library Function Node: function not found within library

I do not know how I got this error. I attached the vi so that you can also check it.

Thanks,

Elliot




Are you sure you have added the OpenCV shared libraries location to your LD_LIBRARY_PATH? Without that you get all kinds of weird errors when you try to link to a shared library, especially since the OpenCV library consists of many shared libraries depending on each other.

Rolf Kalbermatter

Message Edited by rolfk on 06-23-2005 05:07 PM

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 11
(4,902 Views)
/usr/share/lib is within LD_LIBRARY_PATH

Are you talking about Linux's LD_LIBRARY_PATH or NI's?
0 Kudos
Message 3 of 11
(4,893 Views)


@elliot.ee wrote:
/usr/share/lib is within LD_LIBRARY_PATH

Are you talking about Linux's LD_LIBRARY_PATH or NI's?




LD_LIBRARY_PATH is an environment variable used by the shared library loader. Not sure what you mean with LD_LIBRARY_PATH being from NI.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 11
(4,888 Views)
Sorry for the confusion, per your suggestion we performed "export LD_LIBRARY_PATH=/usr/local/lib" (the repository of our shared libraries) in .bash_profile, but LabVIEW still has the error:

"The function name specified for this node cannot be found in the library. Right-click the Call Library Function node and select Configure, then choose the correct function name."

I verified the name of the called function with "nm -D " to no avail. An ldd on the library revealed the libraries dependencies and I made sure their paths where also in LD_LIBRARY_PATH. In case anybody is interested the specific library I am trying to call is attached (but I did not include all its dependencies.)

Thanks!
Sam Miller
0 Kudos
Message 5 of 11
(4,870 Views)
libcxcore is a dependency
0 Kudos
Message 6 of 11
(4,840 Views)
In addition, libhighgui.so may be a dependency
0 Kudos
Message 7 of 11
(4,839 Views)
Here's the library description of the C++ function cvLoadImage from the OpenCV documentation:

IplImage* cvLoadImage(const char* filename, int isColor = 1);

filename -> Name of file to be loaded

isColor -> Specifies colorness of the loaded image:
* if >0, the loaded image is forced to be a 3-channel color image
* if 0, the loaded image is forced to be greyscale;
* if <0, the loaded image will be loaded as is

File formats that are supported are Window bitmaps, jpeg files, PNG, Portable image format, Sunrasters, and TIFF files.

cvLoadImage is located within cvHighGui.so shared library.


IplImage is a struct located in the library cxCore library.
    typedef struct _IplImage
{
int nSize; /* sizeof(IplImage) */
int ID; /* version (=0)*/
int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */
int alphaChannel; /* ignored by OpenCV */
int depth; /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
char colorModel[4]; /* ignored by OpenCV */
char channelSeq[4]; /* ditto */
int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels.
cvCreateImage can only create interleaved images */
int origin; /* 0 - top-left origin,
1 - bottom-left origin (Windows bitmaps style) */
int align; /* Alignment of image rows (4 or 8).
OpenCV ignores it and uses widthStep instead */
int width; /* image width in pixels */
int height; /* image height in pixels */
struct _IplROI *roi;/* image ROI. when it is not NULL, this specifies image region to process */
struct _IplImage *maskROI; /* must be NULL in OpenCV */
void *imageId; /* ditto */
struct _IplTileInfo *tileInfo; /* ditto */
int imageSize; /* image data size in bytes
(=image->height*image->widthStep
in case of interleaved data)*/
char *imageData; /* pointer to aligned image data */
int widthStep; /* size of aligned image row in bytes */
int BorderMode[4]; /* border completion mode, ignored by OpenCV */
int BorderConst[4]; /* ditto */
char *imageDataOrigin; /* pointer to a very origin of image data
(not necessarily aligned) -
it is needed for correct image deallocation */
}
IplImage;

0 Kudos
Message 8 of 11
(4,835 Views)
I realize that there may be other dependencies within the .so files. If you have a Linux box and if you don't mind installing the OpenCV program to help me find out what is wrong from http://sourceforge.net/projects/opencvlibrary/ , that will be great! Thanks.
0 Kudos
Message 9 of 11
(4,803 Views)
Well, I'm not sure about Linux but under Windows a C++ compiled function name is always decorated with some extra stuff. For instance your optional parameter isColor is something not possible with standard C functions. LabVIEWs Call Library Node can only handle standard C functions or more precisely global functions not expecting some inherent parameter such as a class pointer which under Windows is done through the thiscall calling convention instead of the stdcall one.

You may actually have to create a wrapper shared library for your OpenCV library to be able to call the functions throught the Call Library Node. My Linux knowledge on this area is however quite limited.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 11
(4,799 Views)