Tencent_文字识别_英文识别

# 
import json
import cv2
import requests
import uuid
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ocr.v20181119 import ocr_client, models
from tencentcloud.ocr.v20181119 import models as ocr_models
import numpy as np
import base64
import matplotlib.pyplot as plt
%matplotlib inline
import warnings
warnings.filterwarnings("ignore")
SecretId="xxxxxx"
SecretKey="xxxxxxx"
"""

通用印刷体识别(高精度版)
https://console.cloud.tencent.com/api
/explorer?Product=ocr&Version=2018-11-19&Action=GeneralAccurateOCR&SignVersion=
"""


try: 
    cred = credential.Credential(SecretId, SecretKey) 
    httpProfile = HttpProfile()
    httpProfile.endpoint = "ocr.tencentcloudapi.com"

    clientProfile = ClientProfile()
    clientProfile.httpProfile = httpProfile
    client = ocr_client.OcrClient(cred, "ap-beijing", clientProfile) 
    img_path="./images/en1.jpg"
    with open(img_path,"rb") as file:
        img=base64.b64encode(file.read()) 
    req = ocr_models.EnglishOCRRequest()

    params = {
        "ImageBase64": str(img,encoding="utf-8"),
#         "ImageUrl": "",
        "EnableCoordPoint": False,
        "EnableCandWord": False,
        "Preprocess": True
    }
    req.from_json_string(json.dumps(params))

    resp = client.EnglishOCR(req).to_json_string() 
     
    resp=json.loads(resp)
    print(resp)  

except TencentCloudSDKException as err: 
    print(err) 


{'TextDetections': [{'DetectedText': '"It is in writing that, unless they give themselves in, the Taliban will arrest and', 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 19}, {'X': 748, 'Y': 19}, {'X': 748, 'Y': 37}, {'X': 35, 'Y': 37}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': '"'}, {'Confidence': 99, 'Character': 'It'}, {'Confidence': 99, 'Character': 'is'}, {'Confidence': 99, 'Character': 'in'}, {'Confidence': 99, 'Character': 'writing'}, {'Confidence': 99, 'Character': 'that'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': 'unless'}, {'Confidence': 100, 'Character': 'they'}, {'Confidence': 100, 'Character': 'give'}, {'Confidence': 99, 'Character': 'themselves'}, {'Confidence': 100, 'Character': 'in'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': 'the'}, {'Confidence': 99, 'Character': 'Taliban'}, {'Confidence': 99, 'Character': 'will'}, {'Confidence': 99, 'Character': 'arrest'}, {'Confidence': 100, 'Character': 'and'}]}, {'DetectedText': 'prosecute, interrogate and punish family members on behalf of those', 'Confidence': 99, 'Polygon': [{'X': 36, 'Y': 46}, {'X': 671, 'Y': 46}, {'X': 671, 'Y': 63}, {'X': 36, 'Y': 63}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'prosecute'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': 'interrogate'}, {'Confidence': 99, 'Character': 'and'}, {'Confidence': 99, 'Character': 'punish'}, {'Confidence': 99, 'Character': 'family'}, {'Confidence': 99, 'Character': 'members'}, {'Confidence': 99, 'Character': 'on'}, {'Confidence': 99, 'Character': 'behalf'}, {'Confidence': 100, 'Character': 'of'}, {'Confidence': 99, 'Character': 'those'}]}, {'DetectedText': '"', 'Confidence': 95, 'Polygon': [{'X': 138, 'Y': 72}, {'X': 148, 'Y': 72}, {'X': 148, 'Y': 81}, {'X': 138, 'Y': 81}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 95, 'Character': '"'}]}, {'DetectedText': "individuals.'", 'Confidence': 89, 'Polygon': [{'X': 35, 'Y': 72}, {'X': 140, 'Y': 75}, {'X': 139, 'Y': 92}, {'X': 35, 'Y': 90}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'individuals'}, {'Confidence': 99, 'Character': '.'}, {'Confidence': 68, 'Character': "'"}]}, {'DetectedText': "He warned that anyone on the Taliban's blacklist was in severe danger, and", 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 122}, {'X': 722, 'Y': 122}, {'X': 722, 'Y': 138}, {'X': 35, 'Y': 138}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'He'}, {'Confidence': 99, 'Character': 'warned'}, {'Confidence': 100, 'Character': 'that'}, {'Confidence': 99, 'Character': 'anyone'}, {'Confidence': 99, 'Character': 'on'}, {'Confidence': 100, 'Character': 'the'}, {'Confidence': 99, 'Character': "Taliban's"}, {'Confidence': 99, 'Character': 'blacklist'}, {'Confidence': 99, 'Character': 'was'}, {'Confidence': 100, 'Character': 'in'}, {'Confidence': 99, 'Character': 'severe'}, {'Confidence': 99, 'Character': 'danger'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 100, 'Character': 'and'}]}, {'DetectedText': 'that there could be mass executions.', 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 147}, {'X': 374, 'Y': 150}, {'X': 374, 'Y': 165}, {'X': 34, 'Y': 162}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'that'}, {'Confidence': 99, 'Character': 'there'}, {'Confidence': 99, 'Character': 'could'}, {'Confidence': 100, 'Character': 'be'}, {'Confidence': 99, 'Character': 'mass'}, {'Confidence': 100, 'Character': 'executions'}, {'Confidence': 99, 'Character': '.'}]}, {'DetectedText': 'Foreign powers are continuing efforts to get their nationals out of', 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 196}, {'X': 642, 'Y': 196}, {'X': 642, 'Y': 211}, {'X': 35, 'Y': 211}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'Foreign'}, {'Confidence': 99, 'Character': 'powers'}, {'Confidence': 100, 'Character': 'are'}, {'Confidence': 99, 'Character': 'continuing'}, {'Confidence': 99, 'Character': 'efforts'}, {'Confidence': 99, 'Character': 'to'}, {'Confidence': 100, 'Character': 'get'}, {'Confidence': 99, 'Character': 'their'}, {'Confidence': 99, 'Character': 'nationals'}, {'Confidence': 99, 'Character': 'out'}, {'Confidence': 100, 'Character': 'of'}]}, {'DetectedText': 'Afghanistan. A Nato official said on Friday that more than 18,000 people have', 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 222}, {'X': 753, 'Y': 222}, {'X': 753, 'Y': 240}, {'X': 35, 'Y': 240}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'Afghanistan'}, {'Confidence': 99, 'Character': '.'}, {'Confidence': 99, 'Character': 'A'}, {'Confidence': 99, 'Character': 'Nato'}, {'Confidence': 99, 'Character': 'official'}, {'Confidence': 100, 'Character': 'said'}, {'Confidence': 99, 'Character': 'on'}, {'Confidence': 99, 'Character': 'Friday'}, {'Confidence': 99, 'Character': 'that'}, {'Confidence': 100, 'Character': 'more'}, {'Confidence': 100, 'Character': 'than'}, {'Confidence': 99, 'Character': '18'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': '000'}, {'Confidence': 99, 'Character': 'people'}, {'Confidence': 100, 'Character': 'have'}]}, {'DetectedText': 'been evacuated in the last five days from Kabul airport.', 'Confidence': 99, 'Polygon': [{'X': 36, 'Y': 249}, {'X': 544, 'Y': 249}, {'X': 544, 'Y': 266}, {'X': 36, 'Y': 266}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'been'}, {'Confidence': 99, 'Character': 'evacuated'}, {'Confidence': 99, 'Character': 'in'}, {'Confidence': 99, 'Character': 'the'}, {'Confidence': 99, 'Character': 'last'}, {'Confidence': 100, 'Character': 'five'}, {'Confidence': 99, 'Character': 'days'}, {'Confidence': 99, 'Character': 'from'}, {'Confidence': 99, 'Character': 'Kabul'}, {'Confidence': 100, 'Character': 'airport'}, {'Confidence': 99, 'Character': '.'}]}, {'DetectedText': 'Some 6,000 more, among them former interpreters for foreign armed forces,', 'Confidence': 99, 'Polygon': [{'X': 34, 'Y': 296}, {'X': 741, 'Y': 297}, {'X': 741, 'Y': 313}, {'X': 33, 'Y': 312}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'Some'}, {'Confidence': 100, 'Character': '6'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': '000'}, {'Confidence': 99, 'Character': 'more'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': 'among'}, {'Confidence': 99, 'Character': 'them'}, {'Confidence': 99, 'Character': 'former'}, {'Confidence': 99, 'Character': 'interpreters'}, {'Confidence': 100, 'Character': 'for'}, {'Confidence': 100, 'Character': 'foreign'}, {'Confidence': 99, 'Character': 'armed'}, {'Confidence': 99, 'Character': 'forces'}, {'Confidence': 99, 'Character': ','}]}, {'DetectedText': 'are on standby to be flown out late on Thursday or early Friday.', 'Confidence': 99, 'Polygon': [{'X': 35, 'Y': 323}, {'X': 619, 'Y': 323}, {'X': 619, 'Y': 340}, {'X': 35, 'Y': 340}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'are'}, {'Confidence': 99, 'Character': 'on'}, {'Confidence': 99, 'Character': 'standby'}, {'Confidence': 99, 'Character': 'to'}, {'Confidence': 99, 'Character': 'be'}, {'Confidence': 99, 'Character': 'flown'}, {'Confidence': 99, 'Character': 'out'}, {'Confidence': 99, 'Character': 'late'}, {'Confidence': 99, 'Character': 'on'}, {'Confidence': 99, 'Character': 'Thursday'}, {'Confidence': 99, 'Character': 'or'}, {'Confidence': 100, 'Character': 'early'}, {'Confidence': 99, 'Character': 'Friday'}, {'Confidence': 99, 'Character': '.'}]}, {'DetectedText': 'The aim is to double evacuation efforts over the weekend, the official said.', 'Confidence': 99, 'Polygon': [{'X': 36, 'Y': 370}, {'X': 714, 'Y': 370}, {'X': 714, 'Y': 387}, {'X': 36, 'Y': 387}], 'AdvancedInfo': '{}', 'WordCoordPoint': [], 'CandWord': [], 'Words': [{'Confidence': 99, 'Character': 'The'}, {'Confidence': 99, 'Character': 'aim'}, {'Confidence': 100, 'Character': 'is'}, {'Confidence': 100, 'Character': 'to'}, {'Confidence': 99, 'Character': 'double'}, {'Confidence': 99, 'Character': 'evacuation'}, {'Confidence': 99, 'Character': 'efforts'}, {'Confidence': 99, 'Character': 'over'}, {'Confidence': 100, 'Character': 'the'}, {'Confidence': 99, 'Character': 'weekend'}, {'Confidence': 99, 'Character': ','}, {'Confidence': 99, 'Character': 'the'}, {'Confidence': 99, 'Character': 'official'}, {'Confidence': 100, 'Character': 'said'}, {'Confidence': 99, 'Character': '.'}]}], 'Angel': 358.5354309082031, 'RequestId': '1ca6fca0-ed28-4cb4-8b4a-72330527d3ee'}
resp["TextDetections"]
[{'DetectedText': '"It is in writing that, unless they give themselves in, the Taliban will arrest and',
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 19},
   {'X': 748, 'Y': 19},
   {'X': 748, 'Y': 37},
   {'X': 35, 'Y': 37}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': '"'},
   {'Confidence': 99, 'Character': 'It'},
   {'Confidence': 99, 'Character': 'is'},
   {'Confidence': 99, 'Character': 'in'},
   {'Confidence': 99, 'Character': 'writing'},
   {'Confidence': 99, 'Character': 'that'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': 'unless'},
   {'Confidence': 100, 'Character': 'they'},
   {'Confidence': 100, 'Character': 'give'},
   {'Confidence': 99, 'Character': 'themselves'},
   {'Confidence': 100, 'Character': 'in'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': 'the'},
   {'Confidence': 99, 'Character': 'Taliban'},
   {'Confidence': 99, 'Character': 'will'},
   {'Confidence': 99, 'Character': 'arrest'},
   {'Confidence': 100, 'Character': 'and'}]},
 {'DetectedText': 'prosecute, interrogate and punish family members on behalf of those',
  'Confidence': 99,
  'Polygon': [{'X': 36, 'Y': 46},
   {'X': 671, 'Y': 46},
   {'X': 671, 'Y': 63},
   {'X': 36, 'Y': 63}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'prosecute'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': 'interrogate'},
   {'Confidence': 99, 'Character': 'and'},
   {'Confidence': 99, 'Character': 'punish'},
   {'Confidence': 99, 'Character': 'family'},
   {'Confidence': 99, 'Character': 'members'},
   {'Confidence': 99, 'Character': 'on'},
   {'Confidence': 99, 'Character': 'behalf'},
   {'Confidence': 100, 'Character': 'of'},
   {'Confidence': 99, 'Character': 'those'}]},
 {'DetectedText': '"',
  'Confidence': 95,
  'Polygon': [{'X': 138, 'Y': 72},
   {'X': 148, 'Y': 72},
   {'X': 148, 'Y': 81},
   {'X': 138, 'Y': 81}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 95, 'Character': '"'}]},
 {'DetectedText': "individuals.'",
  'Confidence': 89,
  'Polygon': [{'X': 35, 'Y': 72},
   {'X': 140, 'Y': 75},
   {'X': 139, 'Y': 92},
   {'X': 35, 'Y': 90}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'individuals'},
   {'Confidence': 99, 'Character': '.'},
   {'Confidence': 68, 'Character': "'"}]},
 {'DetectedText': "He warned that anyone on the Taliban's blacklist was in severe danger, and",
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 122},
   {'X': 722, 'Y': 122},
   {'X': 722, 'Y': 138},
   {'X': 35, 'Y': 138}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'He'},
   {'Confidence': 99, 'Character': 'warned'},
   {'Confidence': 100, 'Character': 'that'},
   {'Confidence': 99, 'Character': 'anyone'},
   {'Confidence': 99, 'Character': 'on'},
   {'Confidence': 100, 'Character': 'the'},
   {'Confidence': 99, 'Character': "Taliban's"},
   {'Confidence': 99, 'Character': 'blacklist'},
   {'Confidence': 99, 'Character': 'was'},
   {'Confidence': 100, 'Character': 'in'},
   {'Confidence': 99, 'Character': 'severe'},
   {'Confidence': 99, 'Character': 'danger'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 100, 'Character': 'and'}]},
 {'DetectedText': 'that there could be mass executions.',
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 147},
   {'X': 374, 'Y': 150},
   {'X': 374, 'Y': 165},
   {'X': 34, 'Y': 162}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'that'},
   {'Confidence': 99, 'Character': 'there'},
   {'Confidence': 99, 'Character': 'could'},
   {'Confidence': 100, 'Character': 'be'},
   {'Confidence': 99, 'Character': 'mass'},
   {'Confidence': 100, 'Character': 'executions'},
   {'Confidence': 99, 'Character': '.'}]},
 {'DetectedText': 'Foreign powers are continuing efforts to get their nationals out of',
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 196},
   {'X': 642, 'Y': 196},
   {'X': 642, 'Y': 211},
   {'X': 35, 'Y': 211}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'Foreign'},
   {'Confidence': 99, 'Character': 'powers'},
   {'Confidence': 100, 'Character': 'are'},
   {'Confidence': 99, 'Character': 'continuing'},
   {'Confidence': 99, 'Character': 'efforts'},
   {'Confidence': 99, 'Character': 'to'},
   {'Confidence': 100, 'Character': 'get'},
   {'Confidence': 99, 'Character': 'their'},
   {'Confidence': 99, 'Character': 'nationals'},
   {'Confidence': 99, 'Character': 'out'},
   {'Confidence': 100, 'Character': 'of'}]},
 {'DetectedText': 'Afghanistan. A Nato official said on Friday that more than 18,000 people have',
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 222},
   {'X': 753, 'Y': 222},
   {'X': 753, 'Y': 240},
   {'X': 35, 'Y': 240}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'Afghanistan'},
   {'Confidence': 99, 'Character': '.'},
   {'Confidence': 99, 'Character': 'A'},
   {'Confidence': 99, 'Character': 'Nato'},
   {'Confidence': 99, 'Character': 'official'},
   {'Confidence': 100, 'Character': 'said'},
   {'Confidence': 99, 'Character': 'on'},
   {'Confidence': 99, 'Character': 'Friday'},
   {'Confidence': 99, 'Character': 'that'},
   {'Confidence': 100, 'Character': 'more'},
   {'Confidence': 100, 'Character': 'than'},
   {'Confidence': 99, 'Character': '18'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': '000'},
   {'Confidence': 99, 'Character': 'people'},
   {'Confidence': 100, 'Character': 'have'}]},
 {'DetectedText': 'been evacuated in the last five days from Kabul airport.',
  'Confidence': 99,
  'Polygon': [{'X': 36, 'Y': 249},
   {'X': 544, 'Y': 249},
   {'X': 544, 'Y': 266},
   {'X': 36, 'Y': 266}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'been'},
   {'Confidence': 99, 'Character': 'evacuated'},
   {'Confidence': 99, 'Character': 'in'},
   {'Confidence': 99, 'Character': 'the'},
   {'Confidence': 99, 'Character': 'last'},
   {'Confidence': 100, 'Character': 'five'},
   {'Confidence': 99, 'Character': 'days'},
   {'Confidence': 99, 'Character': 'from'},
   {'Confidence': 99, 'Character': 'Kabul'},
   {'Confidence': 100, 'Character': 'airport'},
   {'Confidence': 99, 'Character': '.'}]},
 {'DetectedText': 'Some 6,000 more, among them former interpreters for foreign armed forces,',
  'Confidence': 99,
  'Polygon': [{'X': 34, 'Y': 296},
   {'X': 741, 'Y': 297},
   {'X': 741, 'Y': 313},
   {'X': 33, 'Y': 312}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'Some'},
   {'Confidence': 100, 'Character': '6'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': '000'},
   {'Confidence': 99, 'Character': 'more'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': 'among'},
   {'Confidence': 99, 'Character': 'them'},
   {'Confidence': 99, 'Character': 'former'},
   {'Confidence': 99, 'Character': 'interpreters'},
   {'Confidence': 100, 'Character': 'for'},
   {'Confidence': 100, 'Character': 'foreign'},
   {'Confidence': 99, 'Character': 'armed'},
   {'Confidence': 99, 'Character': 'forces'},
   {'Confidence': 99, 'Character': ','}]},
 {'DetectedText': 'are on standby to be flown out late on Thursday or early Friday.',
  'Confidence': 99,
  'Polygon': [{'X': 35, 'Y': 323},
   {'X': 619, 'Y': 323},
   {'X': 619, 'Y': 340},
   {'X': 35, 'Y': 340}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'are'},
   {'Confidence': 99, 'Character': 'on'},
   {'Confidence': 99, 'Character': 'standby'},
   {'Confidence': 99, 'Character': 'to'},
   {'Confidence': 99, 'Character': 'be'},
   {'Confidence': 99, 'Character': 'flown'},
   {'Confidence': 99, 'Character': 'out'},
   {'Confidence': 99, 'Character': 'late'},
   {'Confidence': 99, 'Character': 'on'},
   {'Confidence': 99, 'Character': 'Thursday'},
   {'Confidence': 99, 'Character': 'or'},
   {'Confidence': 100, 'Character': 'early'},
   {'Confidence': 99, 'Character': 'Friday'},
   {'Confidence': 99, 'Character': '.'}]},
 {'DetectedText': 'The aim is to double evacuation efforts over the weekend, the official said.',
  'Confidence': 99,
  'Polygon': [{'X': 36, 'Y': 370},
   {'X': 714, 'Y': 370},
   {'X': 714, 'Y': 387},
   {'X': 36, 'Y': 387}],
  'AdvancedInfo': '{}',
  'WordCoordPoint': [],
  'CandWord': [],
  'Words': [{'Confidence': 99, 'Character': 'The'},
   {'Confidence': 99, 'Character': 'aim'},
   {'Confidence': 100, 'Character': 'is'},
   {'Confidence': 100, 'Character': 'to'},
   {'Confidence': 99, 'Character': 'double'},
   {'Confidence': 99, 'Character': 'evacuation'},
   {'Confidence': 99, 'Character': 'efforts'},
   {'Confidence': 99, 'Character': 'over'},
   {'Confidence': 100, 'Character': 'the'},
   {'Confidence': 99, 'Character': 'weekend'},
   {'Confidence': 99, 'Character': ','},
   {'Confidence': 99, 'Character': 'the'},
   {'Confidence': 99, 'Character': 'official'},
   {'Confidence': 100, 'Character': 'said'},
   {'Confidence': 99, 'Character': '.'}]}]
DetectedTextList=[]
PolygonList=[]
for content in resp["TextDetections"]:
    DetectedTextList.append(content["DetectedText"])
    PolygonList.append(content['Polygon'])
    
''.join(DetectedTextList)
'"It is in writing that, unless they give themselves in, the Taliban will arrest andprosecute, interrogate and punish family members on behalf of those"individuals.\'He warned that anyone on the Taliban\'s blacklist was in severe danger, andthat there could be mass executions.Foreign powers are continuing efforts to get their nationals out ofAfghanistan. A Nato official said on Friday that more than 18,000 people havebeen evacuated in the last five days from Kabul airport.Some 6,000 more, among them former interpreters for foreign armed forces,are on standby to be flown out late on Thursday or early Friday.The aim is to double evacuation efforts over the weekend, the official said.'
plt.figure(figsize=(12,12))
img=plt.imread(img_path)
plt.imshow(img)
<matplotlib.image.AxesImage at 0x14b30a7dd90>

在这里插入图片描述

plt.figure(figsize=(12,12))
res=plt.imread(img_path)
for pts in PolygonList:
#     print(pts)
    points=np.array([[pt["X"],pt["Y"]] for pt in pts],np.int32)
    points.reshape((-1,1,2))
    res=cv2.polylines(img=res, pts=[points], isClosed=True, color=(0,0,255), thickness=3)
plt.imshow(res)
<matplotlib.image.AxesImage at 0x14b30b01c70>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值