热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

特征检测之特征提取(Detect)

特征检测之特征提取(Detect)DetectkeypointsinimageusingthetraditionalShi-Thomasidetecto

特征检测之特征提取(Detect)

在这里插入图片描述

// Detect keypoints in image using the traditional Shi-Thomasi detector
void detKeypointsShiTomasi(vector &keypoints, cv::Mat &img, bool bVis)
{// compute detector parameters based on image sizeint blockSize &#61; 4; // size of an average block for computing a derivative covariation matrix over each pixel neighborhooddouble maxOverlap &#61; 0.0; // max. permissible overlap between two features in %double minDistance &#61; (1.0 - maxOverlap) * blockSize;int maxCorners &#61; img.rows * img.cols / max(1.0, minDistance); // max. num. of keypointsdouble qualityLevel &#61; 0.01; // minimal accepted quality of image cornersdouble k &#61; 0.04;// Apply corner detectiondouble t &#61; (double)cv::getTickCount();vector corners;cv::goodFeaturesToTrack(img, corners, maxCorners, qualityLevel, minDistance, cv::Mat(), blockSize, false, k);// add corners to result vectorfor (auto it &#61; corners.begin(); it !&#61; corners.end(); &#43;&#43;it){cv::KeyPoint newKeyPoint;newKeyPoint.pt &#61; cv::Point2f((*it).x, (*it).y);newKeyPoint.size &#61; blockSize;keypoints.push_back(newKeyPoint);}t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"Shi-Tomasi detection with n&#61;" <}//FAST, BRISK, ORB, AKAZE, SIFT
void detKeypointsModern(std::vector &keypoints, cv::Mat &img, std::string detectorType, bool bVis)
{string windowName;if (detectorType.compare("FAST") &#61;&#61; 0){int threshold &#61; 30;bool bNMS &#61; true;cv::FastFeatureDetector::DetectorType type &#61; cv::FastFeatureDetector::TYPE_9_16; // TYPE_9_16, TYPE_7_12, TYPE_5_8cv::Ptr detector &#61; cv::FastFeatureDetector::create(threshold, bNMS, type);double t &#61; (double)cv::getTickCount();detector->detect(img, keypoints);t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"FAST detection with n&#61; " < detector &#61; cv::BRISK::create();double t &#61; (double)cv::getTickCount();detector->detect(img, keypoints);t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"BRISK detection with n&#61; " < detector &#61; cv::ORB::create();double t &#61; (double)cv::getTickCount();detector->detect(img, keypoints);t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"ORB detection with n&#61; " < detector &#61; cv::AKAZE::create();double t &#61; (double)cv::getTickCount();detector->detect(img, keypoints);t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"AKAZE detection with n&#61; " < detector &#61; cv::xfeatures2d::SIFT::create();double t &#61; (double)cv::getTickCount();detector->detect(img, keypoints);t &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"SIFT detection with n&#61; " <}// Detect keypoints in image using the traditional Harris detector
void detKeypointsHarris(std::vector &keypoints, cv::Mat &img, bool bVis)
{// Detector parametersint blockSize &#61; 2; // for every pixel, a blockSize × blockSize neighborhood is consideredint apertureSize &#61; 3; // aperture parameter for Sobel operator (must be odd)int minResponse &#61; 100; // minimum value for a corner in the 8bit scaled response matrixdouble k &#61; 0.04; // Harris parameter (see equation for details)// Detect Harris corners and normalize outputdouble t &#61; (double)cv::getTickCount();cv::Mat dst, dst_norm, dst_norm_scaled;dst &#61; cv::Mat::zeros(img.size(), CV_32FC1);cv::cornerHarris(img, dst, blockSize, apertureSize, k, cv::BORDER_DEFAULT);cv::normalize(dst, dst_norm, 0, 255, cv::NORM_MINMAX, CV_32FC1, cv::Mat());cv::convertScaleAbs(dst_norm, dst_norm_scaled);double maxOverlap &#61; 0.0; // max. permissible overlap between two features in %, used during non-maxima suppressionfor (size_t j &#61; 0; j (j, i);if (response > minResponse){ // only store points above a thresholdcv::KeyPoint newKeyPoint;newKeyPoint.pt &#61; cv::Point2f(i, j);newKeyPoint.size &#61; 2 * apertureSize;newKeyPoint.response &#61; response;// perform non-maximum suppression (NMS) in local neighbourhood around new key pointbool bOverlap &#61; false;for (auto it &#61; keypoints.begin(); it !&#61; keypoints.end(); &#43;&#43;it){double kptOverlap &#61; cv::KeyPoint::overlap(newKeyPoint, *it);if (kptOverlap > maxOverlap){bOverlap &#61; true;if (newKeyPoint.response > (*it).response){ // if overlap is >t AND response is higher for new kpt*it &#61; newKeyPoint; // replace old key point with new onebreak; // quit loop over keypoints}}}if (!bOverlap){ // only add new key point if no overlap has been found in previous NMSkeypoints.push_back(newKeyPoint); // store new keypoint in dynamic list}}} // eof loop over cols} // eof loop over rowst &#61; ((double)cv::getTickCount() - t) / cv::getTickFrequency();cout <<"Harris detection with n&#61;" <


推荐阅读
  • 本文探讨了如何通过预处理器开关选择不同的类实现,并解决在特定情况下遇到的链接器错误。 ... [详细]
  • 采用IKE方式建立IPsec安全隧道
    一、【组网和实验环境】按如上的接口ip先作配置,再作ipsec的相关配置,配置文本见文章最后本文实验采用的交换机是H3C模拟器,下载地址如 ... [详细]
  • 本文介绍了如何在多线程环境中实现异步任务的事务控制,确保任务执行的一致性和可靠性。通过使用计数器和异常标记字段,系统能够准确判断所有异步线程的执行结果,并根据结果决定是否回滚或提交事务。 ... [详细]
  • 本文介绍如何在Spring Boot项目中集成Redis,并通过具体案例展示其配置和使用方法。包括添加依赖、配置连接信息、自定义序列化方式以及实现仓储接口。 ... [详细]
  • 本文详细介绍了优化DB2数据库性能的多种方法,涵盖统计信息更新、缓冲池调整、日志缓冲区配置、应用程序堆大小设置、排序堆参数调整、代理程序管理、锁机制优化、活动应用程序限制、页清除程序配置、I/O服务器数量设定以及编入组提交数调整等方面。通过这些技术手段,可以显著提升数据库的运行效率和响应速度。 ... [详细]
  • 深入解析Java枚举及其高级特性
    本文详细介绍了Java枚举的概念、语法、使用规则和应用场景,并探讨了其在实际编程中的高级应用。所有相关内容已收录于GitHub仓库[JavaLearningmanual](https://github.com/Ziphtracks/JavaLearningmanual),欢迎Star并持续关注。 ... [详细]
  • Redux入门指南
    本文介绍Redux的基本概念和工作原理,帮助初学者理解如何使用Redux管理应用程序的状态。Redux是一个用于JavaScript应用的状态管理库,特别适用于React项目。 ... [详细]
  • 在 Android 开发中,通过 Intent 启动 Activity 或 Service 时,可以使用 putExtra 方法传递数据。接收方可以通过 getIntent().getExtras() 获取这些数据。本文将介绍如何使用 RoboGuice 框架简化这一过程,特别是 @InjectExtra 注解的使用。 ... [详细]
  • Hadoop发行版本选择指南:技术解析与应用实践
    本文详细介绍了Hadoop的不同发行版本及其特点,帮助读者根据实际需求选择最合适的Hadoop版本。内容涵盖Apache Hadoop、Cloudera CDH等主流版本的特性及应用场景。 ... [详细]
  • Spring Boot单元测试中Redis连接失败的解决方案
    本文探讨了在Spring Boot项目中进行单元测试时遇到Redis连接问题的原因及解决方法,详细分析了配置文件加载路径不当导致的问题,并提供了有效的解决方案。 ... [详细]
  • Coursera ML 机器学习
    2019独角兽企业重金招聘Python工程师标准线性回归算法计算过程CostFunction梯度下降算法多变量回归![选择特征](https:static.oschina.n ... [详细]
  • Nginx 反向代理与负载均衡实验
    本实验旨在通过配置 Nginx 实现反向代理和负载均衡,确保从北京本地代理服务器访问上海的 Web 服务器时,能够依次显示红、黄、绿三种颜色页面以验证负载均衡效果。 ... [详细]
  • 本题来自WC2014,题目编号为BZOJ3435、洛谷P3920和UOJ55。该问题描述了一棵不断生长的带权树及其节点上小精灵之间的友谊关系,要求实时计算每次新增节点后树上所有可能的朋友对数。 ... [详细]
  • This request pertains to exporting the hosted_zone_id attribute associated with the aws_rds_cluster resource in Terraform configurations. The absence of this attribute can lead to issues when integrating DNS records with Route 53. ... [详细]
  • 本文将详细介绍多个流行的 Android 视频处理开源框架,包括 ijkplayer、FFmpeg、Vitamio、ExoPlayer 等。每个框架都有其独特的优势和应用场景,帮助开发者更高效地进行视频处理和播放。 ... [详细]
author-avatar
命运2502901041_350
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有