c++ - Open cv , Run code in tutorial of Finding contours in your image? -


i'm starting learn how use opencv libraries. i've downloaded , installed opencv 2.4.10 , , have run example " in tutorial of finding contours in image " using visual studio 2010. code compiles, every time run it, crashes,and showing error in image link following message:

windows has triggered breakpoint in edgedetection.exe.

this may due corruption of heap, indicates bug in >edgedetection.exe or of dlls has loaded.

this may due user pressing f12 while edgedetection.exe has focus.

the output window may have more diagnostic information.

i don't know, reason.here's offending code:

#include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <stdio.h> #include <stdlib.h>  using namespace cv; using namespace std;  mat src; mat src_gray; int thresh = 100; int max_thresh = 255; rng rng(12345);  /// function header void thresh_callback(int, void* );  /** @function main */ int main( int argc, char** argv ) {   /// load source image , convert gray  // src = imread( argv[1], 1 );     src=cvloadimage("fish.bmp");   /// convert image gray , blur   cvtcolor( src, src_gray, cv_bgr2gray );   blur( src_gray, src_gray, size(3,3) );    /// create window   char* source_window = "source";   namedwindow( source_window, cv_window_autosize );   imshow( source_window, src );    createtrackbar( " canny thresh:", "source", &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<vector<point> > contours;   vector<vec4i> hierarchy;    /// 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) );    /// draw contours   mat drawing = mat::zeros( canny_output.size(), cv_8uc3 );   for( int = 0; i< contours.size(); i++ )      {        scalar color = scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );        drawcontours( drawing, contours, i, color, 2, 8, hierarchy, 0, point() );      }    /// show in window   namedwindow( "contours", cv_window_autosize );   imshow( "contours", drawing ); } 

the breaking appears @ line :

    findcontours( canny_output, contours, hierarchy, cv_retr_tree, cv_chain_approx_simple, point(0, 0) ); 

so,i me.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -