mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Drop string encoding/decoding from Java test
This commit is contained in:
parent
d4f94bfb1b
commit
b91ffb8f1c
@ -57,28 +57,25 @@ public class QRCodeDetectorTest extends OpenCVTestCase {
|
|||||||
assertEquals(new HashSet<String>(output), new HashSet<String>(expectedResults));
|
assertEquals(new HashSet<String>(output), new HashSet<String>(expectedResults));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKanji() throws UnsupportedEncodingException {
|
public void testKanji() {
|
||||||
if (!Charset.isSupported("Shift_JIS"))
|
byte[] inp = new byte[]{(byte)0x82, (byte)0xb1, (byte)0x82, (byte)0xf1, (byte)0x82, (byte)0xc9, (byte)0x82,
|
||||||
throw new TestSkipException();
|
(byte)0xbf, (byte)0x82, (byte)0xcd, (byte)0x90, (byte)0xa2, (byte)0x8a, (byte)0x45};
|
||||||
|
|
||||||
String inp = new String("\u3053\u3093\u306B\u3061\u306F\u4E16\u754C");
|
|
||||||
|
|
||||||
QRCodeEncoder_Params params = new QRCodeEncoder_Params();
|
QRCodeEncoder_Params params = new QRCodeEncoder_Params();
|
||||||
params.set_mode(QRCodeEncoder.MODE_KANJI);
|
params.set_mode(QRCodeEncoder.MODE_KANJI);
|
||||||
QRCodeEncoder encoder = QRCodeEncoder.create(params);
|
QRCodeEncoder encoder = QRCodeEncoder.create(params);
|
||||||
|
|
||||||
Mat qrcode = new Mat();
|
Mat qrcode = new Mat();
|
||||||
encoder.encode(inp.getBytes("Shift_JIS"), qrcode);
|
encoder.encode(inp, qrcode);
|
||||||
Imgproc.resize(qrcode, qrcode, new Size(0, 0), 2, 2, Imgproc.INTER_NEAREST);
|
Imgproc.resize(qrcode, qrcode, new Size(0, 0), 2, 2, Imgproc.INTER_NEAREST);
|
||||||
|
|
||||||
QRCodeDetector detector = new QRCodeDetector();
|
QRCodeDetector detector = new QRCodeDetector();
|
||||||
byte[] output = detector.detectAndDecodeBytes(qrcode);
|
byte[] output = detector.detectAndDecodeBytes(qrcode);
|
||||||
assertEquals(detector.getEncoding(), QRCodeEncoder.ECI_SHIFT_JIS);
|
assertEquals(detector.getEncoding(), QRCodeEncoder.ECI_SHIFT_JIS);
|
||||||
assertEquals(inp, new String(output, "Shift_JIS"));
|
assertArrayEquals(inp, output);
|
||||||
|
|
||||||
List < byte[] > outputs = new ArrayList< byte[] >();
|
List < byte[] > outputs = new ArrayList< byte[] >();
|
||||||
assertTrue(detector.detectAndDecodeBytesMulti(qrcode, outputs));
|
assertTrue(detector.detectAndDecodeBytesMulti(qrcode, outputs));
|
||||||
assertEquals(detector.getEncoding(0), QRCodeEncoder.ECI_SHIFT_JIS);
|
assertEquals(detector.getEncoding(0), QRCodeEncoder.ECI_SHIFT_JIS);
|
||||||
assertEquals(inp, new String(outputs.get(0), "Shift_JIS"));
|
assertArrayEquals(inp, outputs.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user