Ask Your Question
0

Loading the SED model in xcode

asked 2018-03-05 04:30:41 -0500

fletenchard gravatar image

Hi everybody,

I installed the package opencv2-contrib through cocoa pods in xcode, in order to use the structured edge detection algorithm rather than the canny edge detection.

A corresponding trained model is available at https://github.com/opencv/opencv_extr... and I have been trying to use it inside my Xcode project, but I can't get rid of this error : "OpenCV Error: Assertion failed (modelFile.isOpened()) in StructuredEdgeDetectionImpl, file /Users/Benjamin/Desktop/opencv/opencv_contrib/modules/ximgproc/src/structured_edge_detection.cpp, line 354"...

Here is the code I try to load the model with :

const cv::String modelFile="./model.yml";
cv::resize(image, rimage, dim, CV_INTER_AREA);
cv::Mat rimageFloat;
rimage.convertTo(rimageFloat, cv::DataType<float>::type, 1 / 255.0);
cv::Mat edges(rimageFloat.size(),rimageFloat.type());
cv::Ptr<cv::ximgproc::StructuredEdgeDetection> pDollar = cv::ximgproc::createStructuredEdgeDetection(modelFile);
pDollar->detectEdges(rimageFloat, edges);

I also tried to use the compressed version .gz but this time I end up with another error : "libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/Benjamin/Desktop/opencv/opencv/modules/core/src/persistence.cpp:4208: error: (-213) There is no compressed file storage support in this configuration in function cvOpenFileStorage"

I'm still new and it could be something with the frameworks installation (actually I don't even know how to access the specified files that seem to be on Benjamin's desktop - who is this ?).

If anyone here already came to a solution concerning the loading of a model for the SED detector, could he please give me a sign ? Thanks !

edit retag flag offensive close merge delete

Comments

  • try to use the model.yml.gz file "as is"
  • relative paths are tricky. put the file, where your application starts , or use an absolute path
  • you ide (i don't know it) might come in the way. rather start your program from the cmdline
berak gravatar imageberak ( 2018-03-05 04:38:12 -0500 )edit

Thank you for your answer, but using an absolute path and the .gz file unfortunately doesn't help (I used const cv::String modelFile("/Users/myself/Desktop/iOS/rectangle/rectangle/model.yml.gz");) I am working with Xcode and objective-c++ files, the function cvOpenFileStorage doesn't seem to handle .gz files

fletenchard gravatar imagefletenchard ( 2018-03-05 05:11:17 -0500 )edit
1

"cvOpenFileStorage doesn't seem to handle .gz files" -- bullshit.

maybe your model is broken ? (download problem) throw it at a text editor or use head model.yml.gz

really, occams razor...

try again with the download button from [this page]

berak gravatar imageberak ( 2018-03-05 05:34:10 -0500 )edit

It turned out that I simply didn't know how to properly load and access a file in Xcode...
Just used
NSString *assetPath = [[NSBundle mainBundle] pathForResource:@"model" ofType:@"yml"]; modelFile = [assetPath UTF8String];
As previously said, I get an error when trying to load the gz file
Thanks berak for the answers

fletenchard gravatar imagefletenchard ( 2018-03-06 03:37:16 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-22 08:13:05 -0500

fletenchard gravatar image

I was using outdated opencv contribution library loaded from an unofficial cocoa pod, up to date opencv library does indeed handle compressed files - my bad

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-03-05 04:30:41 -0500

Seen: 98 times

Last updated: Mar 05 '18