当前位置:网站首页>Sub pixel corner detection opencv cornersubpix
Sub pixel corner detection opencv cornersubpix
2022-07-07 03:22:00 【Master Ma】
Opencv-cornerSubPix Principle introduction
If the purpose of image processing is not to extract feature points for recognition, but to carry out geometric measurement , This usually requires higher accuracy , The function goodFeaturesToTrack() Only simple pixel coordinate values can be provided , That is to say, sometimes we need real coordinate values instead of integer coordinate values .
Corner location features : The connecting line between the corner and the edge point is perpendicular to the gradient direction of the edge point .
As shown in the figure above , Suppose a starting corner q Near the actual sub-pixel corner .
p The point is q In the neighborhood near the point , if p The point is inside the uniform area , be p The gradient of the point is 0; if p Point on the edge , be p The gradient direction of the point is perpendicular to the edge direction . If the vector q-p The direction is consistent with the edge direction , that q-p Vector and p The result of dot product operation of gradient vector of point is 0 .
At the initial corner ( The initial corner may not be on the edge ) Nearby, we can collect the gradients and correlation vectors of many groups of points q-p , At this time q It is the more accurate corner position we require , Then the vector dot product of each group is set to 0 , It is based on this idea , Product points into 0 The equations of form a system equation , The solution of the system equation is a more accurate sub-pixel corner position . New q Point as the center of the region , You can continue to use this method for iteration , Obtain high accuracy .
Look for sub-pixel corners :cornerSubPix function
void cornerSubPix(InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria);
image, The input image , Source image .
corners, Provide the initial coordinates of the input corner and the precise output coordinates .
winSize, Half the size of the search window . if winSize = Size(5,5), That means using (52+1)×(52+1)= 11×11 Size search window .
zeroZone, Half the size of the dead zone . The real search area is [zeroZone2+1 , winSize2+1]. The value is (-1,-1) Indicates that there is no dead zone .
criteria, The termination condition of the iterative process of finding the corner . Or the number of iterations is greater than a certain set value , Or the accuracy reaches a certain set value , It can even be a combination of them .
#include<opencv.hpp>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
using namespace cv;
Mat src, cornerImg, grayImg;
int mxCorners = 10;
RNG rngs = {
12345 };
void Change(int, void*) {
// Calculate the integer corner
vector<Point>corners1;
vector<Point2f>corners2; //https://www.cnblogs.com/bjxqmy/p/12459005.html
goodFeaturesToTrack(grayImg, corners1, mxCorners, 0.01, 10, Mat(), 3, false, 0.04);
goodFeaturesToTrack(grayImg, corners2, mxCorners, 0.01, 10, Mat(), 3, false, 0.04);
// Calculate the exact corner
TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::MAX_ITER, 40, 0.001);
cornerSubPix(grayImg, corners2, Size(5, 5), Size(-1, -1), criteria);
Mat dst = src.clone();
for (int i = 0; i < corners1.size(); i++) {
cout << "[" << corners1[i].x << "," << corners1[i].y << "]" << endl;
cout << "[" << corners2[i].x << "," << corners2[i].y << "]" << endl << endl;
Scalar colors = Scalar(rngs.uniform(0, 255), rngs.uniform(0, 255), rngs.uniform(0, 255));
circle(dst, corners2[i], 5, colors, -1);
}
imshow("dst", dst);
}
int main() {
src = imread("C:/Users/ Qi Mingyang /Desktop/ The sample picture /1.jpg");
imshow("src", src);
// Convert to grayscale image
cvtColor(src, grayImg, COLOR_BGR2GRAY);
namedWindow("dst");
createTrackbar("maxCorners", "dst", &mxCorners, 100, Change);
Change(0, 0);
waitKey(0);
}
Reference source :https://blog.csdn.net/weixin_41695564/article/details/79991733
边栏推荐
- 2022年信息安全工程师考试大纲
- How to analyze fans' interests?
- leetcode
- 杰理之RTC 时钟开发【篇】
- tensorboard的使用
- Cocos2d-x Box2D物理引擎编译设置
- 美国空军研究实验室《探索深度学习系统的脆弱性和稳健性》2022年最新85页技术报告
- Shangsilicon Valley JVM Chapter 1 class loading subsystem
- Stored procedures and functions (MySQL)
- Codeforces round 264 (Div. 2) C gargari and Bishop [violence]
猜你喜欢
杰理之播内置 flash 提示音控制播放暂停【篇】
Shangsilicon Valley JVM Chapter 1 class loading subsystem
The whole process of knowledge map construction
The first symposium on "quantum computing + application of financial technology" was successfully held in Beijing
The solution of unable to create servlet file after idea restart
Appx代码签名指南
IDEA重启后无法创建Servlet文件的解决方案
Create applet from 0
「小样本深度学习图像识别」最新2022综述
Nuggets quantification: obtain data through the history method, and use the same proportional compound weight factor as Sina Finance and snowball. Different from flush
随机推荐
Jerry's transmitter crashed after the receiver shut down [chapter]
线性表的查找
Jerry's question about DAC output power [chapter]
Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
centerX: 用中国特色社会主义的方式打开centernet
2022.6.28
The latest 2022 review of "small sample deep learning image recognition"
LAB1配置脚本
【安全的办公和生产力应用程序】上海道宁为您提供ONLYOFFICE下载、试用、教程
变量、流程控制与游标(MySQL)
leetcode
Domcontentloaded and window onload
[Dameng database] after backup and recovery, two SQL statements should be executed
制作(转换)ico图标
Decoration design enterprise website management system source code (including mobile source code)
CVPR 2022 最佳论文候选 | PIP: 6个惯性传感器实现全身动捕和受力估计
【达梦数据库】备份恢复后要执行两个sql语句
mos管實現主副電源自動切換電路,並且“零”壓降,靜態電流20uA
[untitled]
C language string sorting