#include<iostream>
#include<fstream>
#include<opencv2/opencv.hpp>
#include<io.h> //api和结构体
#include<string>
using namespace std;
using namespace cv;
void readTestImg(const cv::String& imgpath,int num)
{
cv::String train_path = "D:/code/cv/课程数据集/手写数字/训练集";
ostringstream newos;
newos << num;
train_path = train_path + "/" + newos.str() + "_train.txt";
ifstream myfile(train_path, ios::in);
string temp;
string res;
while (getline(myfile, temp)) {
res += temp;
res += '\n';
}
//cout << res;
myfile.close();
//1-125
//一些比较
int faslenums = 0, truenums = 0;
double sums = 0;
for (int label = 1; label < 126; label++)
{
cv::String path;
cv::Mat img;
ostringstream os; //构造一个输出字符串流,流内容为空
os << label;
path = imgpath + "/"+os.str()+".bmp";
os.clear();
//cout <<"图片路径: "+path << endl;
img = cv::imread(path);
cvtColor(img, img, COLOR_BGR2GRAY
C++实现基于模板匹配的手写数字识别
于 2022-05-13 17:29:09 首次发布

最低0.47元/天 解锁文章
6152

被折叠的 条评论
为什么被折叠?



