当前位置: 首页>>代码示例>>Python>>正文


Python Geometry.getPointsDistance方法代码示例

本文整理汇总了Python中Geometry.getPointsDistance方法的典型用法代码示例。如果您正苦于以下问题:Python Geometry.getPointsDistance方法的具体用法?Python Geometry.getPointsDistance怎么用?Python Geometry.getPointsDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geometry的用法示例。


在下文中一共展示了Geometry.getPointsDistance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detectAllVertices

# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import getPointsDistance [as 别名]
    def detectAllVertices(self, testImg):
        # Detecting vertices on the newly constructed board
        self.gray = cv2.cvtColor(testImg, cv2.COLOR_BGR2GRAY)

        tempVertices = cv2.goodFeaturesToTrack(self.gray, int(self.FINAL_VERTICES_COUNT), 0.01, 10)
        tempVertices = np.int0(tempVertices)

        newVertices = []

        for i in tempVertices:
            x, y = i.ravel()
            newVertices.append((x, y))

        # Matrix to store coordinates of vertices on the board
        self.ALL_VERTICES = [[(0, 0) for x in range(self.FACTOR + 2)] for x in range(self.FACTOR + 2)]

        # Filling the matrix
        self.ALL_VERTICES[0][0] = (self.CORNERS[1])

        for i in range(0, self.FACTOR):
            for j in range(0, self.FACTOR):
                predicted_x = self.ALL_VERTICES[i][j][0] + int(
                    (self.OUTER_VERTICES[2][self.FACTOR - i][0] - self.OUTER_VERTICES[0][i][0]) / 8)
                predicted_y = self.ALL_VERTICES[i][j][1] + int(
                    (self.OUTER_VERTICES[3][self.FACTOR - i][1] - self.OUTER_VERTICES[1][i][1]) / 8)

                minn_dist = self.INT_MAX

                for point in newVertices:
                    this_dist = Geometry.getPointsDistance(point, (predicted_x, self.ALL_VERTICES[i][j][1]))
                    if this_dist < minn_dist:
                        self.ALL_VERTICES[i][j + 1] = point
                        minn_dist = this_dist

                minn_dist = self.INT_MAX

                for point in newVertices:
                    this_dist = Geometry.getPointsDistance(point, (self.ALL_VERTICES[i][j][0], predicted_y))
                    if this_dist < minn_dist:
                        self.ALL_VERTICES[i + 1][j] = point;
                        minn_dist = this_dist

        self.ALL_VERTICES[self.FACTOR][self.FACTOR] = (self.CORNERS[3])
开发者ID:pakhandi,项目名称:ChessBot,代码行数:45,代码来源:ChessBoard.py


注:本文中的Geometry.getPointsDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。