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

  • SEARCH
  • Home
  • 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 9163597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:29:01+00:00 2026-06-17T14:29:01+00:00

I have been trying for hours to run an xcode project with openCV. I

  • 0

I have been trying for hours to run an xcode project with openCV. I have built the source, imported it into the project and included
#ifdef __cplusplus #import opencv2/opencv.hpp>
#endif
in the .pch file.

I followed the instructions from http://docs.opencv.org/trunk/doc/tutorials/introduction/ios_install/ios_install.html

Still I am getting many Apple Mach-O linker errors when I compile.

Undefined symbols for architecture i386:
 "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:

Please help me I am really lost..

UPDATE:

Errors all fixed and now I am trying to detect circles..

Mat src, src_gray;

cvtColor( image, src_gray, CV_BGR2GRAY );

vector<Vec3f> circles;

/// Apply the Hough Transform to find the circles
HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, image.rows/8, 200, 100, 0, 0 );


/// Draw the circles detected
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]);
    // circle center
    circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
    // circle outline
    circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );


}

I am using the code above, however no circles are being drawn on the image.. is there something obvious that I am doing wrong?

  • 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-06-17T14:29:02+00:00Added an answer on June 17, 2026 at 2:29 pm

    Try the solution in my answer to this question…

    How to resolve iOS Link errors with OpenCV

    Also on github I have a couple of simple working samples – with recently built openCV framework.

    NB – OpenCVSquares is simpler than OpenCVSquaresSL. The latter was adapted for Snow Leopard backwards compatibility – it contains two builds of the openCV framework and 3 targets, so you are better off using the simpler OpenCVSquares if it will run on your system.

    To adapt OpenCVSquares to detect circles, I suggest that you start with the Hough Circles c++ sample from the openCV distro, and use it to adapt/replace CVSquares.cpp and CVSquares.h with, say CVCircles.cpp and CVCicles.h

    The principles are exactly the same:

    • remove UI code from the c++, the UI is provided on the obj-C side
    • transform the main() function into a static member function for the class declared in the header file. This should mirror in form an Objective-C message to the wrapper (which translates the obj-c method to a c++ function call).

    From the objective-C side, you are passing a UIImage to the wrapper object, which:

    • converts the UIImage to a cv::Mat image
    • pass the Mat to a c++ class for processing
    • converts the result from Mat back to UIImage
    • returns the processed UIImage back to the objective-C calling object

    update

    The adapted houghcircles.cpp should look something like this at it’s most basic (I’ve replaced the CVSquares class with a CVCircles class):

    cv::Mat CVCircles::detectedCirclesInImage (cv::Mat img)
    {   
        //expects a grayscale image on input
        //returns a colour image on ouput
        Mat cimg;
        medianBlur(img, img, 5);
        cvtColor(img, cimg, CV_GRAY2RGB);
        vector<Vec3f> circles;
        HoughCircles(img, circles, CV_HOUGH_GRADIENT, 1, 10,
                     100, 30, 1, 60 // change the last two parameters
                     // (min_radius & max_radius) to detect larger circles
                     );
        for( size_t i = 0; i < circles.size(); i++ )
            {
            Vec3i c = circles[i];
            circle( cimg, Point(c[0], c[1]), c[2], Scalar(255,0,0), 3, CV_AA);
            circle( cimg, Point(c[0], c[1]), 2, Scalar(0,255,0), 3, CV_AA);
            }
        return cimg;
        }
    

    Note that the input parameters are reduced to one – the input image – for simplicity. Shortly I will post a sample on github which will include some parameters tied to slider controls in the iOS UI, but you should get this version working first.

    As the function signature has changed you should follow it up the chain…

    Alter the houghcircles.h class definition:

        static cv::Mat detectedCirclesInImage (const cv::Mat image);
    

    Modify the CVWrapper class to accept a similarly-structured method which calls detectedCirclesInImage

        + (UIImage*) detectedCirclesInImage:(UIImage*) image
        {
            UIImage* result = nil;
            cv::Mat matImage = [image CVGrayscaleMat];
            matImage = CVCircles::detectedCirclesInImage (matImage);
            result = [UIImage imageWithCVMat:matImage];
            return result;
        }
    

    Note that we are converting the input UIImage to grayscale, as the houghcircles function expects a grayscale image on input. Take care to pull the latest version of my github project, I found an error in the CVGrayscaleMat category which is now fixed . Output image is colour (colour applied to grayscale input image to pick out found circles).

    If you want your input and output images in colour, you just need to ensure that you make a grayscale conversion of your input image for sending to Houghcircles() – eg cvtColor(input_image, gray_image, CV_RGB2GRAY); and apply your found circles to the colour input image (which becomes your return image).

    Finally in your CVViewController, change your messages to CVWrapper to conform to this new signature:

        UIImage* image = [CVWrapper detectedCirclesInImage:self.image];
    

    If you follow all of these details your project will produce circle-detected results.

    update 2
    OpenCVCircles now on Github
    With sliders to adjust HoughCircles() parameters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying for hours to find a way to solve the issue,
This is crazy, I have been trying for hours to get this to work.
I have been trying this for hours without success. http://replicaisland.googlecode.com/svn/trunk/ I have added the
I have been fruitlessly trying for several hours to make a function that filter
okay i have been trying to understand this for hours i am learning VB
So I have been trying and battling with this for a few hours now.
I've been trying for hours and have read what this site and the internet
I have been scratching my head for hours trying to figure out why this
So I have been working and trying for a couple of hours. I am
I'm a rails beginner and have been several hours now trying to figure out

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.