I am using OpenCV 3.1 w/ contrib in C++. Trying to recreate the program outlined within the "Learning Image Processing with OpenCV pg 152-161. I copied the code line by line but am getting this resulting error.
//-Create a blender-//S10
Ptr<Blender> blender = Blender::createDefault(blend_type,false);
Size dst_sz = resultRoi(corners, sizes).size();
float blend_width = sqrt(static_cast<float>(dst_sz.area()))* blend_strength / 100.f;
if(blend_width < 1.f){
blender = Blender::createDefault(Blender::NO,false);
}
else if(blend_type == Blender::MULTI_BAND){
MultiBandBlender* mb = dynamic_cast<MultiBandBlender*>(blender.get());
mb->setNumBands(static_cast<int>(ceil(log(blend_width)/log(2.))-1.));
cout << "Multi-band blender, number of bands: " << mb->numBands() << endl;
}
else if(blend_type == Blender::FEATHER){
FeatherBlender* fb = dynamic_cast<FeatherBlender*>(blender.get());
fb->setSharpness(1.f/blend_width);
cout << "Feather blender, sharpness: " << fb->sharpness() << endl;
}
blender->prepare(corners,sizes);
//-Compositing step-//S11
cout << "Composting..." << endl;
t = getTickCount();
Mat img_warped, img_warped_s;
Mat dilated_mask, seam_mask, mask, mask_warped;
for(int img_idx = 0; img_idx < num_images; img_idx++){
cout << "Compositing image #" << indices[img_idx]+1 << endl;
//-Read image and resize it if necessary-//S11.1
full_img = imread(img_names[img_idx]);
if(abs(scale - 1)> 1e-1){
resize(full_img, img, Size(),scale,scale);
}
else{
img = full_img;
}
full_img.release();
Size img_size = img.size();
Mat K;
cameras[img_idx].K().convertTo(K, CV_32F);
//-Warp the current image-//S11.2
warper->warp(img,K,cameras[img_idx].R,INTER_LINEAR,BORDER_REFLECT,img_warped);
//Warp the current image mask
mask.create(img_size, CV_8U);
mask.setTo(Scalar::all(255));
warper->warp(mask,K,cameras[img_idx].R,INTER_NEAREST,BORDER_CONSTANT,mask_warped);
//-Compenstae exposure error step-//S11.3
compensator->apply(img_idx,corners[img_idx],img_warped,mask_warped);
img_warped.convertTo(img_warped, CV_16S);
img_warped.release();
img.release();
mask.release();
dilate(masks_warped[img_idx], dilated_mask, Mat());
resize(dilated_mask, seam_mask, mask_warped.size());
mask_warped = seam_mask & mask_warped;
//-Blending images step-//S11.4
blender->feed(img_warped_s,mask_warped,corners[img_idx]);
}
The issue is occurring on the final line saying:
error: (-215) img.type() == CV_16SC3 || img.type() == CV_8UC3 in function feed
AS the blender::feed function tasks in an img, mask, and tl I assumed the issue was with the img img_warped
variable and tried converting it to type CV_16SC3 and CV_8UC3 but didn't work. Any help is appreciated.