fix python/Java tests, add new Java test

pull/3325/head
AleksandrPanov 2 years ago
parent 95cf9efea9
commit b562b69d0c
  1. 26
      modules/aruco/misc/java/test/ArucoTest.java
  2. 2
      modules/aruco/misc/pattern_generator/MarkerPrinter.py
  3. 12
      modules/aruco/misc/python/test/test_aruco.py
  4. 2
      modules/ovis/samples/aruco_ar_demo.py
  5. 2
      modules/rapid/samples/track_marker.py

@ -6,6 +6,7 @@ import java.util.List;
import org.opencv.test.OpenCVTestCase;
import org.opencv.core.Scalar;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.core.CvType;
import org.opencv.aruco.*;
import org.opencv.objdetect.*;
@ -13,9 +14,30 @@ import org.opencv.objdetect.*;
public class ArucoTest extends OpenCVTestCase {
public void testDrawBoards() {
Dictionary dictionary = Objdetect.getPredefinedDictionary(Objdetect.DICT_4X4_50);
Mat point1 = new Mat(4, 3, CvType.CV_32FC1);
int row = 0, col = 0;
point1.put(row ,col, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0);
List<Mat>objPoints = new ArrayList<Mat>();
objPoints.add(point1);
Mat ids = new Mat(1, 1, CvType.CV_32SC1);
ids.put(row, col, 0);
Board board = Board.create(objPoints, dictionary, ids);
Mat image = new Mat();
board.draw(new Size(50, 50), image);
assertTrue(image.total() > 0);
}
public void testArucoIssue3133() {
byte[][] marker = {{0,1,1},{1,1,1},{0,1,1}};
Dictionary dictionary = extendDictionary(1, 3);
Dictionary dictionary = Objdetect.extendDictionary(1, 3);
dictionary.set_maxCorrectionBits(0);
Mat markerBits = new Mat(3, 3, CvType.CV_8UC1);
for (int i = 0; i < 3; i++) {
@ -32,7 +54,7 @@ public class ArucoTest extends OpenCVTestCase {
}
public void testArucoDetector() {
Dictionary dictionary = getPredefinedDictionary(0);
Dictionary dictionary = Objdetect.getPredefinedDictionary(0);
DetectorParameters detectorParameters = new DetectorParameters();
ArucoDetector detector = new ArucoDetector(dictionary, detectorParameters);

@ -39,7 +39,7 @@ def SaveArucoDictBytesList(filePath = "arucoDictBytesList.npz"):
arucoDictBytesList = {}
for name, flag in dictInfo:
arucoDict = aruco.Dictionary_get(flag)
arucoDict = aruco.getPredefinedDictionary(flag)
arucoDictBytesList[name] = arucoDict.bytesList
np.savez_compressed(filePath, **arucoDictBytesList)

@ -16,7 +16,7 @@ class aruco_test(NewOpenCVTests):
ids = np.arange(17)
rev_ids = ids[::-1]
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_5X5_250)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_5X5_250)
board = cv.aruco.CharucoBoard_create(7, 5, 1, 0.5, aruco_dict)
np.testing.assert_array_equal(board.getIds().squeeze(), ids)
@ -28,7 +28,7 @@ class aruco_test(NewOpenCVTests):
np.testing.assert_array_equal(board.getIds().squeeze(), ids)
def test_drawCharucoDiamond(self):
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
img = cv.aruco.drawCharucoDiamond(aruco_dict, np.array([0, 1, 2, 3]), 100, 80)
self.assertTrue(img is not None)
@ -62,7 +62,7 @@ class aruco_test(NewOpenCVTests):
os.remove(filename)
def test_identify(self):
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
expected_idx = 9
expected_rotation = 2
bit_marker = np.array([[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 1]], dtype=np.uint8)
@ -74,7 +74,7 @@ class aruco_test(NewOpenCVTests):
self.assertEqual(rotation, expected_rotation)
def test_getDistanceToId(self):
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
idx = 7
rotation = 3
bit_marker = np.array([[0, 1, 0, 1], [0, 1, 1, 1], [1, 1, 0, 0], [0, 1, 0, 0]], dtype=np.uint8)
@ -84,7 +84,7 @@ class aruco_test(NewOpenCVTests):
def test_aruco_detector(self):
aruco_params = cv.aruco.DetectorParameters()
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_250)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_250)
aruco_detector = cv.aruco.ArucoDetector(aruco_dict, aruco_params)
id = 2
marker_size = 100
@ -107,7 +107,7 @@ class aruco_test(NewOpenCVTests):
def test_aruco_detector_refine(self):
aruco_params = cv.aruco.DetectorParameters()
aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_250)
aruco_dict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_250)
aruco_detector = cv.aruco.ArucoDetector(aruco_dict, aruco_params)
board_size = (3, 4)
board = cv.aruco.GridBoard_create(board_size[0], board_size[1], 5.0, 1.0, aruco_dict)

@ -2,7 +2,7 @@ import numpy as np
import cv2 as cv
# aruco
adict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
adict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
cv.imshow("marker", cv.aruco.drawMarker(adict, 0, 400))
# random calibration data. your mileage may vary.

@ -2,7 +2,7 @@ import numpy as np
import cv2 as cv
# aruco config
adict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50)
adict = cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_50)
cv.imshow("marker", cv.aruco.drawMarker(adict, 0, 400))
marker_len = 5

Loading…
Cancel
Save