example.py 文件源码

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

项目:test-automation 作者: openstax 项目源码 文件源码
def Harris_Corner(self):
        self.threshold = 0.999999999999
        temp_i = self.image_i.copy()
        temp1_i = self.image_i.copy()
        gray_i = cv2.cvtColor(temp_i, cv2.COLOR_BGR2GRAY)
        gray_i = numpy.float32(gray_i)
        dst_i = cv2.cornerHarris(gray_i,2,3,0.025)
        dst_i = cv2.dilate(dst_i,None)
        # Threshold for an optimal value, it may vary depending on the image.
        temp_i[dst_i<0.01*dst_i.max()]=[0,0,0]
        temp_i[dst_i>=0.01*dst_i.max()]=[255,255,255]
        temp1_i[dst_i>0.01*dst_i.max()]=[0,0,255]
        hist_i = cv2.calcHist([temp_i], [0], None, [256], [0, 256])
        temp_j = self.image_j.copy()
        temp1_j = self.image_j.copy()
        gray_j = cv2.cvtColor(temp_j, cv2.COLOR_BGR2GRAY)
        gray_j = numpy.float32(gray_j)
        dst_j = cv2.cornerHarris(gray_j,2,3,0.025)
        dst_j = cv2.dilate(dst_j,None)
        # Threshold for an optimal value, it may vary depending on the image.
        temp_j[dst_j<0.01*dst_j.max()]=[0,0,0]
        temp_j[dst_j>=0.01*dst_j.max()]=[255,255,255]
        temp1_j[dst_j>0.01*dst_j.max()]=[0,0,255]
        hist_j = cv2.calcHist([temp_j], [0], None, [256], [0, 256])

        self.measure = cv2.compareHist(hist_i, hist_j, cv.CV_COMP_CORREL)
        self.assertGreater(self.measure, self.threshold)
        print self.measure
        cv2.imshow('Input X',temp1_i)
        cv2.waitKey(0)
        cv2.imshow('Input Y',temp1_j)
        cv2.waitKey(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号