Ask Your Question
1

opencv IOS - MacTypes.h, ambiguous references

asked 2013-07-30 08:10:04 -0500

Opelfahrer gravatar image

My previous question referred to linker errors - although the opencv2.framework is included, it does not find functions like the FeatureDetector::detect for example... well, it seems that this has to do with the order of includes... so rearranging the order of includes I end up with:

Reference to 'Ptr' ambiguous
Reference to 'Point' ambiguous
Reference to 'Rect' ambiguous

I don't get how I can come around this issue... someone in another forum suggested to #define the Ptr, Point and Rect, then include the system headers and then #undef them again... This resulted in exactly the same linker problems that I already had before...

Undefined symbols for architecture armv7:
"cv::FeatureDetector::detect(cv::Mat const&, std::vector<cv::KeyPoint, 
std::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from:
   detect(char const*, cv::Mat&, float, float) in 
libDetector.a(ObjectDetector.o)

Can someone tell me what is the real and correct way to fuse opencv with ios?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-11-16 14:54:58 -0500

krm104 gravatar image

I know this is an old question, but it was at the top of the searches when I encountered the same issue, so I thought I would attempt to clarify the problem and solution for others that may hit this in a search result:

The problem encountered is a conflict between similar type names declared in OpenCV and iOS, for example - Ptr, Size, Rect, etc.

In order to rectify these conflicts, make sure that the OpenCV imports are declared before any iOS imports, and make sure that there is not a using namespace cv declared before the iOS imports. If this error occurs, the most likely culprit is that the statement "using namespace cv" is declared before the iOS imports, which causes the ambiguous reference in the compiler.

edit flag offensive delete link more
0

answered 2013-12-16 04:55:31 -0500

amourreux gravatar image

you have to use namespace like this;

for example You will use Point;

define in cv namespace

namespace cv{
    Point maxLoc;
}

And use it like this;

minMaxLoc(histForRed, 0, 0, 0, &maxLoc);

NSLog(@"R x: %d", maxLoc.x);
NSLog(@"R y: %d", maxLoc.y);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-07-30 08:10:04 -0500

Seen: 3,036 times

Last updated: Dec 16 '13