自学内容网 自学内容网

营业执照OCR识别API接口如何用C#调用

服务器和计算设备的性能不断提升,为 OCR 识别提供了更强大的计算能力支持。更快的 CPU、GPU 以及分布式计算技术的应用,使得营业执照图片的处理速度大幅加快,能够在更短的时间内完成大量营业执照的识别工作。

研发人员不断对 OCR 识别算法进行优化,减少不必要的计算步骤和时间消耗。采用并行处理、多线程技术等,让识别系统能够同时处理多个任务,进一步提高识别速度。例如,一些先进的 OCR 识别 API 接口可以在几秒内完成一张营业执照的识别,满足了企业和机构对高效处理的需求。

以下是C#实现营业执照OCR识别API接口的示例代码:

using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;

public class ApiDemo {
    private const String url = "https://api.shuxuntech.com/v1/business/ocr";
    private const String method = "POST";
    private const String appKey = "您的appKey";
    private const String appSecret = "您的appSecret";

    public static void Main(string[] args) {
        TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
        String timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
        String sign = SHA256(appKey + timestamp + appSecret);

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        httpRequest = (HttpWebRequest) WebRequest.CreateDefault(new Uri(url));
        httpRequest.Method = method;
        httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";

        httpRequest.Headers.Add("appKey", appKey);
        httpRequest.Headers.Add("timestamp", timestamp);
        httpRequest.Headers.Add("sign", sign);

        String image = "";
        String imgUrl = "";
        String params = "image=" + image + "&imgUrl=" + imgUrl;

        byte[] data = Encoding.UTF8.GetBytes(params);
        using (Stream stream = httpRequest.GetRequestStream()) {
            stream.Write(data, 0, data.Length);
        }

        httpResponse = (HttpWebResponse) httpRequest.GetResponse();
        Console.WriteLine(httpResponse.StatusCode);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
    }

    public static string SHA256(string str) {
        byte[] SHA256Data = Encoding.UTF8.GetBytes(str);
        SHA256Managed Sha256 = new SHA256Managed();
        byte[] by = Sha256.ComputeHash(SHA256Data);
        return BitConverter.ToString(by).Replace("-", "").ToLower();
    }
}

返回的数据:

(1)正确返回:


    "code": "0",
    "msg": "成功",
    "isFee": 1,
    "seqNo": "98ik48a942udag92uxvhz1jw2txplza9",
    "data": {
        "result": 1,
        "resultDesc": "识别成功,有数据",
        "info": {
            "enterpriseType": "有限责任公司(自然人独资)",
            "address": "浙江省杭州市余杭区五常街道瑞谷中心7幢5层525-7室",
            "registrationCapital": "壹佰万元整",
            "opTo": "",
            "orgForm": "",
            "opScope": "一般项目:技术服务、技术开发、技术咨询、技术交流、技术转让、技术推广:信息系统集成服务:大数据服务:软件开发;数字内容制作服务(不含出版发行):互联网数据服务:网络与信息安全软件开发:人工智能公共数据平台:信息技术咨询服务:数据处理服务:计算机系统服务:企业管理咨询:计算机软硬件及辅助设备批发:计算机软硬件及辅助设备零售:电子产品销售;通讯设备销售:互联网销售(除销售需要许可的商品)(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)",
            "establishingDate": "2022-09-13",
            "legalName": "李欢",
            "registrationCode": "",
            "opFrom": "",
            "creditCode": "91330110MABYJ76842",
            "opPeriod": "",
            "enterpriseName": "杭州数勋科技有限公司",
            "isCopy": 1
        }
    }
}

(2)错误返回:

{
    "code": "1",
    "msg": "参数错误",
    "isFee": 0,
    "seqNo": null,
    "data": null
}


原文地址:https://blog.csdn.net/shuxuntechAPI/article/details/143629559

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!