本文整理汇总了C++中DImage::assemble方法的典型用法代码示例。如果您正苦于以下问题:C++ DImage::assemble方法的具体用法?C++ DImage::assemble怎么用?C++ DImage::assemble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImage
的用法示例。
在下文中一共展示了DImage::assemble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_Seq
int main_Seq(const ZQ_OpticalFlowOptions& opt, const char* in_fold, const char* prefix, const char* suffix, const int image_num, const int base_id,const char* out_fold)
{
if(image_num < 3)
{
printf("error: image num < 3\n");
return EXIT_FAILURE;
}
char buf[2000];
std::vector<DImage> Images;
for(int i = 0;i < image_num;i++)
{
DImage Im;
sprintf_s(buf,"%s\\%s%d.%s",in_fold,prefix,i+base_id,suffix);
bool flag = ZQ_ImageIO::loadImage(Im,buf,0);
if(!flag)
{
printf("fail to load image %s\n",buf);
return EXIT_FAILURE;
}
Images.push_back(Im);
}
double max_rad = 12;
bool user_input = true;
std::vector<DImage> u,v,warpIm;
clock_t start = clock();
switch(opt.methodType)
{
case ZQ_OpticalFlowOptions::METHOD_ONEDIR_INC_L2:
ZQ_OpticalFlow::Coarse2Fine_OneDir_Inc_L2(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_ONEDIR_INC_DL1:
ZQ_OpticalFlow::Coarse2Fine_OneDir_Inc_DL1(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_ONEDIR_DEC_L2:
ZQ_OpticalFlow::Coarse2Fine_OneDir_Dec_L2(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_ONEDIR_DEC_DL1:
ZQ_OpticalFlow::Coarse2Fine_OneDir_Dec_DL1(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_TWODIR_INC_L2:
ZQ_OpticalFlow::Coarse2Fine_TwoDir_Inc_L2(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_TWODIR_INC_DL1:
ZQ_OpticalFlow::Coarse2Fine_TwoDir_Inc_DL1(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_TWODIR_DEC_L2:
ZQ_OpticalFlow::Coarse2Fine_TwoDir_Dec_L2(u,v,warpIm,Images,opt);
break;
case ZQ_OpticalFlowOptions::METHOD_TWODIR_DEC_DL1:
ZQ_OpticalFlow::Coarse2Fine_TwoDir_Dec_DL1(u,v,warpIm,Images,opt);
break;
}
clock_t end = clock();
float total_time = 0.001*(end-start);
for(int i = 0;i < image_num-1;i++)
{
DImage flow;
flow.assemble(u[i],v[i]);
sprintf_s(buf,"%s\\flow%d_%d.di2",out_fold,i+base_id,i+1+base_id);
flow.saveImage(buf);
int wheelSize = 64;
int color_type = 1;
cv::Mat flow_img = ZQ_ImageIO::SaveFlowToColorImage(u[i],v[i],user_input,max_rad,wheelSize,color_type);
sprintf_s(buf,"%s\\flow%d_%d.%s",out_fold,i+base_id,i+1+base_id,suffix);
cv::imwrite(buf,flow_img);
DImage warp,other;
warpIm[i].separate(1,warp,other);
sprintf_s(buf,"%s\\warp%d_%d.%s",out_fold,i+1+base_id,i+base_id,suffix);
ZQ_ImageIO::saveImage(warp,buf);
}
printf("total_time = %f\n", total_time);
return EXIT_SUCCESS;
}
示例2: main_Regular
//.........这里部分代码省略.........
{
u_pData[i] += base_vel_u;
v_pData[i] += base_vel_v;
}
ZQ_PIVSimulator piv_simu(width,height,mvobj);
piv_simu.RandomInit(par_num,u_img,v_img,par_mask);
int frame = 0;
char buf[200];
DImage flow;
DImage cut_u_img(center_width,center_height),cut_v_img(center_width,center_height);
DImage cut_par_img(center_width,center_height);
for(int i = 0;i < skip_frames;i++)
{
printf("skip frame [%3d/%3d]...\n",i,skip_frames);
piv_simu.RunOneFrame(1.0,use_peroid_coord,false);
}
do
{
printf("frame [%3d] ...\n",frame);
if(cut_boarder)
{
piv_simu.ExportVelocity(u_img,v_img);
for(int h = 0; h < center_height;h++)
{
for(int w = 0;w < center_width;w++)
{
cut_u_img.data()[h*center_width+w] = u_img.data()[(h+boarder_size)*width+w+boarder_size];
cut_v_img.data()[h*center_width+w] = v_img.data()[(h+boarder_size)*width+w+boarder_size];
}
}
cv::Mat show_flow_img = ZQ_ImageIO::SaveFlowToColorImage(cut_u_img,cut_v_img,true,12,64,1);
sprintf_s(buf,"%s\\flow_%d.png",out_flow_fold,frame);
cv::imwrite(buf,show_flow_img);
flow.assemble(cut_u_img,cut_v_img);
sprintf_s(buf,"%s\\flow_%d.di2",out_flow_fold,frame);
flow.saveImage(buf);
par_img.reset();
piv_simu.ExportParticleImage(par_img);
for(int h = 0;h < center_height;h++)
{
for(int w = 0;w < center_width;w++)
{
cut_par_img.data()[h*center_width+w] = par_img.data()[(h+boarder_size)*width+w+boarder_size];
}
}
cv::Mat show_par_img = ParImageToIplImage(cut_par_img);
sprintf_s(buf,"%s\\par_%d.png",out_par_fold,frame);
cv::imwrite(buf,show_par_img);
cv::namedWindow("show");
cv::imshow("show", show_par_img);
cv::waitKey(10);
}
else
{
piv_simu.ExportVelocity(u_img,v_img);
cv::Mat show_flow_img = ZQ_ImageIO::SaveFlowToColorImage(u_img,v_img,true,12,64,1);
sprintf_s(buf,"%s\\flow_%d.png",out_flow_fold,frame);
cv::imwrite(buf,show_flow_img);
flow.assemble(u_img,v_img);
sprintf_s(buf,"%s\\flow_%d.di2",out_flow_fold,frame);
flow.saveImage(buf);
par_img.reset();
piv_simu.ExportParticleImage(par_img);
cv::Mat show_par_img = ParImageToIplImage(par_img);
sprintf_s(buf,"%s\\par_%d.png",out_par_fold,frame);
cv::imwrite(buf,show_par_img);
cv::namedWindow("show");
cv::imshow("show", show_par_img);
cv::waitKey(10);
}
piv_simu.RunOneFrame(1.0,use_peroid_coord,true);
frame++;
} while (frame < 400);
if(mvobj)
delete mvobj;
}
示例3: main_Pair
int main_Pair(const ZQ_OpticalFlowOptions& opt, const char* in_fold, const char* prefix, const char* suffix, const int image_num, const int base_id,const char* out_fold)
{
if(image_num < 2)
{
printf("error: image num < 2\n");
return EXIT_FAILURE;
}
char buf[2000];
std::vector<DImage> Images;
for(int i = 0;i < image_num;i++)
{
DImage Im;
sprintf_s(buf,"%s\\%s%d.%s",in_fold,prefix,i+base_id,suffix);
bool flag = ZQ_ImageIO::loadImage(Im,buf,0);
if(!flag)
{
printf("fail to load image %s\n",buf);
return EXIT_FAILURE;
}
Images.push_back(Im);
}
double max_rad = 12;
bool user_input = true;
std::vector<DImage> u(image_num-1),v(image_num-1),warpIm(image_num-1);
ZQ_OpticalFlowOptions opt1 = opt;
opt1.use_omp = false;
double start = omp_get_wtime();
#pragma omp parallel for
for(int i = 0;i < image_num-1;i++)
{
switch(opt.methodType)
{
case ZQ_OpticalFlowOptions::METHOD_HS_L2:
ZQ_OpticalFlow::Coarse2Fine_HS_L2(u[i],v[i],warpIm[i],Images[i],Images[i+1],opt1);
break;
case ZQ_OpticalFlowOptions::METHOD_HS_DL1:
ZQ_OpticalFlow::Coarse2Fine_HS_DL1(u[i],v[i],warpIm[i],Images[i],Images[i+1],opt1);
break;
case ZQ_OpticalFlowOptions::METHOD_HS_L1:
ZQ_OpticalFlow::Coarse2Fine_HS_L1(u[i],v[i],warpIm[i],Images[i],Images[i+1],opt1);
break;
case ZQ_OpticalFlowOptions::METHOD_ADMM_L2:
ZQ_OpticalFlow::Coarse2Fine_ADMM_L2(u[i],v[i],warpIm[i],Images[i],Images[i+1],opt1);
break;
case ZQ_OpticalFlowOptions::METHOD_ADMM_DL1:
ZQ_OpticalFlow::Coarse2Fine_ADMM_DL1(u[i],v[i],warpIm[i],Images[i],Images[i+1],opt1);
break;
}
}
double end = omp_get_wtime();
#pragma omp parallel for
for(int i = 0;i < image_num-1;i++)
{
DImage flow;
flow.assemble(u[i],v[i]);
sprintf_s(buf,"%s\\flow%d_%d.di2",out_fold,i+base_id,i+1+base_id);
flow.saveImage(buf);
int wheelSize = 64;
int color_type = 1;
cv::Mat flow_img = ZQ_ImageIO::SaveFlowToColorImage(u[i],v[i],user_input,max_rad,wheelSize,color_type);
sprintf_s(buf,"%s\\flow%d_%d.%s",out_fold,i+base_id,i+1+base_id,suffix);
cv::imwrite(buf,flow_img);
DImage warp,other;
warpIm[i].separate(1,warp,other);
sprintf_s(buf,"%s\\warp%d_%d.%s",out_fold,i+1+base_id,i+base_id,suffix);
ZQ_ImageIO::saveImage(warp,buf);
}
printf("total_cost = %f \n",(end-start) );
return EXIT_SUCCESS;
}