<h1 style="text-wrap: wrap; font-size: 32px; border-bottom: 2px solid rgb(204, 204, 204); padding: 0px 4px 0px 0px; margin: 0px 0px 10px;">ORB</h1><p style="text-wrap: wrap;"><span style=" color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif;">当前系列所有demo下载地址:</span></p><p style="text-wrap: wrap;"><a href="https://github.com/GaoRenBao/OpenCv4-Demo" target="_blank" style="font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; margin: 0px; padding: 0px; list-style: none; border: 0px; color: rgb(0, 102, 0); transition-duration: 0.2s; transition-property: opacity; outline: none; opacity: 0.8;">https://github.com/GaoRenBao/OpenCv4-Demo</a></p><p style="margin-top: 0px; margin-bottom: 10px; text-wrap: wrap; box-sizing: border-box; overflow-wrap: break-word; word-break: break-all; line-height: 1.5em; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; color: rgb(51, 51, 51); ">源码参考原文:</p><p style="margin-top: 0px; margin-bottom: 10px; text-wrap: wrap; box-sizing: border-box; overflow-wrap: break-word; word-break: break-all; line-height: 1.5em; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; color: rgb(51, 51, 51); "><a href="/api/system/download?file=OpenCV-Python-Tutorial-%E4%B8%AD%E6%96%87%E7%89%88.pdf" target="_blank" title="OpenCV-Python-Tutorial-中文版.pdf (P207)">OpenCV-Python-Tutorial-中文版.pdf (P207)</a><span style="color: rgba(0, 0, 0, 0.85);"> </span></p><p style="margin-top: 0px; margin-bottom: 10px; text-wrap: wrap; padding: 0px; list-style: none; border: 0px; overflow-wrap: break-word; word-break: break-all; line-height: 1.5em; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; box-sizing: border-box; color: rgb(51, 51, 51);">不同编程语言对应的OpenCv版本以及<span style="">开发环境</span>信息如下:<span style="font-family: Calibri; font-size: 14px;"> </span></p><table border="1" style="border-right: none; border-bottom: none; border-image: initial; border-left: 1px solid rgb(102, 102, 102); border-top: 1px solid rgb(102, 102, 102);"><tbody><tr class="firstRow"><td width="81" valign="top" style="border-color: windowtext rgb(102, 102, 102) rgb(102, 102, 102) windowtext; border-bottom-width: 1px; border-bottom-style: solid; border-right-width: 1px; border-right-style: solid; padding: 5px;"><p style="text-align: center;"><strong><span style="font-family: 宋体; font-size: 14px;">语言</span></strong></p></td><td width="223" valign="top" style="border-color: windowtext rgb(102, 102, 102) rgb(102, 102, 102) windowtext; border-bottom-width: 1px; border-bottom-style: solid; border-right-width: 1px; border-right-style: solid; padding: 5px;"><p style="text-align: center;"><strong><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">OpenCv</span>版本</span></strong></p></td><td width="242" valign="top" style="border-color: windowtext rgb(102, 102, 102) rgb(102, 102, 102) windowtext; border-bottom-width: 1px; border-bottom-style: solid; border-right-width: 1px; border-right-style: solid; padding: 5px;"><p style="text-align: center;"><strong><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">IDE</span></span></strong></p></td></tr><tr><td width="81" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">C#</span></span></p></td><td width="223" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: Calibri; letter-spacing: 0px;">OpenCvSharp4.4.8.0.20230708</span></p></td><td width="242" valign="top" style="border-top: none; border-left-color: windowtext; word-break: break-all; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">Visual Studio 2022</span></span></p></td></tr><tr><td width="81" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">C++</span></span></p></td><td width="223" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; letter-spacing: 0px;"><span style="font-family: Calibri;">O</span></span><span style="font-family: Calibri; letter-spacing: 0px;">pen</span><span style="font-family: 宋体; letter-spacing: 0px;"><span style="font-family: Calibri;">C</span></span><span style="font-family: Calibri; letter-spacing: 0px;">v-4.5.5-vc14_vc15</span></p></td><td width="242" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">Visual Studio 2022</span></span></p></td></tr><tr><td width="81" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">Python</span></span></p></td><td width="223" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">OpenCv-Python (4.6.0.66)</span></span></p></td><td width="242" valign="top" style="border-top: none; border-left-color: windowtext; border-bottom: 1px solid rgb(102, 102, 102); border-right: 1px solid rgb(102, 102, 102); padding: 5px;"><p><span style="font-family: 宋体; font-size: 14px;"><span style="font-family: Calibri;">PyCharm Community Edition 2022.1.3</span></span></p></td></tr></tbody></table><p><br/></p><p> SIFT 和SURF算法是有专利保护的,如果你要使用它们,就可能要花钱。但是ORB不需要!!!</p><p> ORB基本是FAST关键点检测和BRIEF关键点描述器的结合体,并通过很多修改增强了性能。首先它使用FAST找到关键点,然后再使用Harris角点检测对这些关键点进行排序找到其中的前N个点。它也使用金字塔从而产</p><p>生尺度不变性特征。但是有一个问题,FAST算法步计算方向。那旋转不变性怎样解决呢?作者进行了如下修改。</p><p> 它使用灰度矩的算法计算出角点的方向。以角点到角点所在(小块)区域质心的方向为向量的方向。为了进一步提高旋转不变性,要计算以角点为中心半径为r的圆形区域的矩,再根据矩计算除方向。</p><p> 对于描述符,ORB使用的是BRIEF描述符。但是我们已经知道BRIEF对与旋转是不稳定的。所以我们在生成特征前,要把关键点领域的这个patch的坐标轴旋转到关键点的方向。</p><p><br/></p><p style="text-wrap: wrap;">测试原图如下:<br/></p><p style="text-wrap: wrap;"><img src="/upload/image/6383453188145459191230459.jpg" alt="blox.jpg"/></p><p style="text-wrap: wrap;">运行效果如下:</p><p style="text-wrap: wrap;"><img src="/upload/image/6383453918999336889186012.jpg" title="out.jpg" alt="out.jpg"/></p><p style="text-wrap: wrap;"><br/></p><p style="text-wrap: wrap;"><strong style="margin: 0px; padding: 0px; list-style: none; border: 0px; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; "><span style="font-style: italic; color: rgb(51, 153, 204); line-height: 18px;">C#版本代码如下:</span></strong></p><pre class="brush:c#;toolbar:false">using OpenCvSharp;
namespace demo
{
internal class Program
{
static void Main(string[] args)
{
Mat img = Cv2.ImRead("../../../images/blox.jpg", 0);
// Initiate ORB detector
var orb = ORB.Create();
// find the keypoints with ORB
var kp = orb.Detect(img);
// compute the descriptors with ORB
Mat des = new Mat();
orb.Compute(img, ref kp, des);
// draw only keypoints location,not size and orientation
Mat img2 = new Mat();
Cv2.DrawKeypoints(img, kp, img2, new Scalar(0, 255, 0), DrawMatchesFlags.Default);
Cv2.ImShow("img", img2);
Cv2.WaitKey(0);
}
}
}</pre><p style="text-wrap: wrap;"><br/></p><p style="text-wrap: wrap;"><strong style="margin: 0px; padding: 0px; list-style: none; border: 0px; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; "><strong style="margin: 0px; padding: 0px; list-style: none; border: 0px;"><span style="font-style: italic; color: rgb(51, 153, 204); line-height: 18px;">C++版本代码如下:</span></strong></strong></p><pre class="brush:cpp;toolbar:false">#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat img = cv::imread("../images/blox.jpg", 0);
// Initiate ORB detector
Ptr<ORB> orb = cv::ORB::create();
// find the keypoints with ORB
vector<KeyPoint> kp;
orb->detect(img, kp);
// compute the descriptors with ORB
Mat des;
orb->compute(img, kp, des);
// draw only keypoints location,not size and orientation
Mat img2;
drawKeypoints(img, kp, img2, Scalar(0, 255, 0), DrawMatchesFlags::DEFAULT);
cv::imshow("img", img2);
cv::waitKey(0);
}</pre><p><br/></p><p style="text-wrap: wrap;"><strong style="margin: 0px; padding: 0px; list-style: none; border: 0px; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Micro Hei", Arial, sans-serif; "><strong style="margin: 0px; padding: 0px; list-style: none; border: 0px;"><span style="font-style: italic; color: rgb(51, 153, 204); line-height: 18px;">Python版本代码如下:</span></strong></strong></p><pre class="brush:python;toolbar:false">import cv2
from matplotlib import pyplot as plt
img = cv2.imread('../images/blox.jpg', 0)
# Initiate ORB detector
orb = cv2.ORB_create()
# find the keypoints with ORB
kp = orb.detect(img, None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img, kp, None, color=(0, 255, 0), flags=0)
cv2.imwrite("out.jpg", img2)
plt.imshow(img2), plt.show()</pre><p><br/></p>
ORB 当前系列所有demo下载地址:
https://github.com/GaoRenBao/OpenCv4-Demo
源码参考原文:
OpenCV-Python-Tutorial-中文版.pdf (P207)
不同编程语言对应的OpenCv版本以及开发环境 信息如下:
语言
OpenCv 版本
IDE
C#
OpenCvSharp4.4.8.0.20230708
Visual Studio 2022
C++
O pen C v-4.5.5-vc14_vc15
Visual Studio 2022
Python
OpenCv-Python (4.6.0.66)
PyCharm Community Edition 2022.1.3
SIFT 和SURF算法是有专利保护的,如果你要使用它们,就可能要花钱。但是ORB不需要!!!
ORB基本是FAST关键点检测和BRIEF关键点描述器的结合体,并通过很多修改增强了性能。首先它使用FAST找到关键点,然后再使用Harris角点检测对这些关键点进行排序找到其中的前N个点。它也使用金字塔从而产
生尺度不变性特征。但是有一个问题,FAST算法步计算方向。那旋转不变性怎样解决呢?作者进行了如下修改。
它使用灰度矩的算法计算出角点的方向。以角点到角点所在(小块)区域质心的方向为向量的方向。为了进一步提高旋转不变性,要计算以角点为中心半径为r的圆形区域的矩,再根据矩计算除方向。
对于描述符,ORB使用的是BRIEF描述符。但是我们已经知道BRIEF对与旋转是不稳定的。所以我们在生成特征前,要把关键点领域的这个patch的坐标轴旋转到关键点的方向。
测试原图如下:
运行效果如下:
C#版本代码如下:
using OpenCvSharp;
namespace demo
{
internal class Program
{
static void Main(string[] args)
{
Mat img = Cv2.ImRead("../../../images/blox.jpg", 0);
// Initiate ORB detector
var orb = ORB.Create();
// find the keypoints with ORB
var kp = orb.Detect(img);
// compute the descriptors with ORB
Mat des = new Mat();
orb.Compute(img, ref kp, des);
// draw only keypoints location,not size and orientation
Mat img2 = new Mat();
Cv2.DrawKeypoints(img, kp, img2, new Scalar(0, 255, 0), DrawMatchesFlags.Default);
Cv2.ImShow("img", img2);
Cv2.WaitKey(0);
}
}
}
C++版本代码如下:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat img = cv::imread("../images/blox.jpg", 0);
// Initiate ORB detector
Ptr<ORB> orb = cv::ORB::create();
// find the keypoints with ORB
vector<KeyPoint> kp;
orb->detect(img, kp);
// compute the descriptors with ORB
Mat des;
orb->compute(img, kp, des);
// draw only keypoints location,not size and orientation
Mat img2;
drawKeypoints(img, kp, img2, Scalar(0, 255, 0), DrawMatchesFlags::DEFAULT);
cv::imshow("img", img2);
cv::waitKey(0);
}
Python版本代码如下:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('../images/blox.jpg', 0)
# Initiate ORB detector
orb = cv2.ORB_create()
# find the keypoints with ORB
kp = orb.detect(img, None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img, kp, None, color=(0, 255, 0), flags=0)
cv2.imwrite("out.jpg", img2)
plt.imshow(img2), plt.show()