Home > Back-end >  Vs2015 opencv2.4.7, findcontour function an exception occurs, a great god help genuflect is begged!
Vs2015 opencv2.4.7, findcontour function an exception occurs, a great god help genuflect is begged!

Time:11-26



As title, I use the official routine, running to findcontour_demo, appeared the following questions,



The following is the source code
 
//ConsoleApplication6. CPP: defines the entry point of the console application,
//

# include "stdafx. H"


# include "opencv2/highgui/highgui. HPP"
# include "opencv2/imgproc/imgproc HPP"
# include & lt; Iostream>
# include & lt; Stdio. H>
# include & lt; Stdlib. H>

Using the namespace CV;
using namespace std;

Mat SRC. Mat src_gray;
Int thresh=100;
Int max_thresh=255;
RNG RNG (12345);

///the Function header
Void thresh_callback (int, void *);

/* *
* @ function main
*/
Int main (int, char * * argv)
{
///Load the source image and convert it to gray
SRC=https://bbs.csdn.net/topics/imread (argv [1], 1);

///Convert the image to gray and blur it
CvtColor (SRC, src_gray, CV_BGR2GRAY);
The blur (src_gray src_gray, Size (3, 3));

///the Create Windows
Const char * source_window="Source";
NamedWindow (source_window, CV_WINDOW_AUTOSIZE);
Imshow (source_window, SRC);

CreateTrackbar (" Canny thresh: ", "the Source", & amp; Thresh, max_thresh thresh_callback);
Thresh_callback (0, 0);

WaitKey (0);
Return (0);
}

/* *
* @ function thresh_callback
*/
Void thresh_callback (int, void *)
{
Mat canny_output;
Vector Contours.
Vector
///Detect edges using canny
Canny (src_gray canny_output, thresh, thresh * 2, 3);
///Find contours
FindContours (canny_output, contours, hierarchy, CV_RETR_TREE CV_CHAIN_APPROX_SIMPLE, Point (0, 0));

///the Draw contours
Mat drawing=Mat: : zeros (canny_output. The size (), CV_8UC3);
For (size_t I=0; i{
Scalar color=Scalar (RNG) uniform (0, 255), the RNG. Uniform (0, 255), the RNG. Uniform (0, 255));
DrawContours (drawing, contours, (int), color, 2, 8, hierarchy, 0, Point ());
}

///Show a window in
NamedWindow (" Contours ", CV_WINDOW_AUTOSIZE);
Imshow (" Contours ", drawing);
}

When I to screening program is found findcontours functional operation when there is a problem, operation of contour parameters, see inside some part, it size obviously has a problem, some the size is too big, obviously


The same programs, the same pictures, use someone else's computer to run again, is that there is no problem inside the contour outline the size of the size is normal, don't know is what is wrong with my computer in this, a great god answers,

Ps: before you install opencv3.0, later for the environment changed back to 2.4.7, don't know whether this reason, but now run other program is no problem,

CodePudding user response:

Is anyone here??

Please answer agghh ah ~

CodePudding user response:

Before loading is opencv3.0, later for the environment changed back to 2.4.7 change the environment back and try again

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,

CodePudding user response:

refer to the second floor hezhe1008 response:
before loading is opencv3.0, later for the environment changed back to 2.4.7 change the environment back to try again


Two different version of the program language, and then change the code is in trouble

CodePudding user response:

reference zhao4zhong1 reply: 3/f
collapsed in the pop-up dialog box button to enter the corresponding debugging, press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until can read
the key of the problem is that I know is findcontous functional operation out of the question, causes the contours some members in the array size is beyond the scope, leading to the back of the problem, I just want to know what causes findcontours functional operation problems,

CodePudding user response:

The question that the findcontous function is open source,

CodePudding user response:

https://bbs.csdn.net/topics/398340146
  • Related