Good afternoon,
I am trying to run OpenCV
through a DLL
and use it in a LabVIEW
application.
I have correctly acquired an image in LV
and passed the byte array to the DLL
.
I can loop and print out in a text file the values for every pixel and match them to the output in LV, so I know that all my pixels are in the right position, for the exception that LV adds 2 columns at the beginning, with the first 2 values reserved for height and width and the rest are arbitrary numbers. But all this should do is produce a streak on the left side of the image.
Next, I am using the following lines to convert and display the image.
a[0]
, a[1]
... etc. are channels.
The output image comes out as a very horizontally stretched out image with pixels spaced equally 15-20 pixels apart and surrounded by black pixels. I attached a screenshot
_declspec (dllexport) double imageProcess(int **a, int &x, int &y, int &cor,int &cog,int &cob,int &cow, int th, int hth)
{
y = a[0][0];
x = a[0][1];
Mat image(y, x, CV_8U, a[0]);
namedWindow( "Display window", CV_WINDOW_NORMAL ); // Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
return (0);
}
Additionally I tried using this code with the same effect:
IplImage* cv_image = cvCreateImageHeader(cvSize(x,y), IPL_DEPTH_8U, 1);
cvSetData(cv_image, a[0], cv_image->widthStep);
Mat image = Mat(cv_image, false);
Can anyone please help me explain why this is happening during my image creation?
Note, Unfortunately, I cannot provide the original image/capture from LV, but I can say that it doesn't look anything like that and I am working with everything in grayscale.
Output Image: