Opencv's "findContours" error : Thread stopped with code -1073740777

2

I'm currently working on a program to process the datas of a 3D camera. Unfortunately i got an error using the opencv's "findcontours" function.

In fact, when i try to use it in my program i get these errors :

Thread 0x1a4c stopped with code 0 (0x0)

Thread 0x188c stopped with code -1073740777 (0xc0000417).

Thread 0x1c08 stopped with code -1073740777 (0xc0000417).

Thread 0x1330 stopped with code -1073740777 (0xc0000417).

Thread 0x1c90 stopped with code -1073740777 (0xc0000417).

Thread 0x1ed4 stopped with code -1073740777 (0xc0000417).

Thread 0x10d4 stopped with code -1073740777 (0xc0000417).

Thread 0x1a80 stopped with code -1073740777 (0xc0000417).

Thread 0x11bc stopped with code -1073740777 (0xc0000417).

Thread 0x1970 stopped with code -1073740777 (0xc0000417).

Thread 0x1428 stopped with -1073740777 (0xc0000417).

Program '[7932] Project_Camera.exe' stopped with code -1073740777 (0xc0000417).

Furthermore, i once got a window telling me this :

Unhandled exception at 0xc0000417 ... (ntdll.dll). A memory segment have been damaged.

( Sorry if it's not precise enough but i only remember this and didn't save what it was exactly. Plus, it's a translation of the real error cause my VS is in french so i apologize if the vocabulary is not the exact same.)

Here's my code :

float function (input)
{
   // First i get the datas from the camera and save it in an array of the size DATA_SIZE :
   // float distance[DATA_SIZE] (This array only contain ones and zeros)

   Mat img = Mat(Size(NB_ROW, NB_LINE), CV_32FC1, distance);

   Mat element_o = getStructuringElement(MORPH_ELLIPSE, Size(SIZE_OPEN, SIZE_OPEN), Point(-1, -1));
   Mat element_c = getStructuringElement(MORPH_ELLIPSE, Size(SIZE_CLOSE, SIZE_CLOSE), Point(-1, -1));

   Mat img_output;
   morphologyEx(img, img_output, MORPH_OPEN, element_o);

   Mat img_close;
   morphologyEx(img_output, img_close, MORPH_CLOSE, element_c);

   namedWindow("Image from morph ", CV_WINDOW_AUTOSIZE);
   imshow("Image from morph ", img_close);
   waitKey(0);

   ///Convert the image into B&W CV_8U format for the findContours function
   Mat bwimg;
   img_close.convertTo(bwimg, CV_8U);

   /// Find contours
   vector<vector<Point>> contours;
   printf("here"); // I see this one 
   findContours(bwimg, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);//SIMPLE, Point(0, 0));
   printf("here2"); // this one never show up, the program stops right before
   //... ( Then i get the minAreaRect from the contour and deduce an angle ) 
   return angle;
}

My VS solution own 2 projects : DLLCam : where my functions are defined and built as a dll Project_Camera : where i call the functions that are in the dll

To use opencv i built it following this link ( http://funvision.blogspot.fr/2015/11/install-opencv-visual-studio-2015.html ) to get 32 bit 3.1 version of opencv. I correctly set up the properties of the project to use the library.

Then, i'd like to know what could cause the problem, and how i can solve it.

Thanks for the help.

c++
multithreading
opencv
asked on Stack Overflow Jun 6, 2016 by Jorick

1 Answer

1

As Miki said in the comments, the issue was coming from the library i was using (opencv_310.lib).

I actually missed to compile the INSTALL project of the OpenCV solution for debug. Then, the files "opencv_310d.lib" were missing and i coulnd't link them. After compiling for Debug i found those files and used them in linker -> input, thus solving the problem.

answered on Stack Overflow Jun 7, 2016 by Jorick

User contributions licensed under CC BY-SA 3.0