【opencv450-目标检测】coco数据集yolo4-tiny预训练模型加载测试

【opencv450-目标检测】coco数据集yolo4-tiny预训练模型加载测试_第1张图片

【opencv450-目标检测】coco数据集yolo4-tiny预训练模型加载测试_第2张图片

 【opencv450-目标检测】coco数据集yolo4-tiny预训练模型加载测试_第3张图片

 

识别效果

控制台主程序:

#include "Detection.h"
#include 

using namespace std;
using namespace cv;
using namespace dnn;

void TestDetection()
{
	std::vector files;
	glob("./data", files);

	for (size_t i = 0; i < files.size(); i++)
	{
		Mat img = imread(files[i]);
		cout << "width: " << img.cols << endl;
		cout << "height: " << img.rows << endl;
		Detection detection = Detection();
		detection.Initialize(img.cols, img.rows);
		detection.Detecting(img);
		string save_path = files[i].substr(0, files[i].rfind(".")) + "result.jpg";
		imwrite(save_path, detection.GetFrame());
		//detection.~Detection();
	}
	//waitKey();
	return;
	//string image_path = "./data/1.bmp";
	//string save_path = "./data/1.jpg";
	//string image_path = "./data/test.jpg";
	//string save_path = "./data/testresult.jpg";
	//Mat img = imread(image_path);
	//cout << "width: " << img.cols << endl;
	//cout << "height: " << img.rows << endl;

	/*Detection detection = Detection();
	detection.Initialize(img.cols, img.rows);
	detection.Detecting(img);
	imwrite(save_path, detection.GetFrame());*/
	//return;
}

int main()
{
	TestDetection();
	return 0;
}

【opencv450-目标检测】coco数据集yolo4-tiny预训练模型加载测试_第4张图片

 

你可能感兴趣的:(opencv,C++,目标检测,人工智能,计算机视觉)