PseudoSquareROI.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:dataArtist 作者: radjkarl 项目源码 文件源码
def getMask(self, shape):

        p=self.state['pos']
        s=self.state['size']
        center=p + s / 2
        a=self.state['angle']
        # opencv convention:
        shape = (shape[1], shape[0])
        arr1 = np.zeros(shape, dtype=np.uint8)
        arr2 = np.zeros(shape, dtype=np.uint8)

        # draw rotated rectangle:
        vertices = np.int0(cv2.boxPoints((center, s, a)))
        cv2.drawContours(arr1, [vertices], 0, color=1, thickness=-1)
        # draw ellipse:
        cv2.ellipse(arr2, (int(center[0]), int(center[1])), (int(s[0] / 2 * self._ratioEllispeRectangle),
                     int(s[1] / 2 * self._ratioEllispeRectangle)), int(a),
                    startAngle=0, endAngle=360, color=1, thickness=-1)
        # bring both together:
        return np.logical_and(arr1, arr2).T
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号