前提#1:我已经解决了错误,但我没有深入理解编译错误的原因.
前提#2:该程序的目标是通过多线程进程将图像复制到另一个图像中.也许存在更好的方法,但这不是问题的焦点话题(见前提#1).
我用OpenCV 3.1库编写了一个简单的程序,将图像复制到另一个图像中.它利用了更多线程的CPU的所有核心.
代码是:
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <thread>
using namespace cv;
using namespace std;
#define IMG_PATH "..\\img\\50a.png"
void copy_image(const Mat& input, Mat& output, int row_offset, int skip_row)
{
cout << row_offset;
Size size = input.size();
for (int r = row_offset; r < size.height; r += skip_row)
{
for (int c = 0; c < size.width; c++)
{
output.at<Vec3b>(r, c) = input.at<Vec3b>(r, c);
}
}
}
int main()
{
Mat input_img = …Run Code Online (Sandbox Code Playgroud)