mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
stitching: extend logging
This commit is contained in:
parent
a7f69a37e3
commit
c22d92c1cb
@ -248,7 +248,11 @@ void MultiBandBlender::prepare(Rect dst_roi)
|
|||||||
|
|
||||||
void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||||
{
|
{
|
||||||
Mat img = _img.getMat();
|
#if ENABLE_LOG
|
||||||
|
int64 t = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UMat img = _img.getUMat();
|
||||||
CV_Assert(img.type() == CV_16SC3 || img.type() == CV_8UC3);
|
CV_Assert(img.type() == CV_16SC3 || img.type() == CV_8UC3);
|
||||||
CV_Assert(mask.type() == CV_8U);
|
CV_Assert(mask.type() == CV_8U);
|
||||||
|
|
||||||
@ -286,12 +290,22 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
|||||||
UMat img_with_border;
|
UMat img_with_border;
|
||||||
copyMakeBorder(_img, img_with_border, top, bottom, left, right,
|
copyMakeBorder(_img, img_with_border, top, bottom, left, right,
|
||||||
BORDER_REFLECT);
|
BORDER_REFLECT);
|
||||||
|
LOGLN(" Add border to the source image, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
t = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<UMat> src_pyr_laplace;
|
std::vector<UMat> src_pyr_laplace;
|
||||||
if (can_use_gpu_ && img_with_border.depth() == CV_16S)
|
if (can_use_gpu_ && img_with_border.depth() == CV_16S)
|
||||||
createLaplacePyrGpu(img_with_border, num_bands_, src_pyr_laplace);
|
createLaplacePyrGpu(img_with_border, num_bands_, src_pyr_laplace);
|
||||||
else
|
else
|
||||||
createLaplacePyr(img_with_border, num_bands_, src_pyr_laplace);
|
createLaplacePyr(img_with_border, num_bands_, src_pyr_laplace);
|
||||||
|
|
||||||
|
LOGLN(" Create the source image Laplacian pyramid, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
t = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create the weight map Gaussian pyramid
|
// Create the weight map Gaussian pyramid
|
||||||
UMat weight_map;
|
UMat weight_map;
|
||||||
std::vector<UMat> weight_pyr_gauss(num_bands_ + 1);
|
std::vector<UMat> weight_pyr_gauss(num_bands_ + 1);
|
||||||
@ -313,6 +327,11 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
|||||||
for (int i = 0; i < num_bands_; ++i)
|
for (int i = 0; i < num_bands_; ++i)
|
||||||
pyrDown(weight_pyr_gauss[i], weight_pyr_gauss[i + 1]);
|
pyrDown(weight_pyr_gauss[i], weight_pyr_gauss[i + 1]);
|
||||||
|
|
||||||
|
LOGLN(" Create the weight map Gaussian pyramid, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
t = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
int y_tl = tl_new.y - dst_roi_.y;
|
int y_tl = tl_new.y - dst_roi_.y;
|
||||||
int y_br = br_new.y - dst_roi_.y;
|
int y_br = br_new.y - dst_roi_.y;
|
||||||
int x_tl = tl_new.x - dst_roi_.x;
|
int x_tl = tl_new.x - dst_roi_.x;
|
||||||
@ -348,7 +367,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
|||||||
x_br /= 2; y_br /= 2;
|
x_br /= 2; y_br /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else// weight_type_ == CV_16S
|
else // weight_type_ == CV_16S
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= num_bands_; ++i)
|
for (int i = 0; i <= num_bands_; ++i)
|
||||||
{
|
{
|
||||||
@ -377,6 +396,8 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
|||||||
x_br /= 2; y_br /= 2;
|
x_br /= 2; y_br /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGLN(" Add weighted layer of the source image to the final Laplacian pyramid layer, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,6 +220,9 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
|||||||
for (size_t img_idx = 0; img_idx < imgs_.size(); ++img_idx)
|
for (size_t img_idx = 0; img_idx < imgs_.size(); ++img_idx)
|
||||||
{
|
{
|
||||||
LOGLN("Compositing image #" << indices_[img_idx] + 1);
|
LOGLN("Compositing image #" << indices_[img_idx] + 1);
|
||||||
|
#if ENABLE_LOG
|
||||||
|
int64 compositing_t = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Read image and resize it if necessary
|
// Read image and resize it if necessary
|
||||||
full_img = imgs_[img_idx];
|
full_img = imgs_[img_idx];
|
||||||
@ -261,25 +264,48 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (std::abs(compose_scale - 1) > 1e-1)
|
if (std::abs(compose_scale - 1) > 1e-1)
|
||||||
|
{
|
||||||
|
#if ENABLE_LOG
|
||||||
|
int64 resize_t = getTickCount();
|
||||||
|
#endif
|
||||||
resize(full_img, img, Size(), compose_scale, compose_scale);
|
resize(full_img, img, Size(), compose_scale, compose_scale);
|
||||||
|
LOGLN(" resize time: " << ((getTickCount() - resize_t) / getTickFrequency()) << " sec");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
img = full_img;
|
img = full_img;
|
||||||
full_img.release();
|
full_img.release();
|
||||||
Size img_size = img.size();
|
Size img_size = img.size();
|
||||||
|
|
||||||
|
LOGLN(" after resize time: " << ((getTickCount() - compositing_t) / getTickFrequency()) << " sec");
|
||||||
|
|
||||||
Mat K;
|
Mat K;
|
||||||
cameras_[img_idx].K().convertTo(K, CV_32F);
|
cameras_[img_idx].K().convertTo(K, CV_32F);
|
||||||
|
|
||||||
|
#if ENABLE_LOG
|
||||||
|
int64 pt = getTickCount();
|
||||||
|
#endif
|
||||||
// Warp the current image
|
// Warp the current image
|
||||||
w->warp(img, K, cameras_[img_idx].R, INTER_LINEAR, BORDER_CONSTANT, img_warped);
|
w->warp(img, K, cameras_[img_idx].R, INTER_LINEAR, BORDER_CONSTANT, img_warped);
|
||||||
|
LOGLN(" warp the current image: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
pt = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Warp the current image mask
|
// Warp the current image mask
|
||||||
mask.create(img_size, CV_8U);
|
mask.create(img_size, CV_8U);
|
||||||
mask.setTo(Scalar::all(255));
|
mask.setTo(Scalar::all(255));
|
||||||
w->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped);
|
w->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped);
|
||||||
|
LOGLN(" warp the current image mask: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
pt = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Compensate exposure
|
// Compensate exposure
|
||||||
exposure_comp_->apply((int)img_idx, corners[img_idx], img_warped, mask_warped);
|
exposure_comp_->apply((int)img_idx, corners[img_idx], img_warped, mask_warped);
|
||||||
|
LOGLN(" compensate exposure: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
pt = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
img_warped.convertTo(img_warped_s, CV_16S);
|
img_warped.convertTo(img_warped_s, CV_16S);
|
||||||
img_warped.release();
|
img_warped.release();
|
||||||
@ -292,18 +318,35 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
|||||||
|
|
||||||
bitwise_and(seam_mask, mask_warped, mask_warped);
|
bitwise_and(seam_mask, mask_warped, mask_warped);
|
||||||
|
|
||||||
|
LOGLN(" other: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
pt = getTickCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!is_blender_prepared)
|
if (!is_blender_prepared)
|
||||||
{
|
{
|
||||||
blender_->prepare(corners, sizes);
|
blender_->prepare(corners, sizes);
|
||||||
is_blender_prepared = true;
|
is_blender_prepared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGLN(" other2: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||||
|
|
||||||
|
LOGLN(" feed...");
|
||||||
|
#if ENABLE_LOG
|
||||||
|
int64 feed_t = getTickCount();
|
||||||
|
#endif
|
||||||
// Blend the current image
|
// Blend the current image
|
||||||
blender_->feed(img_warped_s, mask_warped, corners[img_idx]);
|
blender_->feed(img_warped_s, mask_warped, corners[img_idx]);
|
||||||
|
LOGLN(" feed time: " << ((getTickCount() - feed_t) / getTickFrequency()) << " sec");
|
||||||
|
LOGLN("Compositing ## time: " << ((getTickCount() - compositing_t) / getTickFrequency()) << " sec");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_LOG
|
||||||
|
int64 blend_t = getTickCount();
|
||||||
|
#endif
|
||||||
UMat result, result_mask;
|
UMat result, result_mask;
|
||||||
blender_->blend(result, result_mask);
|
blender_->blend(result, result_mask);
|
||||||
|
LOGLN("blend time: " << ((getTickCount() - blend_t) / getTickFrequency()) << " sec");
|
||||||
|
|
||||||
LOGLN("Compositing, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
LOGLN("Compositing, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user