使用 ABBYY 提供的 php 示例http://pastebin.com/SeN8mdya我已经能够将图像转换为文本。奇迹般有效。现在我正在尝试使用 Web 界面在移动设备上拍照并将其发送到 ABBYY ocr 服务并返回结果文本。我的拍照代码:
<!doctype html>
<html>
<head>
<title>Camera access on mobile web!</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
#container {
margin:0 auto;
padding:0;
width:200px;
}
div.message {
background-color:green;
border-radius:4px;
color:white;
display:none;
padding:5px 0;
text-align:center;
width:100%;
}
</style>
</head>
<body>
<div id="container">
<img src="logo-mobile.png" id="lunchbox-logo" />
<div class="message"><strong>Thanks for the submission!</strong></div>
<p>Submit your receipt straight from your web browser!!</p>
<form method="POST" enctype="multipart/form-data" action="http://cloud.ocrsdk.com/processImage?language=english&exportFormat=txt">
<input type="file" accept="image/*" name="receipt[data]">
<input type="button" onClick="submitReceipt();" value="Submit">
</form>
</div>
<script type="text/javascript">
function submitReceipt(){
var token = 'NEVER-COMMIT-TOKENS :)';
var file = document.getElementsByName('receipt[data]')[0].files[0];
fd = new FormData();
fd.append('access_token', token);
fd.append('receipt[data]', file);
req = new XMLHttpRequest();
req.open('POST', 'http://cloud.ocrsdk.com/processImage?language=english&exportFormat=txt');
req.send(fd);
document.getElementsByClassName('message')[0].style.display = "block";
}
</script>
</body>
</html>
两者都彼此独立工作。我希望相机页面将图片提交给ABBYY并等待返回结果然后显示。我所有的尝试都打破了它。再次感谢。