java_baidu_ocr

Java调用百度OCR文字识别API实现图片文字识别软件

这是一款小巧方便,强大的文字识别软件,由Java编写,配上了窗口界面

调用了百度ocr文字识别API 识别精度高。

完整项目放在GitHub:https://github.com/Ymy214/java_baidu_ocr

更新日志

新的改变 OcrViewer 2.0 更新于 2019.1.18

我对OcrViewer进行了一些功能拓展与界面美化,除了标准的本地图片识别功能,我增加了如下几点新功能,帮助你更方便使用本工具,进而更好地识别图像中的文字:

    1. 全新的界面设计,将会带来全新的使用体验;
    1. 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
    1. 增加了 截图识别 功能,你可以通过截取图片直接直接进行识别;
    1. 增加了图片预览功能,更加方便进行图文对比,减少容错;
    1. 增加了 清除图片预览 功能,可以清清除览的图片;
    1. 增加了 重新识别 等功能,如果不确定可以多次识别提高识别精确率;

下面是功能以及新界面展示

  • 识别出师表.png

  • 截图出师表 .png识别结果

  • 识别代码.png

  • 代码.png识别结果

  • 识腾讯新闻弹窗.png

  • 腾讯新闻弹窗.png识别结果

  • 软件界面

Java源代码:

  • 主窗口类 FileChooserOCR2.java
package baiduOcr;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.HashMap; import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea; import org.json.JSONArray;
import org.json.JSONObject;
import com.baidu.aip.ocr.AipOcr; @SuppressWarnings("serial")
public class FileChooserOCR2 extends JFrame implements ActionListener
{
// 设置APPID/AK/SK
public static final String appId = "15289864";
public static final String apiKey = "j0pj5Y7HVElkLnmn2LEXKeyO";
public static final String secretKey = "FKVbH7EBcGy4DIaqPnXcqE47eACzn2W7"; AipOcr client = new AipOcr(appId, apiKey, secretKey);
JButton open, re0, copy, screen, reset, reocr, b6;
JPanel ocrPanel, pNorth, pSouth, pWest, pEast, pCenter, pCenterLeft, pCenterRight;
JTextArea ocrText;
JLabel previewLabel, printLabel;
ImageIcon defaultPreviewImg;
JScrollPane areaScroll;
String filePath = "./img/preview.jpg";
BufferedImage screenImage;// 用与子窗体给父窗体传值
// 构造方法 public FileChooserOCR2()
{
// 主面板
ocrPanel = new JPanel();
ocrPanel.setLayout(new BorderLayout()); // 各个按钮
open = new JButton("[选择图片>>>文字识别]");
re0 = new JButton("清空");
copy = new JButton("复制");
screen = new JButton("[截图识别]");
reset = new JButton("清除");
reocr = new JButton("重识");
b6 = new JButton("b6");
// 设置各按钮字体
open.setFont(new Font("宋体", Font.BOLD, 18));
screen.setFont(new Font("宋体", Font.BOLD, 18));
copy.setFont(new Font("宋体", Font.BOLD, 18));
re0.setFont(new Font("宋体", Font.BOLD, 18));
reset.setFont(new Font("宋体", Font.BOLD, 18));
reocr.setFont(new Font("宋体", Font.BOLD, 18));
b6.setFont(new Font("宋体", Font.BOLD, 18));
// 图片预览标签以及状态提示标签
defaultPreviewImg = new ImageIcon("./img/preview.jpg");
previewLabel = new JLabel(defaultPreviewImg);
printLabel = new JLabel("输出:");
// 文本域
ocrText = new JTextArea("输出内容。。。");
ocrText.setEditable(true);
ocrText.setVisible(true);
ocrText.setFont(new Font("宋体", Font.BOLD, 18));
// 各方位分面板
pWest = new JPanel(new GridLayout(2, 0));
pEast = new JPanel(new GridLayout(2, 2));
pSouth = new JPanel(new GridLayout(0, 2));
pCenter = new JPanel(new GridLayout(0, 2));
pCenterLeft = new JPanel(new CardLayout());
pCenterRight = new JPanel(new CardLayout()); // 默认预览图片是否伸缩
// previewImg.setImage(previewImg.getImage().getScaledInstance(340,
// 466,Image.SCALE_DEFAULT));
// previewLabel.setIcon(previewImg);
// // 文本域的滚动条
areaScroll = new JScrollPane(ocrText);
// 设置横向滚动条始终开启
// areaScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// 设置垂直滚动条始终开启
// areaScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// 设置横向滚动条自动(有需要时)开启
areaScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
// 设置垂直滚动条自动(有需要时)开启
areaScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); // 添加监听
open.addActionListener(this);
re0.addActionListener(this);
copy.addActionListener(this);
screen.addActionListener(this);
reset.addActionListener(this);
reocr.addActionListener(this); // 各组件依次加入相应方位面板
pCenterLeft.add(previewLabel);
// pCenterRight.add(ocrText);
pCenterRight.add(areaScroll); pWest.add(reocr);
pWest.add(reset); pSouth.add(screen);
pSouth.add(printLabel);
pCenter.add(pCenterLeft);
pCenter.add(pCenterRight);
pEast.add(copy);
pEast.add(re0); // 各方位面板加入主面板
ocrPanel.add(open, BorderLayout.NORTH);
ocrPanel.add(pWest, BorderLayout.WEST);
ocrPanel.add(pEast, BorderLayout.EAST);
ocrPanel.add(pCenter, BorderLayout.CENTER);
ocrPanel.add(pSouth, BorderLayout.SOUTH); ocrPanel.setSize(300, 300);
this.add(ocrPanel);
this.setBounds(400, 200, 900, 600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override
public void actionPerformed(ActionEvent e)
{ if (e.getSource() == re0)
{
ocrText.setText("已清空内容。。。");
printLabel.setText("输出:已清空内容。。。");
}
if (e.getSource() == copy)
{
String jianqieban = ocrText.getText();
setSysClipboardText(jianqieban);
printLabel.setText("输出:已复制到剪贴板。。。");
}
if (e.getSource() == screen)
{
new ScreenShotTest(this);
// 现已实现为截屏功能, 截屏功能已经封装到一个类文件中,参考的代码
}
if (e.getSource() == reocr)
{
ocrText.setText(imgOcr(filePath));
printLabel.setText("输出:已重新识别。。。");
}
if (e.getSource() == reset)
{
previewLabel.setIcon(defaultPreviewImg);
filePath = "./img/preview.jpg";
printLabel.setText("输出:已清除预览。。。");
}
if (e.getSource() == open)
{
printLabel.setText("输出:选择文件。。。");
System.out.println(e.getSource());
// TODO Auto-generated method stub
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
jfc.showDialog(new JLabel(), "选择");
File file = jfc.getSelectedFile();
if (file.isDirectory())
{
System.out.println("(选择目录) $ " + file.getAbsolutePath());
System.out.println("请选择图片。。。");
} else if (file.isFile())
{
filePath = file.getAbsolutePath();
ImageIcon ocrImg = new ImageIcon(filePath);
System.out.println("(选择文件) $ " + filePath);
ocrText.setText("正在识别。。。");
// 缩放后的图片,用到了一个图片缩放算法
ocrImg.setImage(ocrImg.getImage().getScaledInstance(340, 470, Image.SCALE_DEFAULT));
previewLabel.setIcon(ocrImg);
String ocrStr = imgOcr(filePath);
printLabel.setText("输出:正在识别。。。");
ocrText.setText(ocrStr);
printLabel.setText("输出:识别完毕!!!。。。"); }
System.out.println("正在识别>>>" + jfc.getSelectedFile().getName());
} } // 复制到剪贴板的方法
public static void setSysClipboardText(String writeMe)
{
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(writeMe);
clip.setContents(tText, null);
} // 主方法
public static void main(String[] args)
{
FileChooserOCR2 ocrWin = new FileChooserOCR2();
ocrWin.setVisible(true);
} /*
* 文字识别方法
*/
public String imgOcr(String imgpath)
{
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("language_type", "CHN_ENG");
options.put("detect_direction", "true");
options.put("detect_language", "true");
options.put("probability", "true"); // 参数为本地路径
JSONObject res = client.basicGeneral(imgpath, options);
// 解析json-------------
JSONArray wordsResult = (JSONArray) res.get("words_result");
String ocrStr = "\n";
for (Object obj : wordsResult)
{
JSONObject jo = (JSONObject) obj;
ocrStr += jo.getString("words") + "\n";
} // 解析json-------------
return ocrStr;
// return res.toString(2); } /*
* 文字识别方法(方法的重载)
*/
public String imgOcr(byte[] imgInbyte)
{
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("language_type", "CHN_ENG");
options.put("detect_direction", "true");
options.put("detect_language", "true");
options.put("probability", "true"); // 参数为二进制数组
JSONObject res = client.basicGeneral(imgInbyte, options);
// 解析json-------------
JSONArray wordsResult = (JSONArray) res.get("words_result");
String ocrStr = "\n";
for (Object obj : wordsResult)
{
JSONObject jo = (JSONObject) obj;
ocrStr += jo.getString("words") + "\n";
} // 解析json-------------
return ocrStr;
// return res.toString(2); } } ////////////////////////////////////////////////////////////////////////////////////////////////
package baiduOcr;

import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date; import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JToolBar;
import javax.swing.JWindow;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.filechooser.FileSystemView; public class ScreenShotTest
{
private FileChooserOCR2 superWindow; public ScreenShotTest(FileChooserOCR2 superWimdow)
{
this.superWindow = superWimdow;
EventQueue.invokeLater(new Runnable() {
@Override
public void run()
{
try
{
new ScreenShotWindow(superWindow);
} catch (AWTException e)
{
e.printStackTrace();
}
}
});
} } /*
* 截图窗口
*/
class ScreenShotWindow extends JWindow
{ private int orgx, orgy, endx, endy;
private BufferedImage image = null;
private BufferedImage tempImage = null;
private BufferedImage saveImage = null; private ToolsWindow tools = null; private FileChooserOCR2 superWin; public ScreenShotWindow(FileChooserOCR2 superWindow) throws AWTException
{
this.superWin = superWindow; // 获取屏幕尺寸
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds(0, 0, d.width, d.height); // 截取屏幕
Robot robot = new Robot();
image = robot.createScreenCapture(new Rectangle(0, 0, d.width, d.height)); this.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e)
{
// 鼠标松开时记录结束点坐标,并隐藏操作窗口
orgx = e.getX();
orgy = e.getY(); if (tools != null)
{
tools.setVisible(false);
}
} @Override
public void mouseReleased(MouseEvent e)
{
// 鼠标松开时,显示操作窗口
if (tools == null)
{
tools = new ToolsWindow(ScreenShotWindow.this, e.getX(), e.getY());
} else
{
tools.setLocation(e.getX(), e.getY());
}
tools.setVisible(true);
tools.toFront();
}
}); this.addMouseMotionListener(new MouseMotionAdapter() { @Override
public void mouseDragged(MouseEvent e)
{
// 鼠标拖动时,记录坐标并重绘窗口
endx = e.getX();
endy = e.getY(); // 临时图像,用于缓冲屏幕区域放置屏幕闪烁
Image tempImage2 = createImage(ScreenShotWindow.this.getWidth(), ScreenShotWindow.this.getHeight());
Graphics g = tempImage2.getGraphics();
g.drawImage(tempImage, 0, 0, null);
int x = Math.min(orgx, endx);
int y = Math.min(orgy, endy);
int width = Math.abs(endx - orgx) + 1;
int height = Math.abs(endy - orgy) + 1;
// 加上1防止width或height0
g.setColor(Color.BLUE);
g.drawRect(x - 1, y - 1, width + 1, height + 1);
// 减1加1都了防止图片矩形框覆盖掉
saveImage = image.getSubimage(x, y, width, height);
g.drawImage(saveImage, x, y, null); ScreenShotWindow.this.getGraphics().drawImage(tempImage2, 0, 0, ScreenShotWindow.this);
}
}); this.setVisible(true);
} @Override
public void paint(Graphics g)
{
RescaleOp ro = new RescaleOp(0.8f, 0, null);
tempImage = ro.filter(image, null);
g.drawImage(tempImage, 0, 0, this);
} // 保存图像到文件
public void saveImage() throws IOException
{
// 先隐藏窗口后台执行,显得程序执行很快
this.setVisible(false);
tools.setVisible(false); JFileChooser jfc = new JFileChooser();
jfc.setDialogTitle("保存"); // 文件过滤器,用户过滤可选择文件
FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "jpg");
jfc.setFileFilter(filter); // 初始化一个默认文件(此文件会生成到桌面上)
SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddHHmmss");
String fileName = sdf.format(new Date());
File filePath = FileSystemView.getFileSystemView().getHomeDirectory();
File defaultFile = new File(filePath + File.separator + fileName + ".jpg");
jfc.setSelectedFile(defaultFile); int flag = jfc.showSaveDialog(this);
if (flag == JFileChooser.APPROVE_OPTION)
{
File file = jfc.getSelectedFile();
String path = file.getPath();
// 检查文件后缀,放置用户忘记输入后缀或者输入不正确的后缀
if (!(path.endsWith(".jpg") || path.endsWith(".JPG")))
{
path += ".jpg";
}
// 写入文件
superWin.printLabel.setText("输出:已保存截图!!!");
ImageIO.write(saveImage, "jpg", new File(path)); dispose();
}
} // 返回截取的图片
public void okImage()
{ this.setVisible(false);
tools.setVisible(false);
superWin.printLabel.setText("输出:识别截图成功!!!");
ByteArrayOutputStream baos = null;
try
{
baos = new ByteArrayOutputStream();
ImageIO.write(saveImage, "jpg", baos);
byte[] imageInByte = baos.toByteArray();// 使用toByteArray()方法转换成字节数组
superWin.ocrText.setText(superWin.imgOcr(imageInByte));
baos.flush();// 会产生IOException异常 } catch (IOException e1)
{
e1.printStackTrace();
} finally
{
try
{
if (baos != null)
{
baos.close();
}
} catch (Exception ex)
{
ex.printStackTrace();
}
} dispose();
} /*
* 文字识别方法(方法的重载) 用父窗口类的
*/ /*
* 文字识别方法
*/ } /*
* 操作窗口
*/
class ToolsWindow extends JWindow implements ActionListener
{
private ScreenShotWindow parent; JButton saveButton, closeButton, okButton; public ToolsWindow(ScreenShotWindow parent, int x, int y)
{
this.parent = parent;
this.setLayout(new BorderLayout());
JToolBar toolBar = new JToolBar("Java 截图"); // 保存按钮
saveButton = new JButton("◰");
// 关闭按钮
closeButton = new JButton("✘");
// 选定按钮
okButton = new JButton("✔"); saveButton.addActionListener(this);
closeButton.addActionListener(this);
okButton.addActionListener(this); toolBar.add(saveButton);
toolBar.add(closeButton);
toolBar.add(okButton); this.add(toolBar, BorderLayout.NORTH); this.setLocation(x, y);
this.pack();
this.setVisible(true);
} @Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
if (e.getSource() == saveButton)
{
try
{
parent.saveImage();
dispose();
} catch (IOException e1)
{
e1.printStackTrace();
}
}
if (e.getSource() == closeButton)
{
parent.dispose();
dispose();
// System.exit(0);
}
if (e.getSource() == okButton)
{
// 返回选定的图片
parent.okImage();
dispose();
}
} }

↑↑↑↑↑↑↑↑↑↑↑↑以上为2019.1.18日OcrViewer2.0第二代↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

↓↓↓↓↓↓↓↓↓↓↓↓以下为2019.1.12日OcrViewer1.0第一代↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

  • 打包生成了jar可执行程序

  • 完整项目GitHub地址 新人有帮助有用的话请给个star谢谢了!

  • https://github.com/Ymy214/java_baidu_ocr

  • 识别图一

  • 图一识别结果

  • 识别图二

  • 图二识别结果

  • 识别图三

  • 图三识别结果

  • 软件界面

Java源代码:


package baiduOcr; import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea; import org.json.JSONArray;
import org.json.JSONObject;
import com.baidu.aip.ocr.AipOcr; @SuppressWarnings("serial")
public class FileChooserOCR extends JFrame implements ActionListener
{
// 设置APPID/AK/SK
public static final String appId = "15289864";
public static final String apiKey = "j0pj5Y7HVElkLnmn2LEXKeyO";
public static final String secretKey = "FKVbH7EBcGy4DIaqPnXcqE47eACzn2W7"; AipOcr client = new AipOcr(appId, apiKey, secretKey);
JButton open, b1, b2, b3;
JPanel ocrPanel;
JTextArea ocrText;
JScrollPane areaScroll; // 构造方法
public FileChooserOCR()
{
ocrPanel = new JPanel();
ocrPanel.setLayout(new BorderLayout());
open = new JButton("选择图片>>>文字识别");
b1 = new JButton("清空");
b2 = new JButton("复制");
b3 = new JButton("配置");
open.setFont(new Font("宋体", Font.BOLD, 18));
b3.setFont(new Font("宋体", Font.BOLD, 18));
b2.setFont(new Font("宋体", Font.BOLD, 18));
b1.setFont(new Font("宋体", Font.BOLD, 18)); //文本域的滚动条
// areaScroll = new JScrollPane(ocrText);
// areaScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// areaScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//添加监听
open.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this); ocrText = new JTextArea("输出内容。。。");
ocrText.setEditable(true);
ocrText.setVisible(true);
ocrText.setFont(new Font("宋体", Font.BOLD, 18));
ocrPanel.add(open, BorderLayout.NORTH);
ocrPanel.add(b1, BorderLayout.EAST);
ocrPanel.add(b2, BorderLayout.WEST);
ocrPanel.add(b3, BorderLayout.SOUTH);
ocrPanel.add(ocrText, BorderLayout.CENTER);
// ocrPanel.add(areaScroll);
ocrPanel.setSize(300, 300);
this.add(ocrPanel);
this.setBounds(400, 200, 900, 600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
ocrText.setText("已清空内容。。。");
}
if(e.getSource()==b2)
{
String jianqieban = ocrText.getText();
setSysClipboardText(jianqieban);
}
if (e.getSource()==b3)
{
//日后实现
}
if(e.getSource()==open)
{
System.out.println(e.getSource());
// TODO Auto-generated method stub
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
jfc.showDialog(new JLabel(), "选择");
File file = jfc.getSelectedFile();
if (file.isDirectory())
{
System.out.println("(选择目录) $ " + file.getAbsolutePath());
System.out.println("请选择图片。。。");
}
else if (file.isFile())
{
System.out.println("(选择文件) $ " + file.getAbsolutePath());
ocrText.setText("正在识别。。。");
String ocrStr = this.imgOcr(file.getAbsolutePath());
ocrText.setText(ocrStr);
}
System.out.println("正在识别>>>"+jfc.getSelectedFile().getName());
} } //复制到剪贴板
public static void setSysClipboardText(String writeMe) {
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(writeMe);
clip.setContents(tText, null);
} // 主方法
public static void main(String[] args)
{
FileChooserOCR ocrWin = new FileChooserOCR();
ocrWin.setVisible(true);
}
/*
* 文字识别方法
*/
public String imgOcr(String imgpath)
{
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("language_type", "CHN_ENG");
options.put("detect_direction", "true");
options.put("detect_language", "true");
options.put("probability", "true"); // 参数为本地路径
JSONObject res = client.basicGeneral(imgpath, options);
//解析json-------------
JSONArray wordsResult = (JSONArray)res.get("words_result");
String ocrStr = "\n";
for(Object obj : wordsResult)
{
JSONObject jo = (JSONObject)obj;
ocrStr += jo.getString("words") + "\n";
} //解析json-------------
return ocrStr;
// return res.toString(2); // 参数为二进制数组
// byte[] file = readFile("test.jpg");
// res = client.basicGeneral(file, options);
// System.out.println(res.toString(2)); // 通用文字识别, 图片参数为远程url图片
// JSONObject res = client.basicGeneralUrl(url, options);
// System.out.println(res.toString(2)); } }

完整项目放在GitHub:https://github.com/Ymy214/java_baidu_ocr

Java文字识别软件-调用百度ocr实现文字识别的更多相关文章

  1. 一篇文章搞定百度OCR图片文字识别API

    一篇文章搞定百度OCR图片文字识别API https://www.jianshu.com/p/7905d3b12104

  2. python截图+百度ocr(图片识别)+ 百度翻译

    一直想用python做一个截图并自动翻译的工具,恰好最近有时间就在网上找了资料,根据资料以及自己的理解做了一个简单的截图翻译工具.整理一下并把代码放在github给大家参考.界面用python自带的G ...

  3. 微信小程序接入百度OCR(身份证识别)

    微信小程序接入百度OCR(身份证识别) 1.接口描述 支持对二代居民身份证正反面所有8个字段进行结构化识别,包括姓名.性别.民族.出生日期.住址.身份证号.签发机关.有效期限,识别准确率超过99%:同 ...

  4. python 调用百度接口 做人脸识别

    操作步骤差不多,记得要在百度AIPI中的控制台中创建对应的工单 创建工单成功后 会生成两个key  这个两个key是要生成tokn 用 这里大家可以用 def函数 将token返回 供下面的接口使用 ...

  5. python调用百度语音识别接口实时识别

    1.本文直接上干货 奉献代码:https://github.com/wuzaipei/audio_discern/tree/master/%E8%AF%AD%E9%9F%B3%E8%AF%86%E5% ...

  6. 百度 OCR API 的使用以及与 Tesseract 的简单对比

    目录 百度 OCR API 初探 用 Python 调用百度 OCR API 与 Tesseract 的简单对比 百度 OCR API 初探 近日得知百度在其 APIStore 上开放了 OCR 的 ...

  7. 怎么提高OCR文字识别软件的识别正确率

    在OCR文字识别软件当中,ABBYY FineReader是比较好用的程序之一,但再好的识别软件也不能保证100%的识别正确率,用户都喜欢软件的正确率高一些,以减轻识别后修正的负担,很多用户也都提过这 ...

  8. 利用百度OCR实现验证码自动识别

    在爬取网站的时候都遇到过验证码,那么我们有什么方法让程序自动的识别验证码呢?其实网上已有很多打码平台,但是这些都是需要money.但对于仅仅爬取点数据而接入打码平台实属浪费.所以百度免费ocr正好可以 ...

  9. 调用百度汇率api 获取各国的汇率值

    设置一个定时任务,每天更新汇率java代码如下 package com.thinkgem.jeesite.modules.huiLvApi.service; import java.io.Buffer ...

随机推荐

  1. python -- 犯过的错之变量作用域

    1.写代码时发现取得变量值,会被覆盖,改为图二的写法后case_id则不会覆盖. 原因:可以理解为变量是内存中一个对象的“引用”.在函数参数传值时,变量也是内存对象的引用. 当对象为可更改对象时,是引 ...

  2. HZNU-ACM寒假集训Day10小结 树-树形DP

    树形DP 加分二叉树 洛谷P1040 注意中序遍历的特点:当根节点编号k时,编号小于k的都在其左子树上,编号大于k的都在右子树 转移方程 f[i,j]=max{f[i,k-1]*f[k+1,j]+d[ ...

  3. SASS- 局部文件(Partial)

    SASS – 简介 SASS – 环境搭建 SASS – 使用Sass程序 SASS – 语法 SASS – 变量 SASS- 局部文件(Partial) SASS – 混合(Mixin) SASS ...

  4. Mybatis 持久化,持久层

    持久化 持久化是将程序数据在持久状态和瞬时状态间转换的机制. 即把数据(如内存中的对象)保存到可永久保存的存储设备中(如磁盘).持久化的主要应用是将内存中的对象存储在数据库中,或者存储在磁盘文件中.X ...

  5. SQL基础之JDBC、连接池

    JDBC JDBC四个核心对象 这几个类都是在java.sql包中 DriverManager(类): 数据库驱动管理类.这个类的作用:1)注册驱动; 2)创建java代码和数据库之间的连接,即获取C ...

  6. POJ - 3662 Telephone Lines (dijstra+二分)

    题意:有N个独立点,其中有P对可用电缆相连的点,要使点1与点N连通,在K条电缆免费的情况下,问剩下的电缆中,长度最大的电缆可能的最小值为多少. 分析: 1.二分临界线(符合的情况的点在右边),找可能的 ...

  7. 吴裕雄--天生自然 JAVASCRIPT开发学习:DOM EventListener

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Nginx和php交互的两种方式

    Unix socket 也叫IPC socket  也就是进程间通信套接字用于同一台主机上的不同进程间交换数据 TCP socket IP socket要利用主机的传输层(tcp),可以用于同一台主机 ...

  9. idea使用eclipse风格

    说明,只是代码编辑区采用eclipse风格,其他用的是idea的IntelliJ(白色风格) 1.下载文件 2.配置

  10. 在vSphere群集中配置EVC的注意事项

    原路径:https://blog.51cto.com/wangchunhai/2084434 个人觉得有一点写的有出入: 2 vCenter保存在本地存储中,无共享存储 中主机图片和描述信息有异常. ...