Skip to content

Commit 27eb5d0

Browse files
author
Alexey Spizhevoy
committed
Added getScale/setScale for image warpers (stitching module)
1 parent 87737c2 commit 27eb5d0

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

modules/stitching/include/opencv2/stitching/detail/warpers.hpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ class CV_EXPORTS RotationWarper
6565
virtual Point warp(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,
6666
Mat &dst) = 0;
6767

68-
// TODO add other backward functions for consistency or move this into a separated interface
6968
virtual void warpBackward(const Mat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,
7069
Size dst_size, Mat &dst) = 0;
7170

7271
virtual Rect warpRoi(Size src_size, const Mat &K, const Mat &R) = 0;
72+
73+
virtual float getScale() const { return 1.f; }
74+
virtual void setScale(float) {}
7375
};
7476

7577

@@ -104,6 +106,9 @@ class CV_EXPORTS RotationWarperBase : public RotationWarper
104106

105107
Rect warpRoi(Size src_size, const Mat &K, const Mat &R);
106108

109+
float getScale() const { return projector_.scale; }
110+
void setScale(float val) { projector_.scale = val; }
111+
107112
protected:
108113

109114
// Detects ROI of the destination image. It's correct for any projection.
@@ -129,8 +134,6 @@ class CV_EXPORTS PlaneWarper : public RotationWarperBase<PlaneProjector>
129134
public:
130135
PlaneWarper(float scale = 1.f) { projector_.scale = scale; }
131136

132-
void setScale(float scale) { projector_.scale = scale; }
133-
134137
Point2f warpPoint(const Point2f &pt, const Mat &K, const Mat &R, const Mat &T);
135138

136139
Rect buildMaps(Size src_size, const Mat &K, const Mat &R, const Mat &T, Mat &xmap, Mat &ymap);
@@ -225,12 +228,12 @@ struct CV_EXPORTS CompressedRectilinearProjector : ProjectorBase
225228
class CV_EXPORTS CompressedRectilinearWarper : public RotationWarperBase<CompressedRectilinearProjector>
226229
{
227230
public:
228-
CompressedRectilinearWarper(float scale, float A = 1, float B = 1)
229-
{
230-
projector_.a = A;
231-
projector_.b = B;
232-
projector_.scale = scale;
233-
}
231+
CompressedRectilinearWarper(float scale, float A = 1, float B = 1)
232+
{
233+
projector_.a = A;
234+
projector_.b = B;
235+
projector_.scale = scale;
236+
}
234237
};
235238

236239

@@ -250,7 +253,7 @@ class CV_EXPORTS CompressedRectilinearPortraitWarper : public RotationWarperBase
250253
{
251254
projector_.a = A;
252255
projector_.b = B;
253-
projector_.scale = scale;
256+
projector_.scale = scale;
254257
}
255258
};
256259

@@ -271,7 +274,7 @@ class CV_EXPORTS PaniniWarper : public RotationWarperBase<PaniniProjector>
271274
{
272275
projector_.a = A;
273276
projector_.b = B;
274-
projector_.scale = scale;
277+
projector_.scale = scale;
275278
}
276279
};
277280

@@ -292,7 +295,7 @@ class CV_EXPORTS PaniniPortraitWarper : public RotationWarperBase<PaniniPortrait
292295
{
293296
projector_.a = A;
294297
projector_.b = B;
295-
projector_.scale = scale;
298+
projector_.scale = scale;
296299
}
297300

298301
};

modules/stitching/include/opencv2/stitching/stitcher.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ class CV_EXPORTS Stitcher
6464
// Creates stitcher with default parameters
6565
static Stitcher createDefault(bool try_use_gpu = false);
6666

67-
Status estimateTransform(InputArray images);
68-
Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois);
69-
70-
Status composePanorama(OutputArray pano);
71-
Status composePanorama(InputArray images, OutputArray pano);
72-
73-
Status stitch(InputArray images, OutputArray pano);
74-
Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);
75-
7667
double registrationResol() const { return registr_resol_; }
7768
void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }
7869

@@ -130,6 +121,19 @@ class CV_EXPORTS Stitcher
130121
const Ptr<detail::Blender> blender() const { return blender_; }
131122
void setBlender(Ptr<detail::Blender> b) { blender_ = b; }
132123

124+
Status estimateTransform(InputArray images);
125+
Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois);
126+
127+
Status composePanorama(OutputArray pano);
128+
Status composePanorama(InputArray images, OutputArray pano);
129+
130+
Status stitch(InputArray images, OutputArray pano);
131+
Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);
132+
133+
std::vector<int> component() const { return indices_; }
134+
std::vector<detail::CameraParams> cameras() const { return cameras_; }
135+
double workScale() const { return work_scale_; }
136+
133137
private:
134138
Stitcher() {}
135139

samples/cpp/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
77
opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
8-
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_videostab)
8+
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_videostab opencv_core_vision_api)
99

1010
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
1111

12+
add_definitions(-DENABLE_LOG)
13+
1214

1315
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
14-
project(cpp_samples)
16+
project(core_vision_api_samples)
1517

1618
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
1719
ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})

0 commit comments

Comments
 (0)