吕一航 2 years ago
parent 16251d7774
commit f6c7c9bd7a

Binary file not shown.

@ -1,3 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -1,12 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="OCR_baidu:jar">
<output-path>$PROJECT_DIR$/out/artifacts/OCR_baidu_jar</output-path>
<root id="archive" name="OCR_baidu.jar">
<element id="module-output" name="OCR_baidu" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/json-20160810.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/slf4j-simple-1.7.25.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/aip-java-sdk-4.16.11.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/slf4j-api-1.7.25.jar" path-in-jar="/" />
</root>
</artifact>
</component>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
</annotationProcessing>
</component>
</project>

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="aip-java-sdk-4.16.11">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/aip-java-sdk-4.16.11.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="json-20160810">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/json-20160810.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/json-20160810.jar!/" />
</SOURCES>
</library>
</component>

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="slf4j-api-1.7.25">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/slf4j-api-1.7.25.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="slf4j-simple-1.7.25">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/slf4j-simple-1.7.25.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CodeInsightWorkspaceSettings">
<option name="optimizeImportsOnTheFly" value="true" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/OCR_baidu.iml" filepath="$PROJECT_DIR$/OCR_baidu.iml" />
</modules>
</component>
</project>

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: OCR

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="aip-java-sdk-4.16.11" level="project" />
<orderEntry type="library" name="json-20160810" level="project" />
<orderEntry type="library" name="slf4j-api-1.7.25" level="project" />
<orderEntry type="library" name="slf4j-simple-1.7.25" level="project" />
</component>
</module>

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: HealthCode

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: HealthCode

File diff suppressed because it is too large Load Diff

@ -1,138 +0,0 @@
import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;
import java.util.HashMap;
public class CovidTestRep {
private String Name;
private String Time;
private String Status;
public CovidTestRep() {
Name = "";
Time = "";
Status = "";
}
public String getName() {
return Name;
}
public String getData() {
return Time;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
public void setName(String name) {
Name = name;
}
public void setData(String data) {
Time = data;
}
public void Print() {
System.out.println("Name:" + this.Name);
System.out.println("Data:" + this.Time);
System.out.println("Status:" + this.Status);
}
public static void main(String[] args) {
String path = "C:/Users//16491/eclipse-workspace/OCR_baidu/src/3.jpg";// 初始化一个AipOcr
ocr3(path);
}
public static String Judge(String path) {
CovidTestRep Ctr=new CovidTestRep();
Ctr=ocr3(path);
String StatusNameTime=Ctr.Status+","+Ctr.Name+","+Ctr.Time;
return StatusNameTime;
}
public static CovidTestRep ocr3(String path) {
final String APP_ID = "28049220";
final String API_KEY = "qyKlUy6xSapA89DTPomExteq";
final String SECRET_KEY = "q5EYpXULVh5gC3firLU1nGaymwIwOMBd";
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(10000);
// 可选:设置代理服务器地址, http和socket二选一或者均不设置
// client.setHttpProxy("proxy_host", proxy_port); // 设置http代理
// client.setSocketProxy("proxy_host", proxy_port); // 设置socket代理
// 可选设置log4j日志输出格式若不设置则使用默认配置
// 也可以直接通过jvm启动参数设置此环境变量
System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");
// 调用接口
JSONObject res = client.basicGeneral(path, new HashMap<String, String>());
/*Map<String,Object> m=res.toMap();
Set s=m.entrySet();*//*
for (Object str : s) {
System.out.println(str);
}
//System.out.println(s);*/
String str= res.toString(0);
/*for(int i=0;i<str.length();i++)
{char c=str.charAt(i);
System.out.println(i);
System.out.println(c);
}*/
//System.out.println(str);
String s="";
for(int i=0;i<str.length();i++){
char c=str.charAt(i);
if((c>='a'&&c<='z')||(c>='A'&&c<='Z')||c=='{'||c=='"'||c==':'||c=='}'||c==''||c=='_'){
continue;
}
else
s+=c;
if(c==']')break;
}
//System.out.println(s);
CovidTestRep CTR=new CovidTestRep();
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)=='姓'&&s.charAt(i+1)=='名')
{
String Na= CTR.getName();
i=i+3;
for(;s.charAt(i)!=',';i++)
{
Na+=s.charAt(i);
}
CTR.setName(Na);
}
if(s.charAt(i)=='采'&&s.charAt(i+1)=='样'&&s.charAt(i+2)=='时'&&s.charAt(i+3)=='间')
{
String Da= CTR.getData();
i=i+5;
for(;s.charAt(i)!=',';i++)
{
Da+=s.charAt(i);
}
CTR.setData(Da);
}
if(s.charAt(i)=='检'&&s.charAt(i+1)=='测'&&s.charAt(i+2)=='结'&&s.charAt(i+3)=='果')
{
String St= CTR.getStatus();
i=i+5;
for(;s.charAt(i)!=']';i++)
{
St+=s.charAt(i);
}
CTR.setStatus(St);
}
}
return CTR;
}
}

@ -1,129 +0,0 @@
import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;
import java.util.HashMap;
public class HealthCode {
private String Name;
private String Data;
private String Status;
public HealthCode() {
Name = "";
Data = "";
Status = "";
}
public String getName() {
return Name;
}
public String getData() {
return Data;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
public void setName(String name) {
Name = name;
}
public void setData(String data) {
Data = data;
}
public void Print() {
System.out.println("Name:" + this.Name);
System.out.println("Data:" + this.Data);
System.out.println("Status:" + this.Status);
}
public static void main(String[] args) {
String path = "C:/Users//16491/eclipse-workspace/OCR_baidu/src/1.jpg";
System.out.println(Judge(path));
}
public static String Judge(String path) {
HealthCode H = new HealthCode();
H = ocr1(path);
String StatusNameData = "S"+H.Status + "," + H.Name + "," + H.Data+"E";
return StatusNameData;
}
/*class OCR {
//设置APPID/AK/SK
public OCR(){
}*/
public static HealthCode ocr1(String path) {
final String APP_ID = "28049220";
final String API_KEY = "qyKlUy6xSapA89DTPomExteq";
final String SECRET_KEY = "q5EYpXULVh5gC3firLU1nGaymwIwOMBd";
// 初始化一个AipOcr
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
// 可选:设置代理服务器地址, http和socket二选一或者均不设置
// client.setHttpProxy("proxy_host", proxy_port); // 设置http代理
// client.setSocketProxy("proxy_host", proxy_port); // 设置socket代理
// 可选设置log4j日志输出格式若不设置则使用默认配置
// 也可以直接通过jvm启动参数设置此环境变量
System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");
// 调用接口
JSONObject res = client.basicGeneral(path, new HashMap<String, String>());
String str= res.toString(0);
int flag = 0;
int flag1 = 0;
int flag2 = 0;
HealthCode HC = new HealthCode();
for (int i = 16; i < str.length(); i++) {
char c = str.charAt(i);
if (c == '[' && flag == 0) {
flag = 1;
} else if (flag == 1 && c == ']') {
break;
} else {
if (i == 27) {
String N = HC.getName();
for (; str.charAt(i) != '\"'; i++) {
N = N + str.charAt(i);
}
HC.setName(N);
}
if (str.charAt(i) == '-' && flag1 == 0) {
flag1 = 1;
String D = HC.getData();
for (i = i - 4; str.charAt(i) != '\"'; i++) {
D = D + str.charAt(i);
}
HC.setData(D);
}
if (str.charAt(i) == '码' && flag2 == 0) {
flag2 = 1;
String S = HC.getStatus();
S = S + str.charAt(i - 1);
HC.setStatus(S);
}
}
}
return HC;
}
}

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: HealthCode

@ -1,146 +0,0 @@
import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;
import java.util.HashMap;
public class TripCode {
private String Status;
private String Telephone;
private String Time;
private String District;
public TripCode() {
Status = "";
Telephone = "";
Time = "";
District = "";
}
public void setStatus(String status) {
Status = status;
}
public void setTelephone(String telephone) {
Telephone = telephone;
}
public void setTime(String time) {
Time = time;
}
public void setDistrict(String district) {
District = district;
}
public String getTelephone() {
return Telephone;
}
public String getStatus() {
return Status;
}
public String getDistrict() {
return District;
}
public String getTime() {
return Time;
}
public void Print() {
System.out.println("Status:" + this.Status);
System.out.println("Telephone:" + this.Telephone);
System.out.println("Time:" + this.Time);
System.out.println("District:" + this.District);
}
public static void main(String[] args) {
String path = "C:\\Users\\16491\\Desktop\\1.jpg";
System.out.println(Judge(path));
}
/*};
class OCR2 {
//设置APPID/AK/SK*/
public static String Judge(String path) {
TripCode T = new TripCode();
T = ocr2(path);
String InfM = T.Status + "," + T.Telephone + "," + T.Time + "," + T.District;
return InfM;
}
public static TripCode ocr2(String path) {
final String APP_ID = "28049220";
final String API_KEY = "qyKlUy6xSapA89DTPomExteq";
final String SECRET_KEY = "q5EYpXULVh5gC3firLU1nGaymwIwOMBd";
// 初始化一个AipOcr
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(10000);
// 可选:设置代理服务器地址, http和socket二选一或者均不设置
// client.setHttpProxy("proxy_host", proxy_port); // 设置http代理
// client.setSocketProxy("proxy_host", proxy_port); // 设置socket代理
// 可选设置log4j日志输出格式若不设置则使用默认配置
// 也可以直接通过jvm启动参数设置此环境变量
System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");
// 调用接口
JSONObject res = client.basicGeneral(path, new HashMap<String, String>());
//System.out.println(res);
String str = res.toString(0);
//System.out.println(str);
String s = "";
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '{' || c == '"' || c == ':' || c == '}' || c == '' || c == '_') {
continue;
} else
s += c;
if (c == ']') break;
}
//System.out.println(s);
TripCode TC = new TripCode();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '的' && s.charAt(i + 1) == '动' && s.charAt(i + 2) == '态' && s.charAt(i + 3) == '行' && s.charAt(i + 4) == '程' && s.charAt(i + 5) == '卡') {
String tel = TC.getTelephone();
for(;s.charAt(i)!=',';i--);
i++;
for (; s.charAt(i) != ','; i++) {
tel += s.charAt(i);
}
TC.setTelephone(tel);
}
if (s.charAt(i) == '请' && s.charAt(i + 1) == '收' && s.charAt(i + 2) == '下') {
String St = TC.getStatus();
i = i + 3;
for (; s.charAt(i) != ','; i++) {
St += s.charAt(i);
}
TC.setStatus(St);
}
if (s.charAt(i) == '更' && s.charAt(i + 1) == '新' && s.charAt(i + 2) == '于') {
String Data = TC.getTime();
i = i + 3;
for (; s.charAt(i) != ','; i++) {
Data += s.charAt(i);
}
TC.setTime(Data);
}
if (s.charAt(i) == '到' && s.charAt(i + 1) == '达' && s.charAt(i + 2) == '或' && s.charAt(i + 3) == '途' && s.charAt(i + 4) == '经') {
String Dis = TC.getDistrict();
i = i + 5;
for (; s.charAt(i) != ']'; i++) {
Dis += s.charAt(i);
}
TC.setDistrict(Dis);
}
}
return TC;
}
}
Loading…
Cancel
Save