mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 22:40:17 +08:00
acc089ca64
QR-Code detector : multiple detection * change in qr-codes detection * change in qr-codes detection * change in test * change in test * add multiple detection * multiple detection * multiple detect * add parallel implementation * add functional for performance tests * change in test * add perftest * returned implementation for 1 qr-code, added support for vector<Mat> and vector<vector<Point2f>> in MultipleDetectAndDecode * deleted all lambda expressions * changing in triangle sort * fixed warnings * fixed errors * add java and python tests * change in java tests * change in java and python tests * change in perf test * change in qrcode.cpp * add spaces * change in qrcode.cpp * change in qrcode.cpp * change in qrcode.cpp * change in java tests * change in java tests * solved problems * solved problems * change in java and python tests * change in python tests * change in python tests * change in python tests * change in methods name * deleted sample qrcode_multi, change in qrcode.cpp * change in perf tests * change in objdetect.hpp * deleted code duplication in sample qrcode.cpp * returned spaces * added spaces * deleted draw function * change in qrcode.cpp * change in qrcode.cpp * deleted all draw functions * objdetect(QR): extractVerticalLines * objdetect(QR): whitespaces * objdetect(QR): simplify operations, avoid duplicated code * change in interface, additional checks in java and python tests, added new key in sample for saving original image from camera * fix warnings and errors in python test * fix * write in file with space key * solved error with empty mat check in python test * correct path to test image * deleted spaces * solved error with check empty mat in python tests * added check of empty vector of points * samples: rework qrcode.cpp * objdetect(QR): fix API, input parameters must be first * objdetect(QR): test/fix points layout
50 lines
1.8 KiB
Java
50 lines
1.8 KiB
Java
package org.opencv.test.objdetect;
|
|
|
|
import java.util.List;
|
|
import org.opencv.core.Mat;
|
|
import org.opencv.objdetect.QRCodeDetector;
|
|
import org.opencv.imgcodecs.Imgcodecs;
|
|
import org.opencv.test.OpenCVTestCase;
|
|
import java.util.ArrayList;
|
|
|
|
public class QRCodeDetectorTest extends OpenCVTestCase {
|
|
|
|
private final static String ENV_OPENCV_TEST_DATA_PATH = "OPENCV_TEST_DATA_PATH";
|
|
private String testDataPath;
|
|
|
|
@Override
|
|
protected void setUp() throws Exception {
|
|
super.setUp();
|
|
|
|
testDataPath = System.getenv(ENV_OPENCV_TEST_DATA_PATH);
|
|
if (testDataPath == null)
|
|
throw new Exception(ENV_OPENCV_TEST_DATA_PATH + " has to be defined!");
|
|
}
|
|
|
|
public void testDetectAndDecode() {
|
|
Mat img = Imgcodecs.imread(testDataPath + "/cv/qrcode/link_ocv.jpg");
|
|
assertFalse(img.empty());
|
|
QRCodeDetector detector = new QRCodeDetector();
|
|
assertNotNull(detector);
|
|
String output = detector.detectAndDecode(img);
|
|
assertEquals(output, "https://opencv.org/");
|
|
}
|
|
|
|
public void testDetectAndDecodeMulti() {
|
|
Mat img = Imgcodecs.imread(testDataPath + "/cv/qrcode/multiple/6_qrcodes.png");
|
|
assertFalse(img.empty());
|
|
QRCodeDetector detector = new QRCodeDetector();
|
|
assertNotNull(detector);
|
|
List < String > output = new ArrayList< String >();
|
|
boolean result = detector.detectAndDecodeMulti(img, output);
|
|
assertTrue(result);
|
|
assertEquals(output.size(), 6);
|
|
assertEquals(output.get(0), "SKIP");
|
|
assertEquals(output.get(1), "EXTRA");
|
|
assertEquals(output.get(2), "TWO STEPS FORWARD");
|
|
assertEquals(output.get(3), "STEP BACK");
|
|
assertEquals(output.get(4), "QUESTION");
|
|
assertEquals(output.get(5), "STEP FORWARD");
|
|
}
|
|
}
|