使用ABBYY提供的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,并等待返回结果,然后显示它。我所有的尝试都破坏了它。再次感谢。
发布于 2012-12-15 01:03:23
在这里,您无意中要做的是提交上传文件的文件名,而不是文件内容。现在有很多奇特的方法可以获取文件的内容,但是跳过正在做的所有奇特的AJAX操作、删除onClick处理程序并正常地提交表单会简单得多。
https://stackoverflow.com/questions/13883070
复制相似问题