資源簡介
openmv目標檢測代碼
代碼片段和文件信息
class?GeometryFeature:
????def?__init__(self?img):
????????self.img?=?img
????????
????@staticmethod
????def?trans_line_format(line):
????????‘‘‘
????????將原來由兩點坐標確定的直線,轉換為?y?=?ax?+?b?的格式
????????‘‘‘
????????x1?=?line.x1()
????????y1?=?line.y1()
????????x2?=?line.x2()
????????y2?=?line.y2()
????????if?x1?==?x2:
????????????#?避免完全垂直,x坐標相等的情況
????????????x1?+=?0.1
????????#?計算斜率?a
????????a?=?(y2?-?y1)?/?(x2?-?x1)
????????#?計算常數項?b
????????#?y?=?a*x?+?b?->?b?=?y?-?a*x
????????b?=?y1?-?a?*?x1
????????return?ab
????@staticmethod????
????def?calculate_angle(line1?line2):
????????‘‘‘
????????利用四邊形的角公式,?計算出直線夾角
????????‘‘‘
????????angle??=?(180?-?abs(line1.theta()?-?line2.theta()))
????????if?angle?>?90:
????????????angle?=?180?-?angle
????????return?angle
????@staticmethod
????def?find_ve
- 上一篇:python打印漢諾塔
- 下一篇:簡單窗口(Python+pyQT)入門級
評論
共有 條評論