问题描述
我正在尝试在javascript中绘制图像的轮廓,轮廓是点数组,不是从cv.findContours()
获得的,这是我的代码:
function drawImageOncanvas(url,contours) {
var img = new Image();
img.onload = function () {
let src = cv.imread(img);
if (contours !== undefined && contours !== null) {
let matVec = new cv.MatVector();
contours.forEach((contour) => {
const matContour = cv.matFromArray(
contour.length,2,cv.CV_8UC1,[].concat(...contour)
);
matVec.push_back(matContour);
});
for (let i = 0; i < matVec.size(); ++i) {
let color = new cv.Scalar(0,100,0);
cv.drawContours(src,matVec,i,color,1);
}
}
cv.imshow('board',src);
src.delete();
};
img.src = url;
}
为了能够将轮廓传递到cv.drawContours()
,首先我使用cv.matFromArray()
从matContour
(点阵列)创建contour
,然后推动每个matContour
在matVec
中(即MatVector
的实例),最后将matVec
传递给cv.drawContours()
;
但是我在Uncaught 6795152
上得到了cv.drawContours
。
有什么想法吗?
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)