0

I am trying to use piotr dollar's model to detect edges in IOS as suggested here. https://docs.opencv.org/3.1.0/d0/da5/tutorial_ximgproc_prediction.html

String modelFilename = "./model.yml.gz";
Ptr<StructuredEdgeDetection> pDollar = createStructuredEdgeDetection(modelFilename);
pDollar->detectEdges(image, edges);

While the above code works in my machine. (Mac OS). I am unable to make it work on IOS. I am getting the following error.

  libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.2) 
../cv3.4/opencv-3.4.2/modules/ximgproc/src/structured_edge_detection.cpp:432: error: (-215:Assertion failed) 
modelFile.isOpened() in function 'StructuredEdgeDetectionImpl'

i have already looked at the following links.

https://stackoverflow.com/a/49753953/381786 https://github.com/opencv/opencv/issues/8106

Any pointers on how to do this.

cypher
  • 429
  • 1
  • 4
  • 16

1 Answers1

0

Instead of just giving the added resource path, one has to get the path via the swift's Bundle.main.path API.

let path = Bundle.main.path(forResource: "model.yml", ofType: "gz"); 

Using this api, one can get the path of the resource and use it to detect edges.

cypher
  • 429
  • 1
  • 4
  • 16