Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You forgot to say if you are able to see the original image being displayed on the screen.</p> <p>I never get tired of telling people that checking the return of functions is a must!</p> <p>Consider <code>IplImage* img = cvLoadImage("images/00000038.jpg");</code> , how can you tell if this function succeeded or not? As far as I can tell, the error you are having might be from a function failing prior to <code>cvCanny()</code> being called.</p> <p>Anyway, I recently posted a <a href="https://stackoverflow.com/questions/6416117/simple-object-detection-using-opencv-and-machine-learning/6416361#6416361">code that uses cvCanny to improve circle detection</a>. You can check that code and see what you are doing differently.</p> <p><strong>EDIT</strong>:</p> <p>Your problem in this case is that you are passing to cvCanny input and output as a 3 channel image, when it takes only a single channel image. <a href="http://opencv.willowgarage.com/documentation/feature_detection.html#canny" rel="nofollow noreferrer">Check the docs</a>:</p> <blockquote> <p>void cvCanny(const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3)</p> </blockquote> <pre><code>Implements the Canny algorithm for edge detection. Parameters: * image – Single-channel input image * edges – Single-channel image to store the edges found by the function * threshold1 – The first threshold * threshold2 – The second threshold * aperture_size – Aperture parameter for the Sobel operator (see Sobel) </code></pre> <p>So, change your code to:</p> <pre><code>// Create an image to hold our modified input image IplImage* out = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1); // Do some smoothing //cvSmooth(img, out, CV_GAUSSIAN, 3, 3); IplImage* gray = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1); cvCvtColor(img, gray, CV_BGR2GRAY); // Do some Edge detection cvCanny(gray, out, 10, 20, 3); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload