I created a generic loop detection library loaded from a Delphi / Lazarus application. The main application passes a pointer to a bitmap to be processed by the function inside the library.
Here's the function inside the library. The "img" parameter is a pointer to my bitmap.
extern "C" { void detect_contour(int imgWidth, int imgHeight, unsigned char * img, int &x, int &y, int &w, int &h) { Mat threshold_output; vector<vector<Point> > contours; vector<Vec4i> hierarchy; Mat src_gray; int thresh = 100; int max_thresh = 255; RNG rng(12345);
On the Delphi side, I pass a pointer to an array of this structure:
TBGRAPixel = packed record blue, green, red, alpha: byte; end;
I need to process the bitmap in memory, so I do not load the file from the library.
The question is: is it right to assign a bitmap to cv :: Mat?
I ask about this because the code works without problems on Linux, but does not work on Windows compiled using Mingw.
Note: it does not work with SIGSEGV on this line:
blur( src_gray, src_gray, Size(10,10) );
EDIT: SIGSEGV is only created if I compile OpenCV in Release mode, in Debug mode it works fine.
Thanks in advance, Leonardo.