Cvread Cascade on iOS failed

asked 2016-09-13 21:28:15 -0500

Max_Ma gravatar image

Platform: iOS, OpenCV 3.1

I am trying to implement object recognition on iOS devices using OpenCV but I have met some difficulties and there is lack of documents or examples of OpenCV for iOS so I need help.

I installed opencv using iOS pod packages manager, just run the command "pod install OpenCV"

I am using machine learning methods, train a Harr feature classifier. However, it failed because the cvRead cannot recognize the cascade file, and returned

"libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/kyle/code/opensource/opencv/modules/core/src/persistence.cpp:4976: error: (-2) The node does not represent a user object (unknown type?) in function cvRead"

Even the origin cascade file 'haarcascade_eye.xml' from the github opencv source cannot be read successfully.

And the code is simple as:

NSString *path = [[NSBundle mainBundle]  pathForResource:@"haarcascade_eye"  ofType:@"xml"];

if(!path)
{
    NSLog(@"no cascade file found");
}
else
{
    _cascade = (CvHaarClassifierCascade*)cvLoad([path cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL, NULL);
}
edit retag flag offensive close merge delete