Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV HoughCircles
    primarykey
    data
    text
    <p>Im using Xcode and c++</p> <p>I have copied the HoughCircles code from the <a href="http://opencv.willowgarage.com/documentation/cpp/feature_detection.html?highlight=circle%20detection#cv-houghcircles" rel="nofollow noreferrer">OpenCV documentation</a>:</p> <pre><code>#include &lt;cv.h&gt; #include &lt;highgui.h&gt; #include &lt;math.h&gt; using namespace cv; int main(int argc, char** argv) { Mat img, gray; if( argc != 2 &amp;&amp; !(img=imread(argv[1], 1)).data) return -1; cvtColor(img, gray, CV_BGR2GRAY); // smooth it, otherwise a lot of false circles may be detected GaussianBlur( gray, gray, Size(9, 9), 2, 2 ); vector&lt;Vec3f&gt; circles; HoughCircles(gray, circles, CV_HOUGH_GRADIENT, 2, gray-&gt;rows/4, 200, 100 ); for( size_t i = 0; i &lt; circles.size(); i++ ) { Point center(cvRound(circles[i][0]), cvRound(circles[i][1])); int radius = cvRound(circles[i][2]); // draw the circle center circle( img, center, 3, Scalar(0,255,0), -1, 8, 0 ); // draw the circle outline circle( img, center, radius, Scalar(0,0,255), 3, 8, 0 ); } namedWindow( "circles", 1 ); imshow( "circles", img ); return 0; } </code></pre> <p>then modified it like this:</p> <pre><code>int main(int argc, char** argv) { VideoCapture cap(0); if(!cap.isOpened()) return -1; namedWindow( "circles", 1 ); Mat img, gray; for( ;; ) { cap &gt;&gt; img; vector&lt;Vec3f&gt; circles; cvtColor(img, gray, CV_BGR2GRAY); GaussianBlur(gray, gray, Size(7,7), 1.5, 1.5); HoughCircles(img, circles, CV_HOUGH_GRADIENT, 2, img-&gt;rows/4, 200, 100 ); imshow( "circles", img ); if(waitKey(30) &gt;= 0) break; } return 0; } </code></pre> <p>I get the error on both cases: error: base operand of '->' has non-pointer type 'cv::Mat' i then replace the -> with . and still get another error. This is the same with the code that i copied from the documentation.</p> <p>My theory is that this happens because its not getting and image or somehting. but when i take the HoughCircles code out, the camera runs fine.</p> <p>Any ideas please??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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