opencv如何在轮廓中按需求画线?

新手上路,请多包涵
import cv2
import numpy as np



img = cv2.imread(r'dabaotest3\cc.jpg') 

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)  

ret, binary = cv2.threshold(gray,127,255,cv2.THRESH_BINARY)  

contours, hierarchy = cv2.findContours(binary,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)  

cv2.drawContours(img,contours,-1,(0,0,255),3)  

cv2.imshow("img", img)

cv2.waitKey(0)

比如这个是mask
从这个轮廓最左端开始画线,直至画到最右端

怎么在 固定的间隔

提取出 x值相隔 10 的 所有绿色点坐标

比如轮廓的最左端,对应的上下绿色点坐标是什么,将这上下对应的两个坐标点加入到list中,
然后下一条线的比右边x+10,也就是间隔10,对应的上下绿色点坐标是什么,加入到list中,
依次类推,画到最右端,
最右端与倒数第二条的间隔不用管是否是10,最右端都是要有线当结尾.
最后将这些list中的坐标,一一对应分别连线.
示意图
我是用cv2.findContours 获取到了contours,但是这个我也不知道如何去处理才能拿来用.
或者有没有别的更好的方法
感谢回答

contours: (array([[[335, 115]],

       [[333, 117]],

       [[330, 117]],

       [[329, 118]],

       [[326, 118]],

       [[324, 120]],

       [[323, 120]],

       [[321, 118]],

       [[302, 118]],

       [[300, 120]],

       [[296, 120]],

       [[295, 121]],

       [[293, 121]],

       [[291, 123]],

       [[264, 123]],

       [[263, 124]],

       [[260, 124]],

       [[258, 126]],

       [[256, 126]],

       [[253, 129]],

       [[252, 129]],

       [[248, 133]],

       [[248, 134]],

       [[247, 135]],

       [[247, 137]],

       [[246, 138]],

       [[244, 138]],

       [[243, 139]],

       [[240, 139]],

       [[238, 141]],

       [[235, 141]],

       [[234, 142]],

       [[234, 143]],

       [[233, 144]],

       [[232, 144]],

       [[229, 147]],

       [[229, 149]],

       [[228, 150]],

       [[228, 153]],

       [[230, 155]],

       [[230, 156]],

       [[231, 157]],

       [[231, 159]],

       [[234, 162]],

       [[234, 171]],

       [[239, 176]],

       [[241, 176]],

       [[244, 179]],

       [[250, 179]],

       [[251, 180]],

       [[252, 180]],

       [[255, 183]],

       [[255, 184]],

       [[254, 185]],

       [[254, 187]],

       [[252, 189]],

       [[250, 189]],

       [[249, 190]],

       [[249, 191]],

       [[248, 192]],

       [[243, 192]],

       [[242, 193]],

       [[242, 195]],

       [[241, 196]],

       [[242, 197]],

       [[242, 198]],

       [[241, 199]],

       [[245, 203]],

       [[257, 203]],

       [[257, 202]],

       [[258, 201]],

       [[261, 201]],

       [[262, 200]],

       [[265, 200]],

       [[267, 198]],

       [[268, 198]],

       [[269, 197]],

       [[274, 197]],

       [[276, 195]],

       [[281, 195]],

       [[286, 190]],

       [[286, 189]],

       [[287, 188]],

       [[291, 188]],

       [[293, 186]],

       [[302, 186]],

       [[303, 187]],

       [[303, 188]],

       [[305, 188]],

       [[306, 189]],

       [[309, 189]],

       [[311, 191]],

       [[339, 191]],

       [[341, 189]],

       [[345, 189]],

       [[346, 188]],

       [[348, 188]],

       [[350, 186]],

       [[351, 186]],

       [[355, 182]],

       [[356, 182]],

       [[357, 183]],

       [[372, 183]],

       [[373, 182]],

       [[378, 182]],

       [[380, 180]],

       [[381, 180]],

       [[382, 179]],

       [[384, 179]],

       [[393, 170]],

       [[396, 170]],

       [[398, 168]],

       [[402, 168]],

       [[403, 167]],

       [[405, 167]],

       [[407, 165]],

       [[408, 165]],

       [[409, 164]],

       [[410, 164]],

       [[410, 163]],

       [[411, 162]],

       [[412, 162]],

       [[413, 161]],

       [[413, 160]],

       [[414, 159]],

       [[414, 156]],

       [[415, 155]],

       [[415, 154]],

       [[414, 153]],

       [[414, 151]],

       [[415, 150]],

       [[415, 148]],


       [[358, 117]],

       [[357, 118]],

       [[356, 118]],

       [[355, 117]],

       [[350, 117]],

       [[348, 115]]], dtype=int32),)
回复
阅读 354
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏