Added debug function to project back from pano to original image

This commit is contained in:
Andrey Kamaev 2011-09-22 13:58:07 +00:00
parent 39268013d5
commit 7ca53cfcd4
2 changed files with 33 additions and 0 deletions

View File

@ -58,6 +58,8 @@ public:
virtual ~Warper() {}
virtual Point warp(const Mat &src, const Mat &K, const Mat &R, Mat &dst,
int interp_mode, int border_mode) = 0;
virtual void warpBackward(const Mat &src, const Mat &K, const Mat &R, Mat &dst, Size dstSize,
int interp_mode, int border_mode) = 0;
virtual Point warp(const Mat &src, const Mat &K, const Mat &R, const Mat &T, Mat &dst,
int interp_mode, int border_mode) = 0;
virtual Rect warpRoi(const Size &sz, const Mat &K, const Mat &R) = 0;
@ -86,6 +88,8 @@ class CV_EXPORTS WarperBase : public Warper
public:
Point warp(const Mat &src, const Mat &K, const Mat &R, Mat &dst,
int interp_mode, int border_mode);
void warpBackward(const Mat &src, const Mat &K, const Mat &R, Mat &dst, Size dstSize,
int interp_mode, int border_mode);
Point warp(const Mat &src, const Mat &K, const Mat &R, const Mat &T, Mat &dst,
int interp_mode, int border_mode);
Rect warpRoi(const Size &sz, const Mat &K, const Mat &R);

View File

@ -79,6 +79,35 @@ Point WarperBase<P>::warp(const Mat &src, const Mat &K, const Mat &R, Mat &dst,
return dst_tl;
}
template <class P>
void WarperBase<P>::warpBackward(const Mat &src, const Mat &K, const Mat &R, Mat &dst, Size dstSize,
int interp_mode, int border_mode)
{
src_size_ = dstSize;
projector_.setCameraParams(K, R);
Point src_tl, src_br;
detectResultRoi(src_tl, src_br);
CV_Assert(src_br.x - src_tl.x + 1 == src.cols && src_br.y - src_tl.y + 1 == src.rows);
Mat xmap(dstSize, CV_32F);
Mat ymap(dstSize, CV_32F);
float u, v;
for (int y = 0; y < dstSize.height; ++y)
{
for (int x = 0; x < dstSize.width; ++x)
{
projector_.mapForward(static_cast<float>(x), static_cast<float>(y), u, v);
xmap.at<float>(y, x) = u - src_tl.x;
ymap.at<float>(y, x) = v - src_tl.y;
}
}
dst.create(dstSize, src.type());
remap(src, dst, xmap, ymap, interp_mode, border_mode);
}
template <class P>
Point WarperBase<P>::warp(const Mat &/*src*/, const Mat &/*K*/, const Mat &/*R*/, const Mat &/*T*/, Mat &/*dst*/,