cvui使用-从文件夹中读取图片

#include<opencv2/opencv.hpp>
#include<iostream>

#define CVUI_IMPLEMENTATION
#include "cvui/cvui.h"

using namespace cv;
using namespace std;

#define WINDOW_NAME "img"

int main()
{
	const int num = 255;
	char filename[50];

	cv::namedWindow(WINDOW_NAME);
	cvui::init(WINDOW_NAME);
	int count = 0;
	while(true)
	{
		sprintf(filename, "%d.jpg", count);
		Mat img = imread(filename);
		if (cvui::button(img, 0, 0, "add")) 
		{
			count++;
		}
		cvui::printf(img, 10, 30, 0.4, 0xff0000, "add cout: %d", count);
		if (img.empty())
		{
			cout << "no img in file now" << endl;
			destroyAllWindows();
			break;
		}
		cvui::update();
		imshow(WINDOW_NAME, img);
		waitKey(10);
		
	}
	return 0;
}

cvui使用-从文件夹中读取图片

cvui使用-从文件夹中读取图片

点击add的时候会从文件夹中读取一张图片并计数,图片以数字命名。