Home > Back-end >  Opencv in memory access violation occurred while running routine? How to do?????? What's the pr
Opencv in memory access violation occurred while running routine? How to do?????? What's the pr

Time:10-11

in opencv 2.4.4 + vs2010 always appear the following error when run the following code ~









Ignore after running



Continue to run



The code is as follows: ~


# include "opencv2/highgui/highgui. HPP"
# include "opencv2/imgproc/imgproc HPP"
#include
#include
#include

using 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 arg c, 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
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 (int I=0; i{
Scalar color=Scalar (RNG) uniform (0, 255), the RNG. Uniform (0255), the RNG. Uniform (0255));
DrawContours (drawing, contours, I, color, 2, 8, hierarchy, 0, Point ());
}

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


  • Related