Skip to content

Commit cb08ac6

Browse files
authored
Merge pull request #3734 from asmorkalov:as/std_move_warning
Fixed Wredundant-move produced by GCC 13.2 (Ubuntu 24.04). #3734 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent 6b1faf0 commit cb08ac6

File tree

10 files changed

+87
-86
lines changed

10 files changed

+87
-86
lines changed

modules/face/src/facemarkLBF.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -661,24 +661,22 @@ FacemarkLBFImpl::BBox::BBox(double _x, double _y, double w, double h) {
661661

662662
// Project absolute shape to relative shape binding to this bbox
663663
Mat FacemarkLBFImpl::BBox::project(const Mat &shape) const {
664-
Mat_<double> res(shape.rows, shape.cols);
665-
const Mat_<double> &shape_ = (Mat_<double>)shape;
664+
Mat res(shape.rows, shape.cols, CV_64FC1);
666665
for (int i = 0; i < shape.rows; i++) {
667-
res(i, 0) = (shape_(i, 0) - x_center) / x_scale;
668-
res(i, 1) = (shape_(i, 1) - y_center) / y_scale;
666+
res.at<double>(i, 0) = (shape.at<double>(i, 0) - x_center) / x_scale;
667+
res.at<double>(i, 1) = (shape.at<double>(i, 1) - y_center) / y_scale;
669668
}
670-
return std::move(res);
669+
return res;
671670
}
672671

673672
// Project relative shape to absolute shape binding to this bbox
674673
Mat FacemarkLBFImpl::BBox::reproject(const Mat &shape) const {
675-
Mat_<double> res(shape.rows, shape.cols);
676-
const Mat_<double> &shape_ = (Mat_<double>)shape;
674+
Mat res(shape.rows, shape.cols, CV_64FC1);
677675
for (int i = 0; i < shape.rows; i++) {
678-
res(i, 0) = shape_(i, 0)*x_scale + x_center;
679-
res(i, 1) = shape_(i, 1)*y_scale + y_center;
676+
res.at<double>(i, 0) = shape.at<double>(i, 0)*x_scale + x_center;
677+
res.at<double>(i, 1) = shape.at<double>(i, 1)*y_scale + y_center;
680678
}
681-
return std::move(res);
679+
return res;
682680
}
683681

684682
Mat FacemarkLBFImpl::getMeanShape(std::vector<Mat> &gt_shapes, std::vector<BBox> &bboxes) {
@@ -997,7 +995,7 @@ void FacemarkLBFImpl::RandomForest::train(std::vector<Mat> &imgs, std::vector<Ma
997995
}
998996

999997
Mat FacemarkLBFImpl::RandomForest::generateLBF(Mat &img, Mat &current_shape, BBox &bbox, Mat &mean_shape) {
1000-
Mat_<int> lbf_feat(1, landmark_n*trees_n);
998+
Mat lbf_feat(1, landmark_n*trees_n, CV_32SC1);
1001999
double scale;
10021000
Mat_<double> rotate;
10031001
calcSimilarityTransform(bbox.project(current_shape), mean_shape, scale, rotate);
@@ -1036,10 +1034,10 @@ Mat FacemarkLBFImpl::RandomForest::generateLBF(Mat &img, Mat &current_shape, BBo
10361034
idx = 2 * idx + 1;
10371035
}
10381036
}
1039-
lbf_feat(i*trees_n + j) = (i*trees_n + j)*base + code;
1037+
lbf_feat.at<int>(i*trees_n + j) = (i*trees_n + j)*base + code;
10401038
}
10411039
}
1042-
return std::move(lbf_feat);
1040+
return lbf_feat;
10431041
}
10441042

10451043
void FacemarkLBFImpl::RandomForest::write(FileStorage fs, int k) {
@@ -1365,7 +1363,7 @@ Mat FacemarkLBFImpl::Regressor::supportVectorRegression(
13651363

13661364
Mat FacemarkLBFImpl::Regressor::globalRegressionPredict(const Mat &lbf, int stage) {
13671365
const Mat_<double> &weight = (Mat_<double>)gl_regression_weights[stage];
1368-
Mat_<double> delta_shape(weight.rows / 2, 2);
1366+
Mat delta_shape(weight.rows / 2, 2, CV_64FC1);
13691367
const double *w_ptr = NULL;
13701368
const int *lbf_ptr = lbf.ptr<int>(0);
13711369

@@ -1374,14 +1372,14 @@ Mat FacemarkLBFImpl::Regressor::globalRegressionPredict(const Mat &lbf, int stag
13741372
w_ptr = weight.ptr<double>(2 * i);
13751373
double y = 0;
13761374
for (int j = 0; j < lbf.cols; j++) y += w_ptr[lbf_ptr[j]];
1377-
delta_shape(i, 0) = y;
1375+
delta_shape.at<double>(i, 0) = y;
13781376

13791377
w_ptr = weight.ptr<double>(2 * i + 1);
13801378
y = 0;
13811379
for (int j = 0; j < lbf.cols; j++) y += w_ptr[lbf_ptr[j]];
1382-
delta_shape(i, 1) = y;
1380+
delta_shape.at<double>(i, 1) = y;
13831381
}
1384-
return std::move(delta_shape);
1382+
return delta_shape;
13851383
} // Regressor::globalRegressionPredict
13861384

13871385
Mat FacemarkLBFImpl::Regressor::predict(Mat &img, BBox &bbox) {

modules/face/src/mace.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ struct MACEImpl CV_FINAL : MACE {
102102
Mat complexInput;
103103
merge(input, 2, complexInput);
104104

105-
Mat_<Vec2d> dftImg(IMGSIZE*2, IMGSIZE*2, 0.0);
105+
Mat dftImg(IMGSIZE*2, IMGSIZE*2, CV_64FC2, 0.0);
106106
complexInput.copyTo(dftImg(Rect(0,0,IMGSIZE,IMGSIZE)));
107107

108108
dft(dftImg, dftImg);
109-
return std::move(dftImg);
109+
return dftImg;
110110
}
111111

112112

modules/mcc/test/test_mcc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ TEST(CV_mcc_ccm_test, detect_Macbeth)
102102

103103
// check Macbeth corners
104104
vector<Point2f> corners = checker->getBox();
105-
EXPECT_MAT_NEAR(gold_corners, corners, 3.6); // diff 3.57385 in ARM only
105+
// diff 3.57385 corresponds to ARM v8
106+
// diff 4.37915 correspnds to Ubuntu 24.04 x86_64 configuration
107+
EXPECT_MAT_NEAR(gold_corners, corners, 4.38);
106108

107109
// read gold chartsRGB
108110
node = fs["chartsRGB"];
@@ -112,7 +114,7 @@ TEST(CV_mcc_ccm_test, detect_Macbeth)
112114

113115
// check chartsRGB
114116
Mat chartsRGB = checker->getChartsRGB();
115-
EXPECT_MAT_NEAR(goldChartsRGB.col(1), chartsRGB.col(1), 0.25); // diff 0.240634 in ARM only
117+
EXPECT_MAT_NEAR(goldChartsRGB.col(1), chartsRGB.col(1), 0.3); // diff 0.292077 on Ubuntu 20.04 ARM64
116118
}
117119

118120
TEST(CV_mcc_ccm_test, compute_ccm)

modules/rgbd/perf/perf_tsdf.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct Scene
9191
{
9292
virtual ~Scene() {}
9393
static Ptr<Scene> create(Size sz, Matx33f _intr, float _depthFactor, bool onlySemisphere);
94-
virtual Mat depth(Affine3f pose) = 0;
94+
virtual Mat_<float> depth(const Affine3f& pose) = 0;
9595
virtual std::vector<Affine3f> getPoses() = 0;
9696
};
9797

@@ -131,15 +131,15 @@ struct SemisphereScene : Scene
131131
return res;
132132
}
133133

134-
Mat depth(Affine3f pose) override
134+
Mat_<float> depth(const Affine3f& pose) override
135135
{
136136
Mat_<float> frame(frameSize);
137137
Reprojector reproj(intr);
138138

139139
Range range(0, frame.rows);
140140
parallel_for_(range, RenderInvoker<SemisphereScene>(frame, pose, reproj, depthFactor, onlySemisphere));
141141

142-
return std::move(frame);
142+
return frame;
143143
}
144144

145145
std::vector<Affine3f> getPoses() override

modules/rgbd/test/ocl/test_tsdf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct SemisphereScene : Scene
143143
Range range(0, frame.rows);
144144
parallel_for_(range, RenderInvoker<SemisphereScene>(frame, pose, reproj, depthFactor, onlySemisphere));
145145

146-
return std::move(frame);
146+
return static_cast<Mat>(frame);
147147
}
148148

149149
std::vector<Affine3f> getPoses() override

modules/rgbd/test/test_colored_kinfu.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ struct Scene
158158
{
159159
virtual ~Scene() {}
160160
static Ptr<Scene> create(int nScene, Size sz, Matx33f _intr, float _depthFactor);
161-
virtual Mat depth(Affine3f pose) = 0;
162-
virtual Mat rgb(Affine3f pose) = 0;
161+
virtual Mat_<float> depth(const Affine3f& pose) = 0;
162+
virtual Mat_<Vec3f> rgb(const Affine3f& pose) = 0;
163163
virtual std::vector<Affine3f> getPoses() = 0;
164164
};
165165

@@ -198,26 +198,26 @@ struct CubeSpheresScene : Scene
198198
return res;
199199
}
200200

201-
Mat depth(Affine3f pose) override
201+
Mat_<float> depth(const Affine3f& pose) override
202202
{
203203
Mat_<float> frame(frameSize);
204204
Reprojector reproj(intr);
205205

206206
Range range(0, frame.rows);
207207
parallel_for_(range, RenderInvoker<CubeSpheresScene>(frame, pose, reproj, depthFactor));
208208

209-
return std::move(frame);
209+
return frame;
210210
}
211211

212-
Mat rgb(Affine3f pose) override
212+
Mat_<Vec3f> rgb(const Affine3f& pose) override
213213
{
214214
Mat_<Vec3f> frame(frameSize);
215215
Reprojector reproj(intr);
216216

217217
Range range(0, frame.rows);
218218
parallel_for_(range, RenderColorInvoker<CubeSpheresScene>(frame, pose, reproj, depthFactor));
219219

220-
return std::move(frame);
220+
return frame;
221221
}
222222

223223
std::vector<Affine3f> getPoses() override
@@ -305,26 +305,26 @@ struct RotatingScene : Scene
305305
return res;
306306
}
307307

308-
Mat depth(Affine3f pose) override
308+
Mat_<float> depth(const Affine3f& pose) override
309309
{
310310
Mat_<float> frame(frameSize);
311311
Reprojector reproj(intr);
312312

313313
Range range(0, frame.rows);
314314
parallel_for_(range, RenderInvoker<RotatingScene>(frame, pose, reproj, depthFactor));
315315

316-
return std::move(frame);
316+
return frame;
317317
}
318318

319-
Mat rgb(Affine3f pose) override
319+
Mat_<Vec3f> rgb(const Affine3f& pose) override
320320
{
321321
Mat_<Vec3f> frame(frameSize);
322322
Reprojector reproj(intr);
323323

324324
Range range(0, frame.rows);
325325
parallel_for_(range, RenderColorInvoker<RotatingScene>(frame, pose, reproj, depthFactor));
326326

327-
return std::move(frame);
327+
return frame;
328328
}
329329

330330
std::vector<Affine3f> getPoses() override

modules/rgbd/test/test_kinfu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct CubeSpheresScene : Scene
141141
Range range(0, frame.rows);
142142
parallel_for_(range, RenderInvoker<CubeSpheresScene>(frame, pose, reproj, depthFactor));
143143

144-
return std::move(frame);
144+
return static_cast<Mat>(frame);
145145
}
146146

147147
std::vector<Affine3f> getPoses() override
@@ -237,7 +237,7 @@ struct RotatingScene : Scene
237237
Range range(0, frame.rows);
238238
parallel_for_(range, RenderInvoker<RotatingScene>(frame, pose, reproj, depthFactor));
239239

240-
return std::move(frame);
240+
return static_cast<Mat>(frame);
241241
}
242242

243243
std::vector<Affine3f> getPoses() override

modules/rgbd/test/test_tsdf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct SemisphereScene : Scene
140140
Range range(0, frame.rows);
141141
parallel_for_(range, RenderInvoker<SemisphereScene>(frame, pose, reproj, depthFactor, onlySemisphere));
142142

143-
return std::move(frame);
143+
return static_cast<Mat>(frame);
144144
}
145145

146146
std::vector<Affine3f> getPoses() override

0 commit comments

Comments
 (0)