【问题标题】:How do I return the angle of orientation from getOrientation() and Open CV code?如何从 getOrientation() 和 Open CV 代码返回方向角度?
【发布时间】: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


【解决方案1】:

你可以根据自己的需要使用这些opencv函数

fitEllipse()fitEllipseAMS()fitEllipseDirect()

基本上,该函数需要一个点数组(您的轮廓)并返回值。这些值之一是轮廓的orientation

https://docs.opencv.org/4.5.2/d3/dc0/group__imgproc__shape.html#gaf259efaad93098103d6c27b9e4900ffa

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    • 2011-04-30
    • 2019-01-29
    相关资源
    最近更新 更多