mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 17:24:28 +08:00
Merge pull request #2973 from rogday:aruco_ids_rw
This commit is contained in:
@@ -281,6 +281,18 @@ class CV_EXPORTS_W Board {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
|
CV_WRAP static Ptr<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set ids vector
|
||||||
|
*
|
||||||
|
* @param ids vector of the identifiers of the markers in the board (should be the same size
|
||||||
|
* as objPoints)
|
||||||
|
*
|
||||||
|
* Recommended way to set ids vector, which will fail if the size of ids does not match size
|
||||||
|
* of objPoints.
|
||||||
|
*/
|
||||||
|
CV_WRAP void setIds(InputArray ids);
|
||||||
|
|
||||||
/// array of object points of all the marker corners in the board
|
/// array of object points of all the marker corners in the board
|
||||||
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
|
/// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
|
||||||
CV_PROP std::vector< std::vector< Point3f > > objPoints;
|
CV_PROP std::vector< std::vector< Point3f > > objPoints;
|
||||||
@@ -290,7 +302,7 @@ class CV_EXPORTS_W Board {
|
|||||||
|
|
||||||
/// vector of the identifiers of the markers in the board (same size than objPoints)
|
/// vector of the identifiers of the markers in the board (same size than objPoints)
|
||||||
/// The identifiers refers to the board dictionary
|
/// The identifiers refers to the board dictionary
|
||||||
CV_PROP std::vector< int > ids;
|
CV_PROP_RW std::vector< int > ids;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
34
modules/aruco/misc/python/test/test_aruco.py
Normal file
34
modules/aruco/misc/python/test/test_aruco.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Python 2/3 compatibility
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os, numpy as np
|
||||||
|
|
||||||
|
import cv2 as cv
|
||||||
|
|
||||||
|
from tests_common import NewOpenCVTests
|
||||||
|
|
||||||
|
class aruco_test(NewOpenCVTests):
|
||||||
|
|
||||||
|
def test_idsAccessibility(self):
|
||||||
|
|
||||||
|
ids = np.array([[elem] for elem in range(17)])
|
||||||
|
rev_ids = np.array(list(reversed(ids)))
|
||||||
|
|
||||||
|
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_5X5_250)
|
||||||
|
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict)
|
||||||
|
|
||||||
|
self.assertTrue(np.equal(board.ids, ids).all())
|
||||||
|
|
||||||
|
board.ids = rev_ids
|
||||||
|
self.assertTrue(np.equal(board.ids, rev_ids).all())
|
||||||
|
|
||||||
|
board.setIds(ids)
|
||||||
|
self.assertTrue(np.equal(board.ids, ids).all())
|
||||||
|
|
||||||
|
with self.assertRaises(cv.error):
|
||||||
|
board.setIds(np.array([0]))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
NewOpenCVTests.bootstrap()
|
@@ -1659,6 +1659,13 @@ Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &di
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
void Board::setIds(InputArray ids_) {
|
||||||
|
CV_Assert(objPoints.size() == ids_.total());
|
||||||
|
ids_.copyTo(this->ids);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation,
|
Ptr<GridBoard> GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation,
|
||||||
|
Reference in New Issue
Block a user