Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 986131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:16:15+00:00 2026-05-16T05:16:15+00:00

Im using Xcode and c++ I have copied the HoughCircles code from the OpenCV

  • 0

Im using Xcode and c++

I have copied the HoughCircles code from the OpenCV documentation:

#include <cv.h>
#include <highgui.h>
#include <math.h>

using namespace cv;

int main(int argc, char** argv)
{
    Mat img, gray;
    if( argc != 2 && !(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<Vec3f> circles;
    HoughCircles(gray, circles, CV_HOUGH_GRADIENT,
                 2, gray->rows/4, 200, 100 );
    for( size_t i = 0; i < 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;
}

then modified it like this:

int main(int argc, char** argv)
{
    VideoCapture cap(0);
    if(!cap.isOpened())
        return -1;
    namedWindow( "circles", 1 );

    Mat img, gray;
    for( ;; )
    {

        cap >> img;
        vector<Vec3f> circles;      
        cvtColor(img, gray, CV_BGR2GRAY);
        GaussianBlur(gray, gray, Size(7,7), 1.5, 1.5);
        HoughCircles(img, circles, CV_HOUGH_GRADIENT, 2, img->rows/4, 200, 100 );
        imshow( "circles", img );
        if(waitKey(30) >= 0) break;
    }

    return 0;
}

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.

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.

Any ideas please??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:16:16+00:00Added an answer on May 16, 2026 at 5:16 am

    Are both compiling errors? What error do you get when you use . to access img members? I’m certain that you should not use -> in this case since img is not a pointer to Mat.

    According to the API reference manual (you should take a loot at it):

    void HoughCircles(Mat& image, vector<Vec3f>& circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0);
    

    You must pass the memory address of the objects img and circles instead of passing the objects themselves.

    You should do something like:

    HoughCircles(&img, &circles, CV_HOUGH_GRADIENT, 2, img.rows/4, 200, 100 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
I'm using Xcode 4.3 and I have followed this user's steps to create the
I am using Xcode 4.3 and i have a problem with playing sound... I
Currently I am using xCode 3.2.5 and I have already installed cocos2d template cocos2d
I am using xcode 4, Compiler version LLVM GCC 4.2. I have been trying
I am creating an iPad app using XCode 4 and Storyboards. I have a
How can I self-sign an iPhone application using Xcode? I have done the following:
I have an application in XCode using the sqlite/coredata database and that has already
I am using a timer in xcode i have managed to make it count

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.