org.openpnp.vision.pipeline.stages.DrawKeyPoints
文章目录
- org.openpnp.vision.pipeline.stages.DrawKeyPoints
- 功能
- 参数
- 例子
- 生成测试图片
- cv-pipeline config
- 效果
- END
org.openpnp.vision.pipeline.stages.DrawKeyPoints
功能
在图像上绘制关键点(KeyPoints),以便于可视化调试或验证特征检测结果
参数
| 参数 | 类型 | 说明 |
|---|---|---|
keyPointsStageName | String | 指定流水线中提供关键点的那个阶段的名称。如果为空或找不到对应结果,则跳过绘制。 |
color | java.awt.Color | 可选,绘制关键点所用的颜色。如果不设置,使用 OpenCV 默认颜色(通常是随机颜色或固定颜色)。 |
例子
生成测试图片
importcv2importnumpy as np# 创建白色背景 (500x500)width, height=500,500img=np.ones((height, width,3),dtype=np.uint8)*255# 定义圆心坐标和半径circles=[(100,100,20),(200,150,25),(350,300,30),(400,400,18),(80,400,22),(300,80,28)]# 绘制实心圆 (模拟斑点)forx, y, rincircles: cv2.circle(img,(x, y), r,(0,0,0), -1)# 黑色填充# 添加少许噪声,使斑点更自然noise=np.random.randint(0,30,(height, width,3),dtype=np.uint8)img=cv2.addWeighted(img,0.95, noise,0.05,0)# 保存图片cv2.imwrite("blob_test.png", img)print("测试图片已生成: blob_test.png")cv-pipeline config
<cv-pipeline><stages><cv-stageclass="org.openpnp.vision.pipeline.stages.ImageRead"name="read"enabled="true"file="D:\3rd\openpnp_prj\openpnp-official\openpnp-test-images\my_test\blob_test.png"color-space="Bgr"handle-as-captured="false"/><cv-stageclass="org.openpnp.vision.pipeline.stages.ConvertColor"name="gray"enabled="true"conversion="Bgr2Gray"/><cv-stageclass="org.openpnp.vision.pipeline.stages.SimpleBlobDetector"name="blobs"enabled="true"threshold-step="10.0"threshold-min="50.0"threshold-max="220.0"repeatability="2"dist-between-blobs="10.0"color="true"color-value="0.0"area="true"area-min="100.0"area-max="5000.0"circularity="false"circularity-min="0.8"circularity-max="-1.0"inertia="true"inertia-ratio-min="0.1"inertia-ratio-max="-1.0"convexity="true"convexity-min="0.95"convexity-max="-1.0"property-name="SimpleBlobDetector"/><cv-stageclass="org.openpnp.vision.pipeline.stages.ImageRecall"name="recall"enabled="true"image-stage-name="read"/><cv-stageclass="org.openpnp.vision.pipeline.stages.DrawKeyPoints"name="draw"enabled="true"key-points-stage-name="blobs"><colorr="0"g="255"b="0"a="255"/></cv-stage><cv-stageclass="org.openpnp.vision.pipeline.stages.ImageWrite"name="save"enabled="true"file="output_blobs_with_keypoints.png"/></stages></cv-pipeline>