将cpu的所有核心与opencv imwrite / imread一起使用

时间:2019-07-12 18:37:33

标签: c++ multithreading visual-studio opencv

我正在使用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。是否可以强迫所有内核都使用未读内容?

0 个答案:

没有答案