1 Star 0 Fork 8

Dawish/opencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
_15SIFT测试.py 839 Bytes
一键复制 编辑 原始数据 按行查看 历史
18151521911@163.com 提交于 2022-02-27 09:46 . opencv示例代码
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 15 11:00:02 2018
@author: zy
"""
import numpy as np
import cv2
from matplotlib import pyplot as plt
img1 = cv2.imread('./image/orb1.jpg',0)
img2 = cv2.imread('./image/orb2.jpg',0)
img2 = cv2.resize(img2,dsize=(450,300))
# Initiate SIFT detector
sift = cv2.xfeatures2d.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# BFMatcher with default params
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)
# Apply ratio test
good = []
for m,n in matches:
if m.distance < 0.75*n.distance:
good.append([m])
# cv2.drawMatchesKnn expects list of lists as matches.
img3 = None
img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,img3,flags=2)
plt.imshow(img3),plt.show()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Dawish/opencv.git
git@gitee.com:Dawish/opencv.git
Dawish
opencv
opencv
master

搜索帮助