org.openpnp.vision.pipeline.stages.DrawCircles

张开发
2026/4/15 9:42:26 15 分钟阅读

分享文章

org.openpnp.vision.pipeline.stages.DrawCircles
文章目录org.openpnp.vision.pipeline.stages.DrawCircles功能参数例子产生测试图像效果ENDorg.openpnp.vision.pipeline.stages.DrawCircles功能从指定的前序 Stage 获取圆形列表ListResult.Circle并在当前工作图像上绘制这些圆形。每个圆形会绘制一个圆轮廓和圆心点。可以自定义圆的颜色、圆心颜色以及线条粗细。如果未指定颜色则使用索引颜色根据圆形在列表中的顺序自动分配及其互补色作为圆心颜色。该阶段直接修改当前工作图像不返回新的模型或图像返回 null。参数参数类型默认值说明circlesStageNameStringnull指定提供圆形列表的 Stage 名称如detect。该 Stage 的结果模型必须是ListResult.Circle。colorColornull圆形的颜色。若未指定则自动使用索引颜色根据列表顺序循环使用一组预定义颜色。centerColorColornull圆心点的颜色。若未指定则自动使用color的互补色。thicknessint1绘制圆形的线条粗细像素。圆心点固定为 2 像素粗细。例子产生测试图像# fn generate_circles.pyimportcv2importnumpy as np# 图像尺寸width, height800,600# 深灰色背景imgnp.full((height,width,3),(64,64,64),dtypenp.uint8)# 圆形参数(圆心x,圆心y,半径,颜色BGR)circles[(200,300,80,(0,0,255)),# 红色(500,200,60,(0,255,0)),# 绿色(650,450,100,(255,0,0)),# 蓝色]for(cx, cy, r, color)incircles:# 注意末尾的冒号cv2.circle(img,(cx, cy), r, color, -1)# 填充圆# 可选添加一些文字说明cv2.putText(img,Test Circles for DrawCircles,(50,50), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)cv2.imwrite(test_circles.png, img)print(测试图像已生成: test_circles.png)cv-pipelinestagescv-stageclassorg.openpnp.vision.pipeline.stages.ImageReadnamereadenabledtruefileD:\3rd\openpnp_prj\openpnp-official\openpnp-test-images\my_test\test_circles.pngcolor-spaceBgrhandle-as-capturedfalse/cv-stageclassorg.openpnp.vision.pipeline.stages.ConvertColornamegrayenabledtrueconversionBgr2Gray/cv-stageclassorg.openpnp.vision.pipeline.stages.BlurGaussiannameblurenabledtruekernel-size3property-nameBlurGaussian/cv-stageclassorg.openpnp.vision.pipeline.stages.DetectCircularSymmetrynamedetectenabledtruemin-diameter100max-diameter220max-distance500search-width0search-height0max-target-count3min-symmetry1.2corr-symmetry0.0outer-margin0.2inner-margin0.4sub-sampling4super-sampling2symmetry-scoreOverallVarianceVsRingVarianceSumproperty-namediagnosticstrueheat-mapfalse/cv-stageclassorg.openpnp.vision.pipeline.stages.ImageRecallnamerecallenabledtrueimage-stage-nameread/cv-stageclassorg.openpnp.vision.pipeline.stages.DrawCirclesnamedrawenabledtruecircles-stage-namedetectthickness3colorr0g255b0a255/center-colorr255g0b0a255//cv-stagecv-stageclassorg.openpnp.vision.pipeline.stages.ImageWritenamesaveenabledtruefileoutput_circles_correct.png//stages/cv-pipeline效果DetectCircularSymmetry对低对比度的检测不佳。END

更多文章