我正在用OpenCV和C++读取JPG文件的文件夹,并把它们作为PNG文件写入另一个文件夹。这是一个极简主义的例子:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string>
#include <iostream>
#include <fstream>
#include <filesystem>
using namespace cv;
using namespace std;
namespace fs = std::filesystem;
int main(){
for (auto& p : fs::recursive_directory_iterator("C:/Users/steve/Project/roof-big-data/labeled3/ALL")) {
cout << p.path()<<endl;
imread(p.path().string());
}
}
我正在使用MSVC 2019来构建此代码,但它只使用了我的25%的CPU,如任务管理器中所示。是否可以强制imread使用所有核心?