车牌识别的停车场管理系统

车牌识别的停车场管理系统
项目课件和资料车牌识别的停车场管理系统_第1张图片
课程信息车牌识别的停车场管理系统_第2张图片在这里插入图片描述车辆信息列表

public static final String API_OCR_PLATEOCR = “https://api.ai.qq.com/fcgi-bin/ocr/ocr_plateocr”;
public String httpsRequest(String requestUrl, Map params) {
StringBuilder strb = new StringBuilder();
for (Entry entry : params.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (strb.length() == 0) {
strb.append(key).append("=").append(SignUtil.urlEncodeUTF8(value));
} else {
strb.append("&").append(key).append("=").append(SignUtil.urlEncodeUTF8(value));
}
}
// logger.info(strb.toString());
String result = null;
try {
// 创建SSLContext对象,并使用我们指定的信任管理器初始化
TrustManager[] tm = { new MyX509TrustManager() };
SSLContext sslContext = SSLContext.getInstance(“SSL”, “SunJSSE”);
sslContext.init(null, tm, new java.security.SecureRandom());
// 从上述SSLContext对象中得到SSLSocketFactory对象
SSLSocketFactory ssf = sslContext.getSocketFactory();

		URL url = new URL(requestUrl);
		HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
		conn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
		conn.setSSLSocketFactory(ssf);
		//输出(发送数据)
		conn.setDoOutput(true);
		//输入(接收数据)
		conn.setDoInput(true);
		//不使用缓存
		conn.setUseCaches(false);
		// 设置请求方式(GET/POST)
		conn.setRequestMethod("POST");

		// 当outputStr不为null时向输出流写数据
		if (strb.length() > 0) {
			OutputStream outputStream = conn.getOutputStream();
			// 注意编码格式
			outputStream.write(strb.toString().getBytes());
			// outputStream.write(strb.toString().getBytes("UTF-8"));
			outputStream.close();
		}

		// 从输入流读取返回内容
		InputStream inputStream = conn.getInputStream();
		InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		String str = null;
		StringBuffer buffer = new StringBuffer();
		while ((str = bufferedReader.readLine()) != null) {
			buffer.append(str);
		}

		// 释放资源
		bufferedReader.close();
		inputStreamReader.close();
		inputStream.close();
		inputStream = null;
		conn.disconnect();
		result = buffer.toString();
	} catch (ConnectException ce) {
		System.out.println("连接超时:{}"+ce);
	} catch (Exception e) {
		System.out.println("https请求异常:{}"+ e);
	}
	return result;
}

车牌识别部分代码展示
public static String MD5(String input) {
try {
// 获得MD5摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance(“MD5”);
// 使用指定的字节更新摘要
mdInst.update(input.getBytes());
// 获得密文
byte[] md = mdInst.digest();
// 把密文转换成十六进制的字符串形式
StringBuffer hexString = new StringBuffer();
// 字节数组转换为 十六进制 数
for (int i = 0; i < md.length; i++) {
String shaHex = Integer.toHexString(md[i] & 0xFF);
if (shaHex.length() < 2) {
hexString.append(0);
}
hexString.append(shaHex);
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return “”;
}
MD5加密算法

你可能感兴趣的:(笔记)