Skip to content

Commit f7b566f

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 10d1020 + 2bef7d7 commit f7b566f

File tree

5 files changed

+73
-15
lines changed

5 files changed

+73
-15
lines changed

modules/aruco/include/opencv2/aruco.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ class CV_EXPORTS_W Board {
281281
*
282282
*/
283283
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
284+
285+
/**
286+
* @brief Set ids vector
287+
*
288+
* @param ids vector of the identifiers of the markers in the board (should be the same size
289+
* as objPoints)
290+
*
291+
* Recommended way to set ids vector, which will fail if the size of ids does not match size
292+
* of objPoints.
293+
*/
294+
CV_WRAP void setIds(InputArray ids);
295+
284296
/// array of object points of all the marker corners in the board
285297
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
286298
CV_PROP std::vector< std::vector< Point3f > > objPoints;
@@ -290,7 +302,7 @@ class CV_EXPORTS_W Board {
290302

291303
/// vector of the identifiers of the markers in the board (same size than objPoints)
292304
/// The identifiers refers to the board dictionary
293-
CV_PROP std::vector< int > ids;
305+
CV_PROP_RW std::vector< int > ids;
294306
};
295307

296308

modules/aruco/misc/objc/gen_dict.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"*" : [ "\"aruco.hpp\"" ],
44
"CharucoBoard" : [ "\"aruco/charuco.hpp\"" ],
55
"Dictionary" : [ "\"aruco/dictionary.hpp\"" ]
6+
},
7+
"func_arg_fix" : {
8+
"Board" : {
9+
"(void)setIds:(Mat*)ids" : { "setIds" : {"name" : "setIdsMat"} }
10+
}
611
}
712
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
3+
# Python 2/3 compatibility
4+
from __future__ import print_function
5+
6+
import os, numpy as np
7+
8+
import cv2 as cv
9+
10+
from tests_common import NewOpenCVTests
11+
12+
class aruco_test(NewOpenCVTests):
13+
14+
def test_idsAccessibility(self):
15+
16+
ids = np.array([[elem] for elem in range(17)])
17+
rev_ids = np.array(list(reversed(ids)))
18+
19+
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_5X5_250)
20+
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict)
21+
22+
self.assertTrue(np.equal(board.ids, ids).all())
23+
24+
board.ids = rev_ids
25+
self.assertTrue(np.equal(board.ids, rev_ids).all())
26+
27+
board.setIds(ids)
28+
self.assertTrue(np.equal(board.ids, ids).all())
29+
30+
with self.assertRaises(cv.error):
31+
board.setIds(np.array([0]))
32+
33+
if __name__ == '__main__':
34+
NewOpenCVTests.bootstrap()

modules/aruco/src/aruco.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,13 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
14951495
return res;
14961496
}
14971497

1498+
/**
1499+
*/
1500+
void Board::setIds(InputArray ids_) {
1501+
CV_Assert(objPoints.size() == ids_.total());
1502+
ids_.copyTo(this->ids);
1503+
}
1504+
14981505
/**
14991506
*/
15001507
Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation,

modules/fuzzy/src/fuzzy_F0_math.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray outpu
122122
int output_height = matrix.rows();
123123
int output_width = matrix.cols();
124124

125-
uchar *img_r = new uchar[output_height * output_width];
126-
uchar *img_g = new uchar[output_height * output_width];
127-
uchar *img_b = new uchar[output_height * output_width];
125+
Mat compR(output_height, output_width, CV_8UC1);
126+
Mat compG(output_height, output_width, CV_8UC1);
127+
Mat compB(output_height, output_width, CV_8UC1);
128+
129+
uchar *img_r = compR.ptr();
130+
uchar *img_g = compG.ptr();
131+
uchar *img_b = compB.ptr();
128132

129133
for (int y = 0; y < output_height; y++)
130134
{
@@ -158,10 +162,6 @@ void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray outpu
158162
}
159163
}
160164

161-
Mat compR(output_height, output_width, CV_8UC1, img_r);
162-
Mat compG(output_height, output_width, CV_8UC1, img_g);
163-
Mat compB(output_height, output_width, CV_8UC1, img_b);
164-
165165
std::vector<Mat> oComp;
166166

167167
oComp.push_back(compB);
@@ -250,9 +250,13 @@ void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray
250250
int output_height = matrix.rows();
251251
int output_width = matrix.cols();
252252

253-
float *img_r = new float[output_height * output_width];
254-
float *img_g = new float[output_height * output_width];
255-
float *img_b = new float[output_height * output_width];
253+
Mat compR(output_height, output_width, CV_32FC1);
254+
Mat compG(output_height, output_width, CV_32FC1);
255+
Mat compB(output_height, output_width, CV_32FC1);
256+
257+
float *img_r = compR.ptr<float>();
258+
float *img_g = compG.ptr<float>();
259+
float *img_b = compB.ptr<float>();
256260

257261
for (int y = 0; y < output_height; y++)
258262
{
@@ -286,10 +290,6 @@ void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray
286290
}
287291
}
288292

289-
Mat compR(output_height, output_width, CV_32FC1, img_r);
290-
Mat compG(output_height, output_width, CV_32FC1, img_g);
291-
Mat compB(output_height, output_width, CV_32FC1, img_b);
292-
293293
std::vector<Mat> oComp;
294294

295295
oComp.push_back(compB);

0 commit comments

Comments
 (0)