07-18-2005 07:44 AM
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 */
}
IplImage;
typedef struct CvSize
{
int width; /* width of the rectangle */
int height; /* height of the rectangle */
}
CvSize;
/* the constructor function */
inline CvSize cvSize( int width, int height );
Now, I used one of OpenCV functions to load an IplImage (ie IplImage *image) and returns a pointer to it. It successfully loads and returns a long integer pointer.
07-18-2005 08:08 AM
hi there
the representation of C/C++ - structures in LabVIEW are Clusters. Create a approbiate cluster containing an I32 "width" and "heigth" and connect it to the dll-node with type "connect to type" and Data format "handles by value" (maybe you have to play around a little bit with these settings). after that you shouls be able to access the elements in the stucture.
you have to be very carefull with the cluster and the structure: the elements must match exactly in their order and size.
best regards & good luck
chris
07-18-2005 08:49 AM
07-18-2005 10:06 AM
"Since I already received the pointer (which is a long integer), how can I go to where the pointer is pointing to and extract the width and height from the memory?..."
well, thats exactly the problem: LabVIEW can't work with pointers like C, you only can access the 4 bytes of memory allocated by the long integer. the memory "after" that pointer can't be accessed directly with labview. you need to allocate a buffer managed by the LabVIEW RTE large enough to hold the whole data and with the correct memory alignmend (the cluster i mentioned) and pass the pointer to that buffer to the dll with the options mentioned above. the data will then be written to that buffer and you are then able to access the data in the cluster inside the LabVIEW RTM.
I think there are some API - functions in user32.dll or kernel32.dll to access memory directly, but that's something to do on a long dark winter day...
(if i said something wrong pls let me know..)
best regards
chris
07-19-2005 08:58 AM