ORB提取特征点学习

提取特征点的流程

1.关键点的提取

用FAST算法提取出FSAT特征点,

2.关键点的描述

ORB选择用BRIEF作为特征描述方法,

代码流程:

1.入读图片文件

2.初始化

3.检测FAST特征点 detector->detect()

4.根据FAST特征点计算BRIEF描述子 descriptor->compute()

5.绘制出特征点

6.输出特征点坐标

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include "opencv2/imgcodecs/legacy/constants_c.h"
#include <opencv2/highgui/highgui.hpp>
#include <chrono>

using namespace std;
using namespace cv;

int main()
{
	//-- 读取图像
	Mat img_1 = imread("F:/杂七杂八/img/11.jpg", CV_LOAD_IMAGE_COLOR);
	if (img_1.empty()) {
		printf("could not load image...\n");
		return -1;
	}

	//-- 初始化
	std::vector<KeyPoint> keypoints_1;
	Mat descriptors_1;
	Ptr<FeatureDetector> detector = ORB::create();
	Ptr<DescriptorExtractor> descriptor = ORB::create();


	//-- 第一步:检测 Oriented FAST 角点位置
	detector->detect(img_1, keypoints_1);


	//-- 第二步:根据角点位置计算 BRIEF 描述子
	descriptor->compute(img_1, keypoints_1, descriptors_1);

	Mat outimg1;
	drawKeypoints(img_1, keypoints_1, outimg1, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
	imshow("ORB特征点img1", outimg1);

	//输出img1的特征点坐标
	for (int i = 0; i < keypoints_1.size(); i++)
	{
		cout << "img1第" << i + 1 << "个特征点的坐标:";
		cout << "x:" << keypoints_1.at(i).pt.x << " ";
		cout << "y:" << keypoints_1.at(i).pt.y << endl;
	}

	waitKey(0);
	return 0;
}

 结果:

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值