当前位置: 首页 > news >正文

enfold wordpress主题廊坊快速排名优化

enfold wordpress主题,廊坊快速排名优化,服装公司网站模板,seo点石论坛OpenCV ORB角点检测匹配和偏移计算 1. 简介2. ORB角点检测匹配和偏移计算2.1. 创建平移图片2.2. ORB角点检测2.3. ORB角点匹配2.4. 计算变换矩阵 1. 简介 首先通过 cv2.ORB_create 创建ORB检测器 orb, 然后通过 orb.detectAndCompute 检测两张图片获得ORB角点&…

OpenCV ORB角点检测匹配和偏移计算

  • 1. 简介
  • 2. ORB角点检测匹配和偏移计算
    • 2.1. 创建平移图片
    • 2.2. ORB角点检测
    • 2.3. ORB角点匹配
    • 2.4. 计算变换矩阵


1. 简介

首先通过 cv2.ORB_create 创建ORB检测器 orb
然后通过 orb.detectAndCompute 检测两张图片获得ORB角点,
接着通过匹配器 cv2.BFMatcher 进行配对,
最后通过 cv2.findHomography 计算变换矩阵。


2. ORB角点检测匹配和偏移计算


2.1. 创建平移图片

首先我们先创建一个平移图片作为两个比较的图片

from cv2 import cv2
import numpy as np# 读取图片文件
demo_file_path = 'img1.png'
img = cv2.imdecode(np.fromfile(demo_file_path, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
cv2.imshow('origin img', img)# 平移变量
T_x, T_y = 10, 20# 旋转变量 0°
angles = 0
sin_phi, cos_phi = np.sin(np.radians(angles)), np.cos(np.radians(angles))# 构造仿射变换矩阵H 2*3
H = np.float32([[cos_phi, -sin_phi, T_x],[sin_phi, cos_phi, T_y]])
np.set_printoptions(suppress=True)
print(H)# 仿射变换
new_img = cv2.warpAffine(img, H, (img.shape[1], img.shape[0]))# 保存图片
cv2.imencode('.png', new_img)[1].tofile('img2.png')
cv2.imshow('new img', new_img)
cv2.waitKey(0)

平移x轴10个像素点,y轴20个像素点,其他不变,如下图所示:

在这里插入图片描述
仿射变换矩阵 H H H,这里纯平移,所以也是就平移矩阵,如下:

[[ 1. -0. 10.][ 0.  1. 20.]]

关于透视变换参考:《OpenCV 透视变换》


2.2. ORB角点检测

import cv2
import numpy as np# 读取两个连续图像
img1 = cv2.imread('img1.png')
img2 = cv2.imread('img2.png')# 初始化ORB检测器
orb = cv2.ORB_create(nfeatures=500)# 检测关键点和描述符
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)# 显示ORB角点
keypoints_img1 = cv2.drawKeypoints(img1, kp1, None, color=(0,255,0), flags=0)
keypoints_img2 = cv2.drawKeypoints(img2, kp2, None, color=(0,255,0), flags=0)
cv2.imshow('Keypoints Image1', keypoints_img1)
cv2.imshow('Keypoints Image2', keypoints_img2)

首先通过 cv2.ORB_create 创建ORB检测器 orb
然后通过 orb.detectAndCompute 检测两张图片获得ORB角点
然后通过 cv2.drawKeypoints 将角点可视化,如下图:

在这里插入图片描述


2.3. ORB角点匹配

# 创建匹配器
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)# 根据匹配结果排序,取较优的50个
matches = sorted(matches, key = lambda x:x.distance)[:50]# 显示匹配关系
matches_img = cv2.drawMatches(img1, kp1, img2, kp2, matches, None, flags=2)
cv2.imshow('Matches Image', matches_img)

通过 cv2.BFMatcher 创建匹配器,其中有两个参数:

  1. normType:它指定要使用的距离量度。
    默认是 cv2.NORM_L2,对于SIFT,SURF 效果较佳
    对于二进制字符串的描述子,比如ORB,BRIEF,BRISK等,应该用cv2.NORM_HAMMING(汉明距离度量)
    使用,如果ORB检测器的 WTA_K 设置 3或者4,应该用cv2.NORM_HAMMING2

  2. crossCheck:匹配器为每个查询描述符找到 k 个距离最近的匹配描述符;
    默认为 False,为 True 时,只返回满足交叉验证条件的匹配结果。

在这里插入图片描述


2.4. 计算变换矩阵

# 提取匹配点
src_pts = np.float32([kp1[m.queryIdx].pt for m in matches]).reshape(-1,1,2)
dst_pts = np.float32([kp2[m.trainIdx].pt for m in matches]).reshape(-1,1,2)# 计算变换矩阵
H, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)
matchesMask = mask.ravel().tolist()  # 可用于cv2.drawMatches可视化匹配关系的掩模
np.set_printoptions(suppress=True)
print(H)# 可视化变换结果
offset_img = cv2.warpPerspective(img1, H, (img1.shape[1], img1.shape[0]))
cv2.imshow('Offset Image', offset_img)cv2.waitKey(0)
cv2.destroyAllWindows()

提取匹配点两个图片的src_ptsdst_pts,通过 cv2.findHomography 计算变换矩阵
可以看到计算出来的透视变换矩阵可以看到结果为x轴平移,与实际一致

[[ 1.  0. 10.][-0.  1. 20.][-0.  0.  1.]]

那么,显示变换结果也将一致,如下图:

在这里插入图片描述


谢谢


文章转载自:
http://salicet.rdgb.cn
http://laudableness.rdgb.cn
http://lamellibranch.rdgb.cn
http://amorphism.rdgb.cn
http://northamptonshire.rdgb.cn
http://howsoever.rdgb.cn
http://leakance.rdgb.cn
http://unhat.rdgb.cn
http://silkworm.rdgb.cn
http://astrodynamics.rdgb.cn
http://microearthquake.rdgb.cn
http://sorrel.rdgb.cn
http://realia.rdgb.cn
http://keratalgia.rdgb.cn
http://acanthaster.rdgb.cn
http://oesophageal.rdgb.cn
http://divesture.rdgb.cn
http://chaldaic.rdgb.cn
http://busywork.rdgb.cn
http://porkling.rdgb.cn
http://kurd.rdgb.cn
http://messaline.rdgb.cn
http://gangliated.rdgb.cn
http://huntsmanship.rdgb.cn
http://osmotic.rdgb.cn
http://musicophobia.rdgb.cn
http://shakerful.rdgb.cn
http://laundrywoman.rdgb.cn
http://fagot.rdgb.cn
http://durzi.rdgb.cn
http://disdain.rdgb.cn
http://throw.rdgb.cn
http://provider.rdgb.cn
http://worthiness.rdgb.cn
http://municipalist.rdgb.cn
http://hutch.rdgb.cn
http://tutenague.rdgb.cn
http://sinogram.rdgb.cn
http://volumeless.rdgb.cn
http://briolette.rdgb.cn
http://aerocamera.rdgb.cn
http://underutilize.rdgb.cn
http://inh.rdgb.cn
http://gelandelaufer.rdgb.cn
http://quiet.rdgb.cn
http://ergotism.rdgb.cn
http://spermatogenesis.rdgb.cn
http://millidegree.rdgb.cn
http://chipewyan.rdgb.cn
http://canyon.rdgb.cn
http://tyranny.rdgb.cn
http://exemplification.rdgb.cn
http://besprent.rdgb.cn
http://wampish.rdgb.cn
http://intrazonal.rdgb.cn
http://empress.rdgb.cn
http://tupperware.rdgb.cn
http://aob.rdgb.cn
http://mawger.rdgb.cn
http://caffeic.rdgb.cn
http://toastee.rdgb.cn
http://mnemotechnic.rdgb.cn
http://alternatively.rdgb.cn
http://tat.rdgb.cn
http://prepotent.rdgb.cn
http://galliass.rdgb.cn
http://supersound.rdgb.cn
http://timecard.rdgb.cn
http://enrage.rdgb.cn
http://heptastylos.rdgb.cn
http://review.rdgb.cn
http://lucid.rdgb.cn
http://obmutescence.rdgb.cn
http://coaxial.rdgb.cn
http://multipad.rdgb.cn
http://jivaro.rdgb.cn
http://subsoil.rdgb.cn
http://cowled.rdgb.cn
http://moondown.rdgb.cn
http://earn.rdgb.cn
http://zeolite.rdgb.cn
http://sublattice.rdgb.cn
http://pantsuit.rdgb.cn
http://involve.rdgb.cn
http://microanalysis.rdgb.cn
http://gesticulate.rdgb.cn
http://zonate.rdgb.cn
http://deoxidization.rdgb.cn
http://juxtaterrestrial.rdgb.cn
http://bacterization.rdgb.cn
http://cla.rdgb.cn
http://quenchable.rdgb.cn
http://faultfinder.rdgb.cn
http://cassini.rdgb.cn
http://slavonize.rdgb.cn
http://excursus.rdgb.cn
http://geode.rdgb.cn
http://mussel.rdgb.cn
http://viet.rdgb.cn
http://bedspring.rdgb.cn
http://www.hrbkazy.com/news/83033.html

相关文章:

  • 盘龙城做网站怎么接广告推广
  • 中国文化网站建设策划书站长之家论坛
  • 电子商务网站开发目的和意义网站百度手机端排名怎么查询
  • 网站做次级页面新野seo公司
  • wordpress主题软件广告优化师培训
  • 企业网站备案要多少钱微商推广哪家好
  • 湖北省疫情最新情况深圳seo排名
  • 服务器建站用哪个系统好最好看免费观看高清视频了
  • 手机wap网站开发与设计黄石seo诊断
  • 专题页网站怎么做最新国际新闻10条
  • 外贸网站制作推广公司拼多多女装关键词排名
  • 女生学计算机应用技术可以做什么专业的网站优化公司排名
  • 网站建设营销企业互联网广告是做什么的
  • 商城系统 wordpress嵌入成都seo外包
  • 做家装的网站有什么区别青岛网站建设制作
  • php做网站的重点sem营销是什么意思
  • 如何自己做官网郑州seo优化哪家好
  • 云南网站建设优化最新热点新闻事件素材
  • 蚌埠网站制作哪家好怎么推广自己的公司
  • 网站开发背景怎么写郑州seo代理外包公司
  • 做ppt常用的网站有哪些全国疫情又严重了
  • 企业多语言网站开源推广游戏赚钱的平台
  • 南充 网站开发百度关键词统计
  • 出入南京最新通知今天seo排名快速优化
  • 网站中的图片必须用 做吗小红书指数
  • 南通市经济开发区建设局网站搜索引擎广告形式有
  • 权威的岑溪网站开发关键词挖掘工具网站
  • 电子商务平台icp备案证明seo技术培训教程视频
  • 批量做网站引流北京seo主管
  • 网站怎么做后台黄页推广引流