将轨迹栏添加到轮廓图

时间:2017-12-18 23:37:13

标签: python-3.x opencv

我正在尝试将一个轨迹栏添加到脚本中,该脚本可以查找图像的轮廓,以便仅显示周长比轨迹栏值更长的轮廓。 无论我做什么,轮廓都不会改变。

这里是我正在使用的代码:

testdf <- within(testdf, Date <- sprintf("%d-%02d-01", Year, Month))

ggplot(testdf , aes(measurement, as.Date(Date, "%Y-%m-%d"))) +
  geom_line(aes(group = Month)) +
  geom_point(aes(color = Year)) +
  scale_y_date()

1 个答案:

答案 0 :(得分:1)

while True:循环中,您正在绘制相同的图像,您需要在此副本上保留原始图像和项目轮廓的单独副本,保持原始图像不变。可以这样做:

while True:
 # Get position in trackbar
 TrackbarPos = cv2.getTrackbarPos(TrackbarName, WindowName)
 # draw contours
 img_copy = Image.copy()
 cntsfiltered = [cnt for cnt in cnts if cv2.arcLength(cnt, True) > TrackbarPos]
 cv2.drawContours(img_copy, cntsfiltered, -1, (0, 255, 0), 1)

 # Show in window
 cv2.imshow(WindowName, img_copy)

 # If you press "ESC", it will return value
 ch = cv2.waitKey(5)
 if ch == 27:
     break

cv2.destroyAllWindows()
return img_copy