当前位置:网站首页>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
边栏推荐
- CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
- How to analyze fans' interests?
- 上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
- SQL中删除数据
- Numpy中排序操作partition,argpartition,sort,argsort
- HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
- input_delay
- 你知道电子招标最突出的5大好处有哪些吗?
- leetcode-02(链表题)
- [swift] learning notes (I) -- familiar with basic data types, coding styles, tuples, propositions
猜你喜欢

Le tube MOS réalise le circuit de commutation automatique de l'alimentation principale et de l'alimentation auxiliaire, et la chute de tension "zéro", courant statique 20ua
![Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]](/img/8c/e8f7e667e4762a4815e97c36a2759f.png)
Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]

leetcode

Don't you know the relationship between JSP and servlet?

HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother

上个厕所的功夫,就把定时任务的三种调度策略说得明明白白

Appx code signing Guide

图形化工具打包YOLOv5,生成可执行文件EXE

线性表的查找

Intelligent static presence detection scheme, 5.8G radar sensing technology, human presence inductive radar application
随机推荐
商城商品的知识图谱构建
How-PIL-to-Tensor
尚硅谷JVM-第一章 类加载子系统
迷失在MySQL的锁世界
[C language] question set of IX
HDU ACM 4578 Transformation-&gt; Segment tree - interval change
杰理之电话本获取【篇】
sshd[12282]: fatal: matching cipher is not supported: aes256- [email protected] [preauth]
源代码保密的意义和措施
An error in SQL tuning advisor ora-00600: internal error code, arguments: [kesqsmakebindvalue:obj]
Lavel PHP artisan automatically generates a complete set of model+migrate+controller commands
SQL中删除数据
netperf 而网络性能测量
New benchmark! Intelligent social governance
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
Flink Task退出流程与Failover机制
Install torch 0.4.1
存储过程与函数(MySQL)
Shell programming basics
The version control of 2021 version is missing. Handling method