我无法使用结构化森林训练的原始BSDS模型(https://github.com/pdollar/edges/blob/master/models/forest/modelBsds.mat)检测边缘。要将.mat
转换为.yml
,我将https://github.com/opencv/opencv_contrib/blob/master/modules/ximgproc/tutorials/scripts/modelConvert.m命令与modelConvert(model, "model.yml")
命令一起使用here。但是,当我使用转换后的模型运行边缘检测时,我得到:
当输入图像是:
也就是说,this model工作。任何人都知道为什么原来的.mat
模型不起作用?这是我的代码:
img = cv2.imread('./kermit.jpg')
edgedetector = cv2.ximgproc.createStructuredEdgeDetection('./model.yml')
src = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
edges = edgedetector.detectEdges(np.float32(src) / 255.0)
cv2.imshow("edges", edges)
任何想法都赞赏。