org.openpnp.vision.pipeline.stages.DrawContours
文章目录org.openpnp.vision.pipeline.stages.DrawContours功能参数例子生成测试图片cv-pipeline配置效果ENDorg.openpnp.vision.pipeline.stages.DrawContours功能从指定的前序 Stage 获取轮廓列表List并在当前工作图像上绘制这些轮廓.参数参数类型默认值说明contoursStageNameStringnull指定提供轮廓列表的 Stage 名称如findContours。该 Stage 的结果模型必须是ListMatOfPoint。colorColornull轮廓的颜色。若未指定则自动使用索引颜色根据列表顺序循环使用一组预定义颜色。通过子元素color r... g... b... a.../设置。thicknessint1绘制轮廓的线条粗细像素。indexint-1要绘制的轮廓索引从 0 开始。负值表示绘制所有轮廓。例子生成测试图片# fn generate_test_shapes.pyimportcv2importnumpy as np# 创建白色背景imgnp.ones((500,500,3),dtypenp.uint8)*255# 绘制黑色矩形cv2.rectangle(img,(50,50),(200,150),(0,0,0), -1)# 绘制黑色圆形cv2.circle(img,(350,300),60,(0,0,0), -1)cv2.imwrite(test_shapes.png, img)print(测试图像已生成: test_shapes.png)cv-pipeline配置cv-pipelinestagescv-stageclassorg.openpnp.vision.pipeline.stages.ImageReadnamereadenabledtruefileD:\3rd\openpnp_prj\openpnp-official\openpnp-test-images\my_test\test_shapes.pngcolor-spaceBgrhandle-as-capturedfalse/cv-stageclassorg.openpnp.vision.pipeline.stages.ConvertColornamegrayenabledtrueconversionBgr2Gray/cv-stageclassorg.openpnp.vision.pipeline.stages.Thresholdnamethreshenabledtruethreshold127autofalseinverttrue/cv-stageclassorg.openpnp.vision.pipeline.stages.FindContoursnamecontoursenabledtrueretrieval-modeExternalapproximation-methodSimple/cv-stageclassorg.openpnp.vision.pipeline.stages.ImageRecallnamerecallenabledtrueimage-stage-nameread/cv-stageclassorg.openpnp.vision.pipeline.stages.DrawContoursnamedrawenabledtruecontours-stage-namecontoursthickness2index-1colorr0g255b0a255//cv-stagecv-stageclassorg.openpnp.vision.pipeline.stages.ImageWritenamesaveenabledtruefileoutput_contours.png//stages/cv-pipeline效果END