Loading the SED model in xcode
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 !
model.yml.gz
file "as is"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
"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]
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