Python使用OpenCV将Numpy数组映射到类中

2024-10-03 09:09:42 发布

您现在位置:Python中文网/ 问答频道 /正文

如何将Numpy数组映射到具有特定成员的类中

perimeterValues = cv2.arcLength(curveData, True)
vertices = cv2.approxPolyDP(curveData, 0.04 * perimeterValues, True)

Results: [[[[257, 396]], [[225, 397]], [[210, 431]], [[235, 450]], [[265, 435]]]]

它需要进入一个包含离散类成员的列表类,如下所示:

verticesList : list[Vertices] 

class Vertices():
  xLocation: int
  yLocation: int

在前面的尝试中,我将丢失类成员的名称xLocation、ylolocation等


Tags: numpytrue列表成员数组cv2resultsint