需要一个整数(类型为元组)python opencv

时间:2019-11-27 17:57:40

标签: python opencv

我正在尝试通过鼠标点击多边形的颜色,并在寻找多边形的颜色或使其变色的过程中遇到了一个问题,该变量期望一个int但得到元组

def onMouse(event, x, y, flags, params):
if event == cv2.EVENT_LBUTTONDOWN:
    point = (x, y)
    subdiv = params

    if point[0] >= 20 and point[0] <= 420 and point[1] >= 20 and point[1] <= 420:
        nearest_pt_id = subdiv.findNearest(point)
        first_edge_id = subdiv.getVertex(nearest_pt_id[0])

        temp_edge = first_edge_id
        while 1:
            next_around_org_edge_id = subdiv.getEdge(temp_edge, subdiv.NEXT_AROUND_ORG) # IT SAYS THAT cv2.Subdiv2D DOESNT HAVE NEXT_AROUND_ORG
            if if_point_in_triangle(point, temp_edge, next_around_org_edge_id, subdiv):
                pt1 = subdiv.edgeOrg(temp_edge)
                pt2 = subdiv.edgeOrg(temp_edge)
                pt3 = subdiv.edgeOrg(next_around_org_edge_id)
                img_copy = img.clone()

                pts = []
                pts.append(pt1)
                pts.append(pt2)
                pts.append(pt3)
                cv2.fillConvexPoly(img_copy, pts ,(0, 0, 255))

                cv2.imshow("placeholder", img_copy)
                break
            else:
                temp_edge = next_around_org_edge_id
                if temp_edge == first_edge_id:
                    break

我在代码中标记了错误发生的位置。我希望获得一个带有形状的窗口,单击时可以使颜色着色,但是我被卡在了这里。 控制台错误:

回溯(最近通话最近一次):

onMouse中的文件“ C:/Users/Veneno/Desktop/RGRV_LV2.py”,第46行     next_around_org_edge_id = subdiv.getEdge(temp_edge,subdiv.NEXT_AROUND_ORG)

AttributeError:'cv2.Subdiv2D'对象没有属性'NEXT_AROUND_ORG'

0 个答案:

没有答案