Opencv.js如何绘制轮廓子集? [英] Opencv.js How to draw a subset of contours?
本文介绍了Opencv.js如何绘制轮廓子集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Opencv.js,我已经获得了图像中的轮廓.
Using Opencv.js I have acquired the contours in an image.
使用一些选择功能,我收集了这些轮廓的子集.
using some selection function I have collected a subset of these contours.
说它们在轮廓列表中:
var suitableContours = [];
我需要知道使用opencv绘制这些轮廓.
I need to know draw these contours using opencv.
如果这是python,我可以做到
If this were python I could do
cv.drawContours(img, [suitableContours[cnt]], 0, [255, 0, 0, 255], 2);
假设要绘制轮廓,我无权访问原始图像,蒙版或原始轮廓列表,而无法访问选定的轮廓.
Assume by the point I want to draw the contours I don't have access to the original image nor the mask nor the original contour list, only the selected contours.
如何绘制这些轮廓?
上面的代码导致: BindingError:无法将"[object Object],[object Object]"作为MatVector传递
推荐答案
来自 https://docs.opencv.org/3.4/d5/daa/tutorial_js_contours_begin.html
尝试这样的事情:
let color = new cv.Scalar(255,0,0,255);
for (let i = 0; i < suitableContours.size(); ++i) {
cv.drawContours(src, suitableContours, i, color, 1, cv.LINE_8, hierarchy, 100);
}
cv.imshow('canvasOutput', src);
这篇关于Opencv.js如何绘制轮廓子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文