c# - 带有 Microsoft OCR 的 Visual Studio
问题描述
我正在做一个关于 OCR 的项目。我正在使用 Microsoft OCR。我的要求是当我单击“下一步”按钮时,它会出现保存到我的 Visual Studio 文件夹下的图像,/wwwroot/images/uploadedFiles
如下所示:
我尝试运行代码。一直显示网页中未找到的错误:
下面是我的代码,我使用的是 MVC 版本:
<button id="buttonOCR" class="btn btn-default" style="background-color:yellowgreen">Next</button>
<img id="myImage" src="~/images/loading.jpg" width="100" />
$(document).ready(function () {
$("#buttonOCR").click(function () {
$("#myImage").attr("src", "../../images/UploadedFiles/20180627165414519.jpg");
$("#myImage").attr("width", "500");
processImage("../../images/UploadedFiles/20180627165414519.jpg");
});
});
function processImage(thisImage) {
// **********************************************
// *** Update or verify the following values. ***
// **********************************************
// Replace the subscriptionKey string value with your valid subscription key.
var subscriptionKey = "*****************"; // subscription key
// Replace or verify the region.
//
// You must use the same region in your REST API call as you used to obtain your subscription keys.
// For example, if you obtained your subscription keys from the westus region, replace
// "westcentralus" in the URI below with "westus".
//
// NOTE: Free trial subscription keys are generated in the westcentralus region, so if you are using
// a free trial subscription key, you should not need to change this region.
var uriBase = "https://southeastasia.api.cognitive.microsoft.com/vision/v1.0/ocr";
// Request parameters.
var params = {
"language": "unk",
"detectOrientation": "true",
};
// Perform the REST API call.
$.ajax({
url: uriBase + "?" + $.param(params),
// Request headers.
beforeSend: function (jqXHR) {
jqXHR.setRequestHeader("Content-Type", "application/json");
jqXHR.setRequestHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
},
type: "POST",
// Request body.
processData: false,
url: thisImage
})
.done(function (url) {
// Show formatted JSON on webpage.
$("#responseTextArea").val(JSON.stringify(url, null, 2));
})
.fail(function (jqXHR, textStatus, errorThrown) {
// Display error message.
var errorString = (errorThrown === "") ? "Error. " : errorThrown + " (" + jqXHR.status + "): ";
errorString += (jqXHR.responseText === "") ? "" : (jQuery.parseJSON(jqXHR.responseText).message) ?
jQuery.parseJSON(jqXHR.responseText).message : jQuery.parseJSON(jqXHR.responseText).error.message;
alert(errorString);
});
};
</script>
谢谢您的帮助!我真的需要帮助!下面的链接是我研究过并尝试用于我的编码: https ://southeastasia.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fc/console
解决方案
推荐阅读
- java - 基于通量大小的条件
- github - 将重复链接转换为markdown中的引用
- c++ - 使用 ReadFile 函数从进程中读取数据
- c - 为什么我的反转字符数组会打印额外的一行?
- java - Java 泛型,返回类型以仅访问抽象类型的受保护方法
- pandas - Anaconda Pandas 安装版本与 Jupyter Notebook 版本不匹配
- javascript - 如何设置此异步等待函数的输出样式,该函数成功地从数据库中获取数据?
- javascript - 作为道具传递的反应状态不会在子组件中更新
- matrix - Torch 对除索引之外的每一行求和
- r - 在 mapEdit 包中使用 EditMod 时从 $finished 刷新数据的闪亮解决方法