getPMatrix.py 文件源码

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

项目:AR-BXT-AR4Python 作者: GeekLiB 项目源码 文件源码
def debugMatches():
    # Debug module.
    # from matplotlib import pyplot as plt

    markImage = cv2.imread('./clock.png')
    sceneImage = cv2.imread('./clock_in_scene.png')

    # Init PM.
    pm = GetPMatrix(markImage)

    # Get kp1, kp2, dst, goodMatches, [draw_params].
    dst = pm.getMatches(sceneImage)
    if dst is None:
        exit()

    # Draw circles and lines.
    img3 = pm.drawMatches(markImage, sceneImage)

    # # Get ret, mtx, dist, rvecs, tvecs
    tmp = None
    for i in range(30):
        tmp = pm.getP(dst)
        if tmp is None:
            exit()
        print i
    mtx, dist, rvec, tvec = tmp

    # Draw Box
    h,w = markImage.shape[:2]
    img3[:,w:] = pm.drawBox(img3[:,w:])

    h2,w2 = sceneImage.shape[:2]
    glP = pm.getGLP(w2, h2)
    glM = pm.getGLM()

    print 'mtx -------------'
    print mtx
    print 'dist ------------'
    print dist
    print 'rvec -----------'
    print rvec
    print 'tvec -----------'
    print tvec
    print 'glP ------------'
    print glP
    print 'glM ------------'
    print glM

    img3 = cv2.cvtColor(img3, cv2.COLOR_BGR2RGB)
    plt.figure('Matches test.'), plt.imshow(img3)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号