鱼C论坛

 找回密码
 立即注册
查看: 1397|回复: 1

opencv绘制轮廓的疑问?

[复制链接]
发表于 2021-1-15 11:42:16 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. def contour():
  2.     img_misaka_rgb = cv2.imread(r'D:\image\bilibili2.jpeg', cv2.IMREAD_COLOR)
  3.     img_misaka_gray = cv2.cvtColor(img_misaka_rgb, cv2.COLOR_BGR2GRAY)
  4.     ret, thresh = cv2.threshold(img_misaka_gray, 200, 255, 0)
  5.     #cv2.imshow('thresh', thresh)
  6.     image, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
  7.     #cv2.imshow('thresh2', thresh)
  8.     #cv2.imshow('image', image)
  9.     misaka_contour = cv2.drawContours(img_misaka_rgb, contours, -1, (0, 255, 0), 3)
  10.     image2, contours2, hierarchy2 = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  11.     misaka_contour2 = cv2.drawContours(img_misaka_rgb, contours2[335], -1, (0, 255, 0), 3)
复制代码


misaka_contour 和misaka_contour2  show出来的轮廓居然是一样的,很奇怪但是找了很久没有找到原因。
百度有看到cv2.findContours方法会改变原图但show出来后也没发现什么变化。

求解答,感谢!
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-1-15 11:46:50 | 显示全部楼层
刚刚试了一下cv2.drawContours居然会改变原图。。。
但是findContours是否会修改原图还未确认。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-26 15:48

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表