};\r
\r
\r
-#ifndef ANDROID\r
-class CV_EXPORTS PlaneWarperGpu : public PlaneWarper\r
-{\r
-public:\r
- PlaneWarperGpu(float scale = 1.f) : PlaneWarper(scale) {}\r
-\r
- Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst);\r
-\r
- Point warp(const Mat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,\r
- Mat &dst);\r
-\r
-private:\r
- gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;\r
-};\r
-#endif\r
-\r
-\r
struct CV_EXPORTS SphericalProjector : ProjectorBase\r
{\r
void mapForward(float x, float y, float &u, float &v);\r
};\r
\r
\r
-#ifndef ANDROID\r
-class CV_EXPORTS SphericalWarperGpu : public SphericalWarper\r
-{\r
-public:\r
- SphericalWarperGpu(float scale) : SphericalWarper(scale) {}\r
-\r
- Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst);\r
-\r
-private:\r
- gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;\r
-};\r
-#endif\r
-\r
-\r
struct CV_EXPORTS CylindricalProjector : ProjectorBase\r
{\r
void mapForward(float x, float y, float &u, float &v);\r
\r
\r
#ifndef ANDROID\r
+class CV_EXPORTS PlaneWarperGpu : public PlaneWarper\r
+{\r
+public:\r
+ PlaneWarperGpu(float scale = 1.f) : PlaneWarper(scale) {}\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, Mat &xmap, Mat &ymap)\r
+ {\r
+ Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);\r
+ d_xmap_.download(xmap);\r
+ d_ymap_.download(ymap);\r
+ return result;\r
+ }\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, const Mat &T, Mat &xmap, Mat &ymap)\r
+ {\r
+ Rect result = buildMaps(src_size, K, R, T, d_xmap_, d_ymap_);\r
+ d_xmap_.download(xmap);\r
+ d_ymap_.download(ymap);\r
+ return result;\r
+ }\r
+\r
+ Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ Mat &dst)\r
+ {\r
+ d_src_.upload(src);\r
+ Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);\r
+ d_dst_.download(dst);\r
+ return result;\r
+ }\r
+\r
+ Point warp(const Mat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,\r
+ Mat &dst)\r
+ {\r
+ d_src_.upload(src);\r
+ Point result = warp(d_src_, K, R, T, interp_mode, border_mode, d_dst_);\r
+ d_dst_.download(dst);\r
+ return result;\r
+ }\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap);\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, const Mat &T, gpu::GpuMat &xmap, gpu::GpuMat &ymap);\r
+\r
+ Point warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst);\r
+\r
+ Point warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst);\r
+\r
+private:\r
+ gpu::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_;\r
+};\r
+\r
+\r
+class CV_EXPORTS SphericalWarperGpu : public SphericalWarper\r
+{\r
+public:\r
+ SphericalWarperGpu(float scale) : SphericalWarper(scale) {}\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, Mat &xmap, Mat &ymap)\r
+ {\r
+ Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);\r
+ d_xmap_.download(xmap);\r
+ d_ymap_.download(ymap);\r
+ return result;\r
+ }\r
+\r
+ Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ Mat &dst)\r
+ {\r
+ d_src_.upload(src);\r
+ Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);\r
+ d_dst_.download(dst);\r
+ return result;\r
+ }\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap);\r
+\r
+ Point warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst);\r
+\r
+private:\r
+ gpu::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_;\r
+};\r
+\r
+\r
class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper\r
{\r
public:\r
CylindricalWarperGpu(float scale) : CylindricalWarper(scale) {}\r
\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, Mat &xmap, Mat &ymap)\r
+ {\r
+ Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);\r
+ d_xmap_.download(xmap);\r
+ d_ymap_.download(ymap);\r
+ return result;\r
+ }\r
+\r
Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst);\r
+ Mat &dst)\r
+ {\r
+ d_src_.upload(src);\r
+ Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);\r
+ d_dst_.download(dst);\r
+ return result;\r
+ }\r
+\r
+ Rect buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap);\r
+\r
+ Point warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst);\r
\r
private:\r
- gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;\r
+ gpu::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_;\r
};\r
#endif\r
\r
}\r
\r
\r
-#ifndef ANDROID\r
-Point PlaneWarperGpu::warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst)\r
-{\r
- return warp(src, K, R, Mat::zeros(3, 1, CV_32F), interp_mode, border_mode, dst);\r
-}\r
-\r
-\r
-Point PlaneWarperGpu::warp(const Mat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,\r
- Mat &dst)\r
-{\r
- projector_.setCameraParams(K, R, T);\r
-\r
- Point dst_tl, dst_br;\r
- detectResultRoi(src.size(), dst_tl, dst_br);\r
-\r
- gpu::buildWarpPlaneMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),\r
- K, R, projector_.scale, d_xmap_, d_ymap_);\r
-\r
- gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);\r
- d_src_.upload(src);\r
-\r
- gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);\r
-\r
- gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);\r
-\r
- d_dst_.download(dst);\r
-\r
- return dst_tl;\r
-}\r
-#endif\r
-\r
-\r
void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)\r
{\r
detectResultRoiByBorder(src_size, dst_tl, dst_br);\r
\r
\r
#ifndef ANDROID\r
-Point SphericalWarperGpu::warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst)\r
+Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)\r
{\r
- projector_.setCameraParams(K, R);\r
+ return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);\r
+}\r
\r
- Point dst_tl, dst_br;\r
- detectResultRoi(src.size(), dst_tl, dst_br);\r
+Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, const Mat &T, gpu::GpuMat &xmap, gpu::GpuMat &ymap)\r
+{\r
+ projector_.setCameraParams(K, R, T);\r
\r
- gpu::buildWarpSphericalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),\r
- K, R, projector_.scale, d_xmap_, d_ymap_);\r
+ Point dst_tl, dst_br;\r
+ detectResultRoi(src_size, dst_tl, dst_br);\r
\r
- gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);\r
- d_src_.upload(src);\r
+ gpu::buildWarpPlaneMaps(src_size, Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),\r
+ K, R, projector_.scale, xmap, ymap);\r
\r
- gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);\r
+ return Rect(dst_tl, dst_br);\r
+}\r
\r
- gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);\r
+Point PlaneWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst)\r
+{\r
+ return warp(src, K, R, Mat::zeros(3, 1, CV_32F), interp_mode, border_mode, dst);\r
+}\r
\r
- d_dst_.download(dst);\r
\r
- return dst_tl;\r
+Point PlaneWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst)\r
+{\r
+ Rect dst_roi = buildMaps(src.size(), K, R, T, d_xmap_, d_ymap_);\r
+ dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());\r
+ gpu::remap(src, dst, d_xmap_, d_ymap_, interp_mode, border_mode);\r
+ return dst_roi.tl();\r
}\r
\r
\r
-Point CylindricalWarperGpu::warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
- Mat &dst)\r
+Rect SphericalWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)\r
{\r
projector_.setCameraParams(K, R);\r
\r
Point dst_tl, dst_br;\r
- detectResultRoi(src.size(), dst_tl, dst_br);\r
+ detectResultRoi(src_size, dst_tl, dst_br);\r
+\r
+ gpu::buildWarpSphericalMaps(src_size, Rect(dst_tl, Point(dst_br.x + 1, dst_br.y + 1)),\r
+ K, R, projector_.scale, xmap, ymap);\r
+\r
+ return Rect(dst_tl, dst_br);\r
+}\r
+\r
+\r
+Point SphericalWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst)\r
+{\r
+ Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_);\r
+ dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());\r
+ gpu::remap(src, dst, d_xmap_, d_ymap_, interp_mode, border_mode);\r
+ return dst_roi.tl();\r
+}\r
\r
- gpu::buildWarpCylindricalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),\r
- K, R, projector_.scale, d_xmap_, d_ymap_);\r
\r
- gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);\r
- d_src_.upload(src);\r
+Rect CylindricalWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)\r
+{\r
+ projector_.setCameraParams(K, R);\r
+\r
+ Point dst_tl, dst_br;\r
+ detectResultRoi(src_size, dst_tl, dst_br);\r
\r
- gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);\r
+ gpu::buildWarpCylindricalMaps(src_size, Rect(dst_tl, Point(dst_br.x + 1, dst_br.y + 1)),\r
+ K, R, projector_.scale, xmap, ymap);\r
\r
- gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);\r
+ return Rect(dst_tl, dst_br);\r
+}\r
\r
- d_dst_.download(dst);\r
\r
- return dst_tl;\r
+Point CylindricalWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,\r
+ gpu::GpuMat &dst)\r
+{\r
+ Rect dst_roi = buildMaps(src.size(), K, R, d_xmap_, d_ymap_);\r
+ dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type());\r
+ gpu::remap(src, dst, d_xmap_, d_ymap_, interp_mode, border_mode);\r
+ return dst_roi.tl();\r
}\r
#endif\r
\r