Structured Edge Detection

限于喜欢 提交于 2019-12-20 07:41:15

问题


I'm trying to implement SED from OpenCV to android but I'm running into an error. So this is the code I'm using and it requires a model file (trained model to detect edges) which is located in the asset folder :

    private Bitmap StructuredDetectEdges (Bitmap bitmap){
    Mat rgba = new Mat();
    Utils.bitmapToMat(bitmap,rgba);
    Mat edges = new Mat(rgba.size(), CvType.CV_8UC1);
    Imgproc.cvtColor(rgba,edges,Imgproc.COLOR_RGB2GRAY,4);
    StructuredEdgeDetection pDollar = createStructuredEdgeDetection("file:///android_asset/SEDmodel.yml");
    pDollar.detectEdges(edges,edges);
    Bitmap resultBitmap = Bitmap.createBitmap(edges.cols(), edges.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(edges, resultBitmap);
    return resultBitmap;

}

and the error that I get is :

Error: Assertion failed (modelFile.isOpened()) in cv::ximgproc::StructuredEdgeDetectionImpl::StructuredEdgeDetectionImpl(const cv::String&, cv::Ptr<const cv::ximgproc::RFFeatureGetter>), file /Users/Chao/opencv_contrib/modules/ximgproc/src/structured_edge_detection.cpp, line 432

any help is much appreciated


回答1:


I solved this problem by making a copy of the model from the asset folder to the phone storage and reading it from there.



来源:https://stackoverflow.com/questions/49734695/structured-edge-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!