【发布时间】:2022-01-10 02:09:44
【问题描述】:
我正在尝试查找图像中对象的方向角度。在图像输出中,图像包含轴和旋转度数,我想要那个度数的位置,这样我就可以将该数据写入.csv。换句话说,我需要输出角度的值而不仅仅是图像上的注释。我附上了我的输出图片,下面是与方向有关的数据部分。
我正在使用 OpenCV 包。
for i, c in enumerate(contours):
# Calculate the area of each contour
area = cv.contourArea(c)
# Ignore contours that are too small or too large
if area < 3700 or 100000 < area:
continue
# Draw each contour only for visualisation purposes
cv.drawContours(img, contours, i, (0, 0, 255), 2)
# Find the orientation of each shape
getOrientation(c, img)
示例输出图像:
【问题讨论】:
-
把角度还原成什么?
-
getOrientation()来自什么软件?
-
我刚刚做了一些改动
-
我不明白您的问题...根据示例图像,您可以使用Fitting a Line 示例(对于每个轮廓),例如
vx, vy, cx, cy = cv2.fitLine(c, cv2.DIST_L2, 0, 0.01, 0.01)。直线角度等于:(180/np.pi)*math.atan2(vy, vx)。
标签: python opencv orientation