OpenCV 基础使用之特征点匹配【11】

464 阅读2分钟

一起养成写作习惯!这是我参与「掘金日新计划 · 4 月更文挑战」的第11天,点击查看活动详情

  • 🎉 声明: 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
  • 1-0

    本博文接上一篇博文,继续进行部分 opencv Python 示例代码运行 效果测试

    • 本博文的测试是直接拉取 opencv-master4.5.1,然后在opencv/samples/python/tutorial_code/ 目录下对不同模块 py 文件进行测试

    0-9


    local features matching 【局部特征匹配】


    运行该代码:

    
    cd opencv/samples/python/tutorial_code/features2D/akaze_matching
    
    cp ../../../../data/graf1.png .
    cp ../../../../data/graf3.png .
    cp ../../../../data/H1to3p.xml .
    
    ls
    AKAZE_match.py  graf1.png  graf3.png  H1to3p.xml
    
    # 运行代码
    python AKAZE_match.py --input1 graf1.png --input2 graf3.png --homography H1to3p.xml 
    
    

    效果如下:

    2-1 输出如下:

    A-KAZE Matching Results
    *******************************
    # Keypoints 1:                        	 2418
    # Keypoints 2:                        	 2884
    # Matches:                            	 382
    # Inliers:                            	 267
    # Inliers Ratio:                      	 0.6989528795811518
    
    

    Detect the keypoints using SURF Detector, compute the descriptors【SURF检测器检测关键点】


    运行该代码:

    cd opencv/samples/python/tutorial_code/features2D/feature_description
    
    cp ../../../../data/box* .
    
    # 运行代码
    python SURF_matching_Demo.py --input1 box.png --input2 box_in_scene.png 
    
    # 运行报错【尚未处理 -- 可能是安装的 opencv-python 4.5.1.48 版本有些低】:
    Traceback (most recent call last):
      File "SURF_matching_Demo.py", line 19, in <module>
        detector = cv.xfeatures2d_SURF.create(hessianThreshold=minHessian)
    AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d_SURF'
    
    

    basic panorama stitching from a rotating camera【旋转相机的基本全景拼接】


    运行该代码一:

    cd opencv/samples/python/tutorial_code/features2D/Homography
    
    python panorama_stitching_rotating_camera.py -I1 ../../../../data/Blender_Suzanne1.jpg -I2 ../../../../data/Blender_Suzanne2.jpg 
    
    

    运行效果如下:

    2-2


    Draw matches【棋盘角匹配】


    运行该代码:

    cd opencv/samples/python/tutorial_code/features2D/Homography
    
    cp ../../../../data/left01.jpg .
    cp ../../../../data/left02.jpg .
    
    python perspective_correction.py --image1 left01.jpg --image2 left02.jpg 
    
    

    运行效果如下:

    2-3


    9-9

    博主简介:软件工程硕士、已毕业、马上 10w 读者 粉丝

    • 🍊 计算机视觉:超分重建、图像修复、目标检测、风格迁移 等领域 稍有所学
    • 🍊 AI 工程化:Ncnn、MNN、TensorRT 正在 学习
    • 🍊 C++、Python、Java 略懂一二
    • 🍊 👋 Follow me 👋,一起 Get 更多有趣 AI、实战博文教程、冲冲冲 🚀 🚀

    喜欢请关注 墨理学AI 及其 同名 公众号 墨理学AI

    取经路上,让墨理学AI 陪你畅享更多有趣AI