template <class T>
class RestoreC1h0//构造一个供parallel_for使用的循环结构体
{
public:
T* pdst ;
T* psrc ;
T* proi;
int dwidth ;
int swidth ;
int rwidth ;
int dheight;
int h0 ;
int hs ;
vector<SciRun> *Run;
void operator()(const blocked_range<int>& range) const
{
for (int i = range.begin(); i < range.end(); i++)
{
int data_o = i*dwidth;
int data_p = i*swidth;
for (int j = 0; j < dwidth; j++)
{
pdst[data_o + j] = psrc[data_p + j];
}
}
}
};
/*************************************************************************************/
void RunRestoreImageC1(vector<SciRun> &Run, cv::Mat &src, cv::Mat &roi, cv::Mat *dst, int ROITopLeftX, int ROITopLeftY)
{
T* pdst = (T*)(dst->data);
T* psrc = (T*)(src.data);
T* proi = (T*)(roi.data);
int dwidth = dst->cols;
int swidth = src.cols;
int rwidth = roi.cols;
int dheight = dst->rows;
int h0 = Run[0][0];
int hs = Run[Run.size() - 1][0];
omp_set_num_threads(m_Device.TBBNum);
#pragma omp parallel for
// for (int i = 0; i < h0; i++)
// {
// int data_o = i*dwidth;
// int data_p = i*swidth;
// for (int j = 0; j < dwidth; j++)
// {
// pdst[data_o + j] = psrc[data_p + j];
// }
// }
#pragma omp parallel for
// for (int i = 0; i < Run.size(); i++)
// {
// int data_o = Run[i][0] * dwidth;
// int data_p = (Run[i][0] - ROITopLeftY) * rwidth - ROITopLeftX;
// for (int j = 0; j < Run[i][1]; j++)
// {
// pdst[data_o + j] = psrc[data_o + j];
// }
// for (int j = Run[i][1]; j <= Run[i][2]; j++)
// {
// pdst[data_o + j] = proi[data_p + j];
// }
// for (int j = Run[i][2] + 1; j < dwidth; j++)
// {
// pdst[data_o + j] = psrc[data_o + j];
// }
// }
#pragma omp parallel for
// for (int i = hs + 1; i < dheight; i++)
// {
// int data_o = i*dwidth;
// int data_p = i*swidth;
// for (int j = 0; j < dwidth; j++)
// {
// pdst[data_o + j] = psrc[data_p + j];
// }
// }
//m_Device.TBBNum = 1;
RestoreC1h0<T> restorec1h0;
restorec1h0.pdst = pdst;
restorec1h0.psrc = psrc;
restorec1h0.proi = proi;
restorec1h0.dwidth = dwidth;
restorec1h0.swidth = swidth;
restorec1h0.dheight = dheight;
restorec1h0.h0 = h0;
restorec1h0.hs = hs;
restorec1h0.Run = &Run;
if (m_Device.TBBNum > 0)
parallel_for(blocked_range<int>(0, h0, (h0) / m_Device.TBBNum), restorec1h0);
else
parallel_for(blocked_range<int>(0, h0), restorec1h0, auto_partitioner());