opencv微信二维码引擎的使用(for java)

前面讲了windows系统下opencv+opencv的编译方法,编译方法和编译好的文件如下:

Windows下联合编译opencv+opencv_contrib微信二维码引擎

OpenCV4.5.2(windows for java)

这次讲下微信二维码引擎的使用方法,为了方便使用,不需要手动添加dll等,对jar、dll、微信配置文件做了集成,重新编译了jar。这个是windows下的,如果要在linux下使用,需要在config下加入对应的so。重新编译的jar如下:

含微信二维码引擎的重编译opencv-452.jar

具体新增如下:
opencv微信二维码引擎的使用(for java)_第1张图片                 opencv微信二维码引擎的使用(for java)_第2张图片
1.把jar添加到项目后,调用Config.load();自动加载dll和微信配置文件。
2.img2mat和mat2img是封装好的图片和Mat转换方法,默认图片格式img为BufferedImage.TYPE_3BYTE_BGR(imgType),mat为CvType.CV_8UC3(matType),通过setType(int imgType, int matType)可进行修改,每调用一次转换方法type值会重置为默认值。

下面以具体例子讲解下使用方法:

package vqb;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.opencv.config.Config;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;
import org.opencv.utils.Converters;
import org.opencv.videoio.VideoCapture;
import org.opencv.wechat_qrcode.WeChatQRCode;

public class Test {
	private static JFrame frame = new JFrame("camera");
	private static JPanel panel = new JPanel();
	private static int width = 900;
	private static int height = 600;
	
	static {
		//加载opencv库
		Config.load();
	}
	
	public static void main(String... args) {
		open();
	}
	
	public static void open() {
		frame.setSize(width,height);
		frame.setLocationRelativeTo(null);
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setContentPane(panel);
		//openCamera();
		openPic();
	}
	
	private static void openCamera() {
		VideoCapture camera = new VideoCapture(0);
		if(!camera.isOpened()){
			System.out.println("Camera Error");
			return;
		}
		Mat img = new Mat();
		while(true){
			camera.read(img);
			deCode(img);
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			panel.repaint();
		}
	}
	
	private static void openPic() {
		String base64 = "data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAqwAAAJCCAYAAAAFjJXCAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAADsLSURBVHhe7d1trGxnXQZ8QsBgQwikh/oSQIOoBxME2idqSEoCwTSGqBThAxRCBFs0QCAYoDnhg8hJFDTUxPhSEwy2gQSl+MRqGj+YeD4gaptqeClCkLQCoRaCTYCeeko9z7N2ZnLWYq7ZM2vWvWbf996/K/n54d+511oznXv21cHMesxj/t+XXQQAgGrFIQAA1CIOAQCgFnEIAAC1iEMAAKhFHAIAQC3iEAAAahGHAABQizgEAIBaxCEAANQiDgEAoBZxCAAAtYhDAACoRRwCAEAt4hAAAGoRhwAAUIs4BACAWsQhAADUIg4BAKAWcQgAALWIQwAAqEUcAgBALeIQAABqEYcAAFCLOAQAgFrEIQAA1CIOAQCgFnEIAAC1iEMAAKhFHAIAQC3iEAAAahGHAABQizgEAIBaxCEAANQiDgEAoBZxCAAAtYhDAACoRRwCAEAt4hAAAGoRhwAAUIs4BACAWsQhUB0RKZO0v4DKxSFQHREpk7S/gMrFIVAdESmTtL+AysUhUB0RKZO0v4DKxSFQHREpk7S/gMrFIVAdESmTtL+AysUhUB0RKZO0v4DKxSFQHREpk7S/gMrFIVAdESmTtL+AysUhUB0RKZO0v4DKxSFQHREpk7S/gMrFIVAdESmTtL+AysUhUB0RKZO0v4DKxSFQHREpk7S/gMrFIVAdESmTtL+AysUhUB0RKZO0v4DKxSFQnal55JFHLt57770nwn333bd41uvzjW98I65d+upXv7p4ZP3pnm96DsdR9z6emrS/gMrFIVCdqen+2D/mMY85ES677LLFs16fG264Ia5dOn369OKR9ad7vuk5HEfd+3hq0v4CKheHQHWmRmEdRmFtk8IKJ1QcAtWZGoV1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uvec1r4rmXrrzyysUjd89tt90Wj93n1qxwQsUhUJ0aorAOKayXKKzArOIQqE4NUViHFNZLFFZgVnEIVKeGKKxDCuslCiswqzgEqlNDFNYhhfUShRWYVRwC1akhCuuQwnqJwgrMKg6B6tQQhXVIYb1EYQVmFYdAdabmwoULBz9SP8Utt9yyUiC+1z4K6+WXX37x9OnTaz3/+c9fnG19ShTWP/uzP4uv01L3z9O60jYV1v/+7/+O17f0+c9/fvHI9XnnO98ZX+ulX/mVX1k8cvcorMBacQhUZ2q6P/SpAJS2j8J65syZxdF2T4nCWotNhbV7vdK6pVOnTi0eebRRWIG14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQorMMorJcorED14hCoztQ89NBDB3demttrX/vai9dcc81az3nOc1ZKyFjPfOYz47HHeNrTnhaP3aKXvOQl8Tkuvec974n/rpY+/vGPx3WlfepTn1q8G3Puv//+eH193ft4atL+AioXh0B1WslVV121Uqg4WmfPnl3828l54IEH4rrSulv71pC0v4DK/T+//5qLffFBwJFrJQprfRTWYdL+AiqnrEIbWonCWh+FdZi0v4DKdf9HWYX6tRKFtT4K6zBpfwGVi0OgOq1EYa2PwjpM2l9A5eIQqE4rUVjro7AOk/YXULk4BKrTShTW+iisw6T9BVQuDoHqtJI3v/nN8Tc4x3j84x+/Unb6Nv0Oa/e7pGndvl1++eXx+kp77GMfG8+/tKmwPvjgg/G4fT/0Qz8Ujz3G7/3e78XfVh3D77DCCRWHQHVOUro7L6XCs7TpTlfdnZ/Sun3rit4+ctlll8XzL20qrNvkNa95TTz2vrnTFZxQcQhU5yRFYR0XhXVc0v4CKheHQHVOUhTWcVFYxyXtL6BycQhU5yRFYR0XhXVc0v4CKheHQHVOUhTWcVFYxyXtL6BycQhU5yRFYR0XhXVc0v4CKheHQHVOUhTWcVFYxyXtL6BycQhU5yRFYR0XhXVc0v4CKheHQHX2kbe85S0XT58+vVZXWvaRTYW1+0H+dH1Lz33ucy/ec889h3rlK18Zjz3GzTffHI+99OEPf3jl2r7XF7/4xcWzzvnoRz8a1/Xdfffd8fxLX//61xdHy/nmN78Zj9v3J3/yJ/HYS3/1V38VX6PSFFY4oeIQqM4+cu21164UhL6rr7568ch5s6mwbtJ947gpN9xwQ1w7RnfnpcPS/fO0rq8re4elK8VpXV/3jfKUbHNr1ltuuWXx6Jy77rorritNYYUTKg6B6uwjCus4CuulKKzArOIQqM4+orCOo7BeisIKzCoOgersIwrrOArrpSiswKziEKjOPqKwjqOwXorCCswqDoHq7CMK6zgK66UorMCs4hCozj6isI6jsF6KwgrMKg6B6uwjf/zHf3zx+uuvX+v973//4pHz5u1vf3s8/7be9KY3LY60PpsK65Of/OR47L5Pf/rTi6PllCis586di+fue/jhhxeP3i3bFNZf/dVfPSjP63Q3c0jrSlNY4YSKQ6A6UjabCmv3Y/lTU6Kw7iPbFNZaKKxwQsUhUB0pG4X1UhRWoHpxCFRHykZhvRSFFaheHALVkbJRWC9FYQWqF4dAdaRsFNZLUViB6sUhUB0pG4X1UhRWoHpxCFRHykZhvRSFFaheHALVkbJRWC9FYQWqF4dAdabmvvvuO7gD1EnQ3SlrU7of2+/uELXOv/3bv8Vjj/HSl740Hrvv0UcfXVzR7umebzr/0vve977FI3NKFNbnPe958fn1veAFL4hrl37xF38xrusr8Xql/QVULg6B6kxN981UKgnHUVfSpqb75jMde4xrrrlmcbR50z3fdP6ls2fPLh6ZU6KwXnnllYujrU93a9+0dqm7NfA+kvYXULk4BKozNQrruCis4yiswKziEKjO1Cis46KwjqOwArOKQ6A6U6OwjovCOo7CCswqDoHqTI3COi4K6zgKKzCrOASqMzUK67gorOMorMCs4hCoztQorOOisI6jsAKzikOgOlOzTWF91atedVBuaveSl7wkXv/SNoX1r//6ry+eOXNmrTe+8Y3x2H2ve93r4vUtfeQjH1mcbff867/+a7y+vsc//vHx+pa6azks3/nOd1aufazf/u3fjtfW1z0mrV16z3veE9f1ffO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zmICLzJO23psVhg0SkXNIegzmIyDxJ+61pcdggESmXtMdgDiIyT9J+a1ocNkhEyiXtMZiDiMyTtN+aFocNEpFySXsM5iAi8yTtt6bFYYNEpFzSHoM5iMg8SfutaXEIAAC1iEMAAKhFHAIAQC3iEAAAahGHAABQizgEAIBaxCEAANQiDgEAoBZxCAAAtYhDAACoRRwCAEAt4hAAAGoRhwAAUIs4BACAWsQhAADUIg4BAKAWcQgAALWIQwAAqEUcAgBALeIQAABqEYcAAFCLOAQAgFrEIQAA1CIOAQCgFnEIAAC1iEMAAKhFHAIAQC3iEAAAahGHAABQizgEAIBaxCEAANQiDgEAoBZxCAAAtYhDAACoRRwCAEAt4hAAAGoRhwAAUIs4BACAWsQhAADUIg4BAKAWcQgAALWIQwAAqEUcAgBALeIQAABqEYcAAFCLOAQAgFrEIQAA1CIOAQCgFnEIAAC1iEMAAKjCyy7+f96zJzD9nBz1AAAAAElFTkSuQmCC";
		Mat img = Converters.img2mat(base64);
		System.out.println(img.width());
		deCode(img);
	}
	
	private static void deCode(Mat img) {
		//微信二维码对象,要返回二维码坐标前2个参数必传;后2个在二维码小或不清晰时必传。
		WeChatQRCode we = new WeChatQRCode(Config.detector_prototxt_path,Config.detector_caffe_model_path,Config.super_resolution_prototxt_path,Config.super_resolution_caffe_model_path);
		List<Mat> points = new ArrayList<Mat>();
		//微信二维码引擎解码,返回的valList中存放的是解码后的数据,points中Mat存放的是二维码4个角的坐标
		List<String> valList = we.detectAndDecode(img, points);
		for(int i = 0; i < valList.size(); i++) {
			//根据坐标画矩形,就是二维码上的那个框
			Imgproc.rectangle(img,new Point(points.get(i).get(0, 0)[0],points.get(i).get(0, 1)[0]),new Point(points.get(i).get(2, 0)[0],points.get(i).get(2, 1)[0]),new Scalar(0, 0, 255),2);
			//opencv的Imgproc.putText方法中文会乱码,如果是英文可以直接使用。
			//Imgproc.putText(img, valList.get(i), new Point(points.get(i).get(0, 0)[0],points.get(i).get(0, 1)[0] - 10), 18, 1, new Scalar(0, 0, 255), 2);
		}
		BufferedImage image = Converters.mat2img(img);
		//因为opencv的Imgproc.putText方法中文会乱码,所以自己写了一个添加文本的方法。
		putText(image, valList, points);
		int w = image.getWidth() > panel.getWidth() ? panel.getWidth() : image.getWidth();
		int h = image.getHeight() > panel.getHeight() ? panel.getHeight() : image.getHeight();
		panel.getGraphics().drawImage(image, (panel.getWidth()-w)/2, (panel.getHeight()-h)/2, w, h, panel);
	}
	//根据坐标为图片添加文字
	private static void putText(BufferedImage img, List<String> textList, List<Mat> points) {
		Graphics2D g = img.createGraphics();
		Font font = new Font("宋体", Font.BOLD, 18);
		g.setColor(Color.red);
		g.setFont(font);
		for(int i = 0; i < textList.size(); i++) {
			g.drawString(textList.get(i), (float)points.get(i).get(0, 0)[0], (float)points.get(i).get(0, 1)[0] - 10);
		}
		g.dispose();
	}
	
}

电脑上没有摄像头,只测试了二维码图片的扫码,调用摄像头扫码方法虽然没有进行测试,应该没有太大问题。如果发现有什么问题可以留言给我。

你可能感兴趣的:(opencv,java,opencv)