#include <iostream>
#include <fstream>
#include <opencv2/core/core.hpp>
#include <string>
#include <opencv2/flann/flann.hpp>
#include <opencv2/features2d/features2d.hpp>
cv::Mat Img1, Img2;
//函数的形参和返回值都不能是IO流对象,而应该是IO流引用(且不能为const)。
//注意这里使用了cv::Mat的引用为形参
//TxtToMat()函数将TXT文件里存储的内容转换成cv::Mat数据结构
void TxtToMat(std::ifstream & infile, cv::Mat & Img);
int main() {
std::ifstream file("gendercenter1_1.txt");
TxtToMat(file, Img1);
Img1.convertTo(Img1, CV_32F);
std::ifstream file1("agecenter1_1.txt");
TxtToMat(file1, Img2);
Img2.convertTo(Img2, CV_32F);
cv::Ptr<cv::DescriptorMatcher> matchers = cv::DescriptorMatcher::create("FlannBased");
//cv::BFMatcher matchers;
//cv::FlannBasedMatcher matchers
C++——将TXT文件存储在cv::Mat数据结构
最新推荐文章于 2024-07-04 09:15:22 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)