documentation for cv.contourArea
表示,如果oriented
为true
,则返回值将为正值或负值,具体取决于轮廓的方向:
oriented
: Oriented area flag. If it istrue
, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking the sign of an area. By default, the parameter isfalse
, which means that the absolute value is returned.
但是,它没有说负值是什么意思-顺时针还是逆时针为负值?
最佳答案
回答问题的最简单方法是用两个简单的三角形轮廓(一个顺时针,一个逆时针)进行测试。
import numpy as np
import cv2
cw = np.array([[0,0],[4,0],[0,4]])
ccw = np.array([[0,0],[0,4],[4,0]])
print cv2.contourArea(cw, True)
print cv2.contourArea(ccw, True)
打印出来
8.0
-8.0
因此,正数表示顺时针,负数表示逆时针。
关于opencv - cv.contourArea(contour,True)何时返回负值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58157158/