文字识别OCR云接口调用的话,做多支持一次几张图片?[阿里云OCR]

文字识别OCR云接口调用的话,做多支持一次几张图片?

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====
4 条回复 A 作者 M 管理员
  1. 根据阿里云文字识别OCR的官方文档,OCR云接口支持一次调用多张图片进行识别。具体支持的图片数量取决于您所使用的OCR API的具体接口。

    例如,使用阿里云的通用文字识别(General Recognition)接口,可以在一次调用中传入多张图片进行识别。您可以通过批量上传图片的方式,将多张图片同时发送给OCR云接口进行文字识别。

    多张图片的处理可能会导致识别时间增加。您可以根据实际需求和性能要求,评估控制每次调用的图片数量,以获得最佳的识别性能和效果。

  2. 阿里云OCR API:
    通用OCR API:文档链接 ↗https://help.aliyun.com/document_detail/29009.html
    手写OCR API:文档链接 ↗https://help.aliyun.com/document_detail/102667.html?spm=a2c4g.750001.0.i1

    import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import com.aliyuncs.DefaultAcsClient;import com.aliyuncs.IAcsClient;import com.aliyuncs.exceptions.ClientException;import com.aliyuncs.exceptions.ServerException;import com.aliyuncs.green.model.v20180509.ImageSyncScanRequest;import com.aliyuncs.http.FormatType;import com.aliyuncs.http.HttpResponse;import com.aliyuncs.http.MethodType;import com.aliyuncs.http.ProtocolType;import com.aliyuncs.profile.DefaultProfile;import com.aliyuncs.profile.IClientProfile;import java.util.*;public class Main {    public static void main(String[] args) throws Exception {        /**         * 阿里云账号AccessKey拥有所有API的访问权限,建议您使用RAM用户进行API访问或日常运维。          * 常见获取环境变量方式:         * 方式一:         *     获取RAM用户AccessKey ID:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");         *     获取RAM用户AccessKey Secret:System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");         * 方式二:         *     获取RAM用户AccessKey ID:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_ID");         *     获取RAM用户AccessKey Secret:System.getProperty("ALIBABA_CLOUD_ACCESS_KEY_SECRET");         */        DefaultProfile profile = DefaultProfile.getProfile(                "cn-shanghai",                "建议从环境变量中获取RAM用户AccessKey ID",                "建议从环境变量中获取RAM用户AccessKey Secret");        DefaultProfile.addEndpoint("cn-shanghai", "Green", "green.cn-shanghai.aliyuncs.com");        IAcsClient client = new DefaultAcsClient(profile);        ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest();        // 指定返回格式。        imageSyncScanRequest.setAcceptFormat(FormatType.JSON);        // 指定请求方法。        imageSyncScanRequest.setMethod(MethodType.POST);        imageSyncScanRequest.setEncoding("utf-8");        // 支持HTTP和HTTPS。        imageSyncScanRequest.setProtocol(ProtocolType.HTTP);        JSONObject httpBody = new JSONObject();        /**         * 设置要检测的场景。         * ocr:表示OCR图文识别和OCR卡证识别。         */        httpBody.put("scenes", Arrays.asList("ocr"));        /**         * 设置待检测的图片,一张图片对应一个检测任务。         * 多张图片同时检测时,处理时间由最后一张处理完的图片决定。         * 通常情况下批量检测的平均响应时间比单任务检测长,一次批量提交的图片数越多,响应时间被拉长的概率越高。         * 代码中以单张图片检测作为示例,如果需要批量检测多张图片,请自行构建多个任务。         */        JSONObject task = new JSONObject();        task.put("dataId", UUID.randomUUID().toString());        // 设置图片链接。        task.put("url", "https://www.www.tongchenyun.com/wp-content/uploads/aliyun/2023/1128/xxx.jpg");        task.put("time", new Date());        httpBody.put("tasks", Arrays.asList(task));        // 需要OCR卡证识别时,设置卡证类型。        JSONObject cardExtras = new JSONObject();        // 身份证正面识别。        cardExtras.put("card", "id-card-front");        // 身份证反面。        //cardExtras.put("card", "id-card-back");        httpBody.put("extras", cardExtras);        imageSyncScanRequest.setHttpContent(org.apache.commons.codec.binary.StringUtils.getBytesUtf8(httpBody.toJSONString()), "UTF-8", FormatType.JSON);        /**         * 请设置超时时间,服务端全链路处理超时时间为10秒,请据此做相应设置。         * 如果您设置的ReadTimeout小于服务端处理的时间,程序中会获得一个read timeout异常。         */        imageSyncScanRequest.setConnectTimeout(3000);        imageSyncScanRequest.setReadTimeout(10000);        HttpResponse httpResponse = null;        try {            httpResponse = client.doAction(imageSyncScanRequest);        } catch (ServerException e) {            e.printStackTrace();        } catch (ClientException e) {            e.printStackTrace();        } catch (Exception e){            e.printStackTrace();        }        // 服务端接收到请求,并完成处理返回的结果。        if(httpResponse != null && httpResponse.isSuccess()){            JSONObject scrResponse = JSON.parseObject(org.apache.commons.codec.binary.StringUtils.newStringUtf8(httpResponse.getHttpContent()));            System.out.println(JSON.toJSONString(scrResponse));            int requestCode = scrResponse.getIntValue("code");            // 每一张图片的检测结果。            JSONArray taskResults = scrResponse.getJSONArray("data");            if (200 == requestCode) {                for (Object taskResult : taskResults) {                    // 单张图片的处理结果。                    int taskCode = ((JSONObject)taskResult).getIntValue("code");                    // 对应检测场景下图片的处理结果。如果是多个场景,则会有每个场景的结果。                    JSONArray sceneResults = ((JSONObject)taskResult).getJSONArray("results");                    if(200 == taskCode){                        for (Object sceneResult : sceneResults) {                            String scene = ((JSONObject)sceneResult).getString("scene");                            String suggestion = ((JSONObject)sceneResult).getString("suggestion");                            //do something                            // 识别出来的身份证信息。                            if("review" .equals(suggestion) && "ocr".equals(scene)){                                JSONObject idCardInfo =  ((JSONObject) sceneResult).getJSONObject("idCardInfo");                                System.out.println(idCardInfo.toJSONString());                            }                        }                    }else{                        // 单张图片处理失败,原因视具体的情况详细分析。                        System.out.println("task process fail. task response:" + JSON.toJSONString(taskResult));                     }                }            } else {                /**                 * 表明请求整体处理失败,原因视具体的情况详细分析。                 */                System.out.println("the whole image scan request failed. response:" + JSON.toJSONString(scrResponse));             }        }    }}

    图片数量限制:
    通用OCR接口:一次请求最多支持100张图片。

    手写OCR接口:一次请求最多支持10张图片。

    图片大小限制:
    单张图片大小一般不超过3M。

    对于多张图片,总大小一般不能超过10M。

    接口响应时间:
    识别多张图片需要更长的响应时间。
    以阿里云OCR服务为例,具体规格如下:

    通用OCR接口:
    一次请求最多100张图片,单张图片最大3M,总大小不超过10M。

    手写OCR接口:
    一次请求最多10张图片,单张图片最大3M,总大小不超过10M。

  3. 阿里云OCR引擎支持一次调用最多5张图片进行识别。
    如果您需要调用多张图片进行识别,可以使用OCR云接口提供的API接口进行操作。具体来说,您可以按照以下步骤进行操作:

    使用OCR云接口提供的API接口上传图片,并调用OCR引擎进行识别。
    识别完成后,可以通过API接口获取识别结果,并对结果进行处理。

  4. OCR云接口的一次调用通常支持一张图片的识别

  5. 私有化是按照qps作为识别速度的标准的,如果购买了5qps,就是每秒可以识别5站图片,此回答整理自钉群”阿里云读光OCR客户交流反馈群 2″