1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public static void main(String[] args) throws IOException { System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat image = imread("images/qrcode-feature.jpg"); QRCodeDetector detector = new QRCodeDetector(); Mat points = new Mat(); Mat straight_qrcode = new Mat(); String data = detector.detectAndDecode(image, points, straight_qrcode);
if (data.length() > 0) { System.out.println("Decoded Data :" + data);
display(image, points);
straight_qrcode.convertTo(straight_qrcode, CvType.CV_8UC3); HighGui.imshow("Rectified QRCode", straight_qrcode);
HighGui.waitKey(0); }
System.exit(0); }
public static void display(Mat image, Mat points) { int n = points.rows(); for (int i = 0; i < n; i++) { Imgproc.line(image, new Point(points.get(i, 0)), new Point(points.get((i + 1) % n, 0)), new Scalar(255, 0, 0), 3); } HighGui.imshow("Result", image); }
|