当前位置: 首页 > 编程日记 > 正文

Harris角点

可参考:http://www.cnblogs.com/ronny/p/4009425.html

http://www.cnblogs.com/ztfei/archive/2012/05/07/2487123.html

http://blog.csdn.net/crzy_sparrow/article/details/7391511

矩阵M(x)的特征值能表示在水平和竖直方向的变化程度,但Harris给出的角点差别方法并不需要计算具体的特征值,而是计算一个

角点响应值R来判断。

alpha的值对角点检测的影响:增大α的值,将减小角点响应值R,降低角点检测的灵性,减少被检测角点的数量;减小α值,将增大角点响应值R,增加角点检测的灵敏性,增加被检测角点的数量。

关于尺度不变性:

下面是代码,我加了部分注释

#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;/*void drawCornerOnImage(Mat& image, const Mat&binary)
{Mat_<uchar>::const_iterator it = binary.begin<uchar>();Mat_<uchar>::const_iterator itd = binary.end<uchar>();for (int i = 0; it != itd; it++, i++){//Point内时什么意思?if (*it)circle(image, Point(i%image.cols, i / image.cols), 3, Scalar(0, 255, 0), 1);}
}
*/
/******************下面是Harris角点检测的C++实现*******************************/
/*
void detectHarrisCorners(const Mat& imgSrc,Mat& imgDst,double alpha )
{Mat gray;if (imgSrc.channels() == 3)cvtColor(imgSrc, gray, CV_BGR2GRAY);elsegray = imgSrc.clone();gray.convertTo(gray, CV_64F);//第二个参数depthMat xKernel = (Mat_<double>(1, 3) << -1, 0, 1);//模板一行三列,后面为相应的值Mat yKernel = xKernel.t();Mat Ix, Iy;//Convolves an image with the kernel.filter2D(gray, Ix, CV_64F, xKernel);filter2D(gray, Iy, CV_64F, yKernel);Mat Ix2, Iy2, Ixy;//计算图像两个梯度方向的乘积Ix2 = Ix.mul(Ix);Iy2 = Iy.mul(Iy);Ixy = Ix.mul(Iy);Mat gaussKernel = getGaussianKernel(7, 1);filter2D(Ix2, Ix2, CV_64F, gaussKernel);filter2D(Iy2, Iy2, CV_64F, gaussKernel);filter2D(Ixy, Ixy, CV_64F, gaussKernel);Mat cornerStrength(gray.size(), gray.type());for (int i = 0; i < gray.rows; i++){for (int j = 0; j < gray.cols; j++){double det_m = Ix2.at<double>(i, j)*Iy2.at<double>(i, j)-Ixy.at<double>(i,j)*Ixy.at<double>(i,j);double trace_m = Ix2.at<double>(i, j) + Iy2.at<double>(i, j);cornerStrength.at<double>(i,j) = det_m - trace_m;}}//thresholddouble maxStrength;minMaxLoc(cornerStrength, NULL, &maxStrength, NULL, NULL);Mat dilated, localMax;//默认3*3核膨胀,膨胀之后,除了局部最大值点和原来相同,其它非局部最大值点被  //3*3邻域内的最大值点取代  dilate(cornerStrength, dilated, Mat());imshow("dilated", dilated);imshow("cornerStrength", cornerStrength);//与原图相比,只剩下和原图值相同的点,这些点都是局部最大值点,保存到localMax  compare(cornerStrength, dilated, localMax, CMP_EQ);//两图中相同的地方进行比较,相等的地方设为255imshow("localMax", localMax);Mat cornerMap;double qualityLevel = 0.01;double thresh = qualityLevel * maxStrength;cornerMap = cornerStrength > thresh;bitwise_and(cornerMap, localMax, cornerMap);//将两图进行与操作imgDst = cornerMap.clone();}*/
int main()
{/******harris角点检测的C++实现********//*Mat img = imread("1.jpg");imshow("原图", img);Mat gray,dst;cvtColor(img, gray, CV_BGR2GRAY);detectHarrisCorners(img, dst, 0.01);imshow("目标", dst);drawCornerOnImage(img, dst);imshow("处理后", img);*/////*************************下面是用opencv自带的角点检测函数*************************/
    /*Mat img = imread("1.jpg");imshow("原图", img);Mat gray;cvtColor(img, gray, CV_BGR2GRAY);Mat cornerStrenth;cornerHarris(gray, cornerStrenth, 3, 3, 0.1);//imshow("cornerstrenth", cornerStrenth);threshold(cornerStrenth, cornerStrenth, 0.001, 255, THRESH_BINARY);//imshow("cornerstrenth", cornerStrenth);double maxStrength, minStrength;minMaxLoc(cornerStrenth, &minStrength, &maxStrength);Mat dilated;Mat locaMax;// // 膨胀图像,找出图像中全部的局部最大值点dilate(cornerStrenth, dilated, Mat());//imshow("dilated", dilated);// compare是一个逻辑比较函数,返回两幅图像中对应点相同的二值图像compare(cornerStrenth, dilated, locaMax, CMP_EQ);//imshow("locaMax", locaMax);Mat cornerMap;double qualityLevel = 0.01;double th = qualityLevel*maxStrength; // 阈值计算threshold(cornerStrenth, cornerMap, th, 255, THRESH_BINARY);//imshow("cornerMap", cornerMap);// 转为8-bit图cornerMap.convertTo(cornerMap, CV_8U);//imshow("cornerMap1", cornerMap);// 逐点的位运算// 和局部最大值图与,剩下角点局部最大值图,即:完成非最大值抑制bitwise_and(cornerMap, locaMax, cornerMap);//imshow("cornerMap2", cornerMap);drawCornerOnImage(img, cornerMap);namedWindow("result");imshow("result", img);//imshow("角点", cornerStrenth);waitKey(0);return 0;*/waitKey(0);return 0;
}
View Code

转载于:https://www.cnblogs.com/573177885qq/p/4731808.html

相关文章:

【博客美化】公告栏显示个性时间

设置侧边公告栏显示个性化时间 效果图&#xff1a; <div id"myTime"><object classid"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version8,0,0,0"…

微信小程序实现退款

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 退款php代码 <?php // ---------------------------------------------------------------------- // | Tplay [ WE ONLY DO WHAT IS NECESSARY ] // -------------------------------…

firebase 发生消息_如何在命令行提示符下显示当前的Firebase项目名称,以防止发生危险错误...

firebase 发生消息by Thang Minh VuThang Minh Vu 如何在命令行提示符下显示当前的Firebase项目名称&#xff0c;以防止发生危险错误 (How to show your current Firebase project name on the command line prompt to prevent dangerous errors) When working on a project w…

使用SQLite删除Mac OS X 中launchpad里的快捷方式

一般情况下&#xff0c;从App Store安装的应用程序&#xff0c;如果应用删除&#xff0c;那么launchpad里对应的图标会一起删除了。 而对于不是通过App Store安装的应用程序&#xff0c;删除应用程序&#xff0c;Launchpad中很可能仍然留有相关程序图标。不能忍&#xff01;是要…

php传递JSON数据

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 php代码 public function ttt(){$data request()->param();$refund_fee $data[total_fee];$refund_phone $data[refund_phone];// consignee-金额&#xff1b;number-电话号码&a…

中国制造2025+互联网+,引领制造业发展

"中国制造2025""互联网"&#xff0c;引领制造业发展转载于:https://www.cnblogs.com/DTWolf/p/4733568.html

swift通知栏推送_如何使用Swift和Laravel使用推送通知创建iOS加密跟踪应用

swift通知栏推送by Neo Ighodaro由新Ighodaro 如何使用Swift和Laravel使用推送通知创建iOS加密跟踪应用 (How to create an iOS crypto tracking app with push notifications using Swift and Laravel) 第2部分 (Part 2) You will need the following installed on your mach…

【转】MySQL常用命令总结

http://blog.csdn.net/qq_33850438/article/details/52144686 MySQL常用的基本操作&#xff0c;以下都是MySQL 5.0下测试通过首先说明下&#xff0c;记住在每个命令结束时加上&#xff1b;&#xff08;分号&#xff09; 1. 导出整个数据库 mysqldump -u 用户名 -p --default-ch…

JS中window.document对象

小知识点注&#xff1a;外面双引号&#xff0c;里面的双引号改为单引号&#xff1b; 在div里面行高设置和整个外面高度一样&#xff0c;才能用竖直居中&#xff0c;居中是行居中 文本框取出来的值是字符串&#xff0c;需要用parseint()转化为数字 Window.document对象 一、找到…

php 常用方法

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 字符串分割成数组 explode() $str_formId aa,bb,cc;$arr_formId explode(,, $str_formId); 删除数组的第一个下标 array_shift() $str_formId aa,bb,cc;$arr_formId explode(,, $str_f…

stackoverflow_StackOverflow帐户如何确保您在公认的开发人员表格中占有一席之地

stackoverflowby Melchor Tatlonghari由Melchor Tatlonghari StackOverflow帐户如何确保您在公认的开发人员表格中占有一席之地 (How a StackOverflow account can secure you a seat at the recognised developer table) I have never met a developer who hasn’t heard of …

Python文件打包成exe

1. 安装pyinstaller pip install pyinstaller 2.如果有外部依赖包 将外部依赖包放到你的python安装的site-packages D:\Python27\Lib\site-packages 3.直接在命令提示符中输入pyinstaller -F 文件名.py 注意F要大写 4. exe在dist文件夹里面&#xff0c;如果你还用到了外部的文件…

小程序群发模板消息

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 场景&#xff1a; 微信小程序一键群发模板消息&#xff08;针对所有使用过小程序的用户&#xff09;&#xff0c;发送消息提醒用户&#xff0c;进入指定页面。 实现步骤&#xff1a; 利用…

bat启动/停止oracle服务

自己的电脑比较慢&#xff0c;尤其装了oracle10g后&#xff0c;服务开启和关闭用bat文件操作省事点 开启服务 echo offnet start OracleServiceORCLnet start OracleDBConsoleorclnet start OracleOraDb11g_home1TNSListenernet start OracleOraDb11g_home1iSQL*Plus pause 停止…

docker使用mongo_如何使用Docker在AWS上部署Mongo:初学者的权威指南

docker使用mongo为什么需要这个&#xff1f; (Why you need this?) 因为JS Python Mongo 完整的数据开发 (Because JS Python Mongo full data development) I am a Meteor developer. More precisely I use Vulcan.js, but that’s a whole other story. Meteor is a fu…

git命令每次都要输入账号密码解决方法

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 1. 打开项目cmd , 打开方式 - 进入项目的文件目录,在目录中输入 cmd 2.在命令行输入命令 git config --global credential.helper store 3.在命令行输入命令 git pull 意思是创建一…

Linux C中strcpy , strncpy , strlcpy 的区别

strcpy ,strncpy ,strlcpy的用法 好多人已经知道利用strncpy替代strcpy来防止缓冲区越界。 但是如果还要考虑运行效率的话&#xff0c;也许strlcpy是一个更好的方式。 1. strcpy strcpy 是依据 /0 作为结束判断的&#xff0c;如果 to 的空间不够&#xff0c;则会引起 buffer ov…

入职后发现公司是外包全职_我如何通过全职工作,伴侣和3岁的双胞胎男孩打造产品...

入职后发现公司是外包全职by Courtney通过考特尼 我如何通过全职工作&#xff0c;伴侣和3岁的双胞胎男孩打造产品 (How I built my product with a full-time job, partner and 3 year old twin boys) If you’ve opened this article then I’ll assume that you’re either …

Java NIO中的Buffer

简介 Buffer缓冲区&#xff0c;首先要弄明白的是&#xff0c;缓冲区是怎样一个概念。它其实是缓存的一种,我们常说的缓存&#xff0c;包括保存在硬盘上的浏览器缓存&#xff0c;保存在内存中的缓存&#xff08;比如Redis、memcached&#xff09;。Buffer是把数据保存在内存中&a…

编写高质量代码改善C#程序的157个建议——建议86:Parallel中的异常处理

建议86&#xff1a;Parallel中的异常处理建议85阐述了如何处理Task中的异常。由于Task的Start方法是异步启动的&#xff0c;所以我们需要额外的技术来完成异常处理。Parallel相对来说就要简单很多&#xff0c;因为Parallel的调用者线程会等到所有的任务全部完成后&#xff0c;再…

VS Code – No source control providers 解决方法

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 1.点击IDE左侧的搜索 2.在搜索中输入 git.enabled 3.点击Open Serrings 4.在Settings中的搜索框输入 git.enabled 5.把它下方的三个选项User Workpace broadband-h5(项目名称) 的Git en…

如何从JavaScript中的给定数字中形成最小的数字

by Prashant Yadav通过Prashant Yadav 如何从JavaScript中的给定数字中形成最小的数字 (How to form the smallest possible number from a given number in JavaScript) In this tutorial, we will implement an algorithm to form the smallest possible number with ES6.在…

微信小程序在web-view页面做分享,并且把分享的参数传递给小程序

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 本demo实现的功能&#xff0c;微信小程序给h5传参&#xff0c;h5给小程序传参 实现代码&#xff1a; <!--index.wxml --><web-view src"https://xxx.xxx.cn/test1.html?us…

洛谷—— P1118 [USACO06FEB]数字三角形Backward Digit Su…

https://www.luogu.org/problem/show?pid1118#sub 题目描述 FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 < N < 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. T…

Centos和Redhat的区别和联系

网上看到的&#xff0c;转载给大家 CentOS与RedHat的关系&#xff1a; RedHat在发行的时候&#xff0c;有两种方式&#xff1a;二进制的发行方式以及源代码的发行方式。无论是哪一种发行方式&#xff0c;你都可以免费获得&#xff08;例如从网上下载&#xff09;&#xff0c;并…

矩阵专职_新的篇章开始了-我将以专职技术作家的身份加入RunCloud

矩阵专职If you used to submit (or read) articles on the freeCodeCamp Medium publication, there is a chance that your article may have been edited by me (or by another member of the team of volunteer editors).如果您以前曾经在freeCodeCamp Medium出版物上提交(…

转:【小作品】STM32无线WIFI视频小车制作剖析(下)

转载于&#xff1a;http://blog.csdn.net/u012819339/article/details/50654764 实体作品请参看优酷视频。 若以上链接点击无效请把该链接地址复制到浏览器地址栏 http://v.youku.com/v_show/id_XODYzODczNzQ4.html 说明&#xff1a; 该作品为arvik于2014年下半年在学校实验室做…

JS 缓存 设置临时缓存和长期缓存 sessionStorage localStorage

QQ技术交流群 173683866 526474645 欢迎加入交流讨论&#xff0c;打广告的一律飞机票 使用 Window sessionStorage 和 localStorage 属性 sessionStorage 用于临时保存同一窗口(或标签页)的数据&#xff0c;在关闭窗口或标签页之后将会删除这些数据 localStorage 缓存在浏览…

SQL中distinct的用法

在表中&#xff0c;可能会包含重复值。这并不成问题&#xff0c;不过&#xff0c;有时您也许希望仅仅列出不同&#xff08;distinct&#xff09;的值。关键词 distinct用于返回唯一不同的值。表A&#xff1a;示例1select distinct name from A 执行后结果如下&#xff1a;示例2…

brain.js 时间序列_免费的Brain JS课程学习JavaScript中的神经网络

brain.js 时间序列The last few years, machine learning has gone from a promising technology to something we’re surrounded with on a daily basis. And at the heart of many machine learning systems lies neural networks.在过去的几年中&#xff0c;机器学习已经从…