-
Notifications
You must be signed in to change notification settings - Fork 247
/
ocr_client.py
2575 lines (2131 loc) · 115 KB
/
ocr_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf8 -*-
# Copyright (c) 2017-2021 THL A29 Limited, a Tencent company. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.common.abstract_client import AbstractClient
from tencentcloud.ocr.v20181119 import models
class OcrClient(AbstractClient):
_apiVersion = '2018-11-19'
_endpoint = 'ocr.tencentcloudapi.com'
_service = 'ocr'
def AdvertiseOCR(self, request):
"""本接口支持广告商品图片内文字的检测和识别,返回文本框位置与文字内容。
产品优势:针对广告商品图片普遍存在较多繁体字、艺术字的特点,进行了识别能力的增强。支持中英文、横排、竖排以及倾斜场景文字识别。文字识别的召回率和准确率能达到96%以上。
默认接口请求频率限制:20次/秒。
:param request: Request instance for AdvertiseOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.AdvertiseOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.AdvertiseOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("AdvertiseOCR", params, headers=headers)
response = json.loads(body)
model = models.AdvertiseOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ArithmeticOCR(self, request):
"""本接口支持作业算式题目的自动识别和判分,目前覆盖 K12 学力范围内的 11 种题型,包括加减乘除四则、加减乘除已知结果求运算因子、判断大小、约等于估算、带余数除法、分数四则运算、单位换算、竖式加减法、竖式乘除法、脱式计算和解方程,平均识别精度达到93%以上。
默认接口请求频率限制:10次/秒。
:param request: Request instance for ArithmeticOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.ArithmeticOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.ArithmeticOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ArithmeticOCR", params, headers=headers)
response = json.loads(body)
model = models.ArithmeticOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BankCardOCR(self, request):
"""本接口支持对中国大陆主流银行卡正反面关键字段的检测与识别,包括卡号、卡类型、卡名字、银行信息、有效期。支持竖排异形卡识别、多角度旋转图片识别。支持对复印件、翻拍件、边框遮挡的银行卡进行告警,可应用于各种银行卡信息有效性校验场景,如金融行业身份认证、第三方支付绑卡等场景。
默认接口请求频率限制:10次/秒。
:param request: Request instance for BankCardOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.BankCardOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.BankCardOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BankCardOCR", params, headers=headers)
response = json.loads(body)
model = models.BankCardOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BankSlipOCR(self, request):
"""本接口支持银行回单全字段的识别,包括付款开户行、收款开户行、付款账号、收款账号、回单类型、回单编号、币种、流水号、凭证号码、交易机构、交易金额、手续费、日期等字段信息。
默认接口请求频率限制:10次/秒。
:param request: Request instance for BankSlipOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.BankSlipOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.BankSlipOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BankSlipOCR", params, headers=headers)
response = json.loads(body)
model = models.BankSlipOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BizLicenseOCR(self, request):
"""本接口支持快速精准识别营业执照上的字段,包括统一社会信用代码、公司名称、主体类型、法定代表人、注册资本、组成形式、成立日期、营业期限和经营范围等字段。
默认接口请求频率限制:10次/秒。
:param request: Request instance for BizLicenseOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.BizLicenseOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.BizLicenseOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BizLicenseOCR", params, headers=headers)
response = json.loads(body)
model = models.BizLicenseOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BusInvoiceOCR(self, request):
"""本接口支持识别公路汽车客票关键字段的识别,包括发票代码、发票号码、日期、票价、始发地、目的地、姓名、时间、发票消费类型、身份证号、省、市、开票日期、乘车地点、检票口、客票类型、车型、座位号、车次等。
默认接口请求频率限制:5次/秒。
:param request: Request instance for BusInvoiceOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.BusInvoiceOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.BusInvoiceOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BusInvoiceOCR", params, headers=headers)
response = json.loads(body)
model = models.BusInvoiceOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def BusinessCardOCR(self, request):
"""本接口支持中英文名片各字段的自动定位与识别,包含姓名、电话、手机号、邮箱、公司、部门、职位、网址、地址、QQ、微信、MSN等。
默认接口请求频率限制:10次/秒。
:param request: Request instance for BusinessCardOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.BusinessCardOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.BusinessCardOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("BusinessCardOCR", params, headers=headers)
response = json.loads(body)
model = models.BusinessCardOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CarInvoiceOCR(self, request):
"""本接口支持机动车销售统一发票和二手车销售统一发票的识别,包括发票号码、发票代码、合计金额、合计税额等二十多个字段。
默认接口请求频率限制:5次/秒。
:param request: Request instance for CarInvoiceOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.CarInvoiceOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.CarInvoiceOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CarInvoiceOCR", params, headers=headers)
response = json.loads(body)
model = models.CarInvoiceOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ClassifyDetectOCR(self, request):
"""支持身份证、护照、名片、银行卡、行驶证、驾驶证、港澳台通行证、户口本、港澳台来往内地通行证、港澳台居住证、不动产证、营业执照的智能分类。
默认接口请求频率限制:20次/秒。
:param request: Request instance for ClassifyDetectOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.ClassifyDetectOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.ClassifyDetectOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ClassifyDetectOCR", params, headers=headers)
response = json.loads(body)
model = models.ClassifyDetectOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateAIFormTask(self, request):
"""本接口可创建智能表单录入任务,支持多个识别图片和PDF的URL上传,返回含有识别内容的操作页面URL。
智能表单录入产品提供高准确率的表单识别技术和人工核对工具,支持自定义字段,将识别结果自动填入到自定义条目中,并提供人工操作工具,完成整个表单识别过程。适用性强,可对票据、合同、货单等文件的识别,适用于金融、货代、保险、档案等领域。本产品免费公测中,您可以点击demo(超链接:https://ocr.smartform.cloud.tencent.com/)试用,如需购买请与商务团队联系。
:param request: Request instance for CreateAIFormTask.
:type request: :class:`tencentcloud.ocr.v20181119.models.CreateAIFormTaskRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.CreateAIFormTaskResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateAIFormTask", params, headers=headers)
response = json.loads(body)
model = models.CreateAIFormTaskResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DriverLicenseOCR(self, request):
"""本接口支持驾驶证主页和副页所有字段的自动定位与识别,重点字段的识别准确度达到99%以上。
驾驶证主页:包括证号、姓名、性别、国籍、住址、出生日期、初次领证日期、准驾车型、有效期限、发证单位
驾驶证副页:包括证号、姓名、档案编号、记录。
另外,本接口还支持复印件、翻拍告警功能。同时支持识别交管12123 APP发放的电子驾驶证正页。
电子驾驶证正页:包括证号、姓名、性别、国籍、出生日期、初次领证日期、准驾车型、有效期开始时间、有效期截止时间、档案编号、状态、累积记分。
默认接口请求频率限制:10次/秒。
:param request: Request instance for DriverLicenseOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.DriverLicenseOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.DriverLicenseOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DriverLicenseOCR", params, headers=headers)
response = json.loads(body)
model = models.DriverLicenseOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DutyPaidProofOCR(self, request):
"""本接口支持对完税证明的税号、纳税人识别号、纳税人名称、金额合计大写、金额合计小写、填发日期、税务机关、填票人等关键字段的识别。
默认接口请求频率限制:5次/秒。
:param request: Request instance for DutyPaidProofOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.DutyPaidProofOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.DutyPaidProofOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DutyPaidProofOCR", params, headers=headers)
response = json.loads(body)
model = models.DutyPaidProofOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EduPaperOCR(self, request):
"""本接口支持数学试题内容的识别和结构化输出,包括通用文本解析和小学/初中/高中数学公式解析能力(包括91种题型,180种符号),公式返回格式为 Latex 格式文本。
默认接口请求频率限制:5次/秒。
:param request: Request instance for EduPaperOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.EduPaperOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.EduPaperOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EduPaperOCR", params, headers=headers)
response = json.loads(body)
model = models.EduPaperOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnglishOCR(self, request):
"""本接口支持图像英文文字的检测和识别,返回文字框位置与文字内容。支持多场景、任意版面下的英文、字母、数字和常见字符的识别,同时覆盖英文印刷体和英文手写体识别。
默认接口请求频率限制:10次/秒。
:param request: Request instance for EnglishOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.EnglishOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.EnglishOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnglishOCR", params, headers=headers)
response = json.loads(body)
model = models.EnglishOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EnterpriseLicenseOCR(self, request):
"""本接口支持智能化识别各类企业登记证书、许可证书、企业执照、三证合一类证书,结构化输出统一社会信用代码、公司名称、法定代表人、公司地址、注册资金、企业类型、经营范围、成立日期、有效期、开办资金、经费来源、举办单位等关键字段。
默认接口请求频率限制:5次/秒。
:param request: Request instance for EnterpriseLicenseOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.EnterpriseLicenseOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.EnterpriseLicenseOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EnterpriseLicenseOCR", params, headers=headers)
response = json.loads(body)
model = models.EnterpriseLicenseOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def EstateCertOCR(self, request):
"""本接口支持不动产权证关键字段的识别,包括使用期限、面积、用途、权利性质、权利类型、坐落、共有情况、权利人、权利其他状况等。
默认接口请求频率限制:5次/秒。
:param request: Request instance for EstateCertOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.EstateCertOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.EstateCertOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("EstateCertOCR", params, headers=headers)
response = json.loads(body)
model = models.EstateCertOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def FinanBillOCR(self, request):
"""本接口支持常见银行票据的自动分类和识别。整单识别包括支票(含现金支票、普通支票、转账支票),承兑汇票(含银行承兑汇票、商业承兑汇票)以及进账单等,适用于中国人民银行印发的 2010 版银行票据凭证版式(银发[2010]299 号)。
默认接口请求频率限制:5次/秒。
:param request: Request instance for FinanBillOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.FinanBillOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.FinanBillOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("FinanBillOCR", params, headers=headers)
response = json.loads(body)
model = models.FinanBillOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def FinanBillSliceOCR(self, request):
"""本接口支持常见银行票据的自动分类和识别。切片识别包括金融行业常见票据的重要切片字段识别,包括金额、账号、日期、凭证号码等。(金融票据切片:金融票据中待识别字段及其周围局部区域的裁剪图像。)
默认接口请求频率限制:5次/秒。
:param request: Request instance for FinanBillSliceOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.FinanBillSliceOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.FinanBillSliceOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("FinanBillSliceOCR", params, headers=headers)
response = json.loads(body)
model = models.FinanBillSliceOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def FlightInvoiceOCR(self, request):
"""本接口支持机票行程单关键字段的识别,包括旅客姓名、有效身份证件号码、电子客票号码、验证码、填开单位、其他税费、燃油附加费、民航发展基金、保险费、销售单位代号、始发地、目的地、航班号、时间、日期、座位等级、承运人、发票消费类型、票价、合计金额、填开日期、国内国际标签、印刷序号、客票级别/类别、客票生效日期、有效期截止日期、免费行李等字段,支持航班信息多行明细输出。
默认接口请求频率限制:5次/秒。
:param request: Request instance for FlightInvoiceOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.FlightInvoiceOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.FlightInvoiceOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("FlightInvoiceOCR", params, headers=headers)
response = json.loads(body)
model = models.FlightInvoiceOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def FormulaOCR(self, request):
"""本接口支持识别主流初高中数学符号和公式,返回公式的 Latex 格式文本。
默认接口请求频率限制:5次/秒。
:param request: Request instance for FormulaOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.FormulaOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.FormulaOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("FormulaOCR", params, headers=headers)
response = json.loads(body)
model = models.FormulaOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GeneralAccurateOCR(self, request):
"""本接口支持图像整体文字的检测和识别。支持中文、英文、中英文、数字和特殊字符号的识别,并返回文字框位置和文字内容。
适用于文字较多、版式复杂、对识别准召率要求较高的场景,如试卷试题、网络图片、街景店招牌、法律卷宗等场景。
产品优势:与通用印刷体识别接口相比,本接口提供更高精度的通用文字识别服务,在手写体、文字较多、长串数字、小字、模糊字、倾斜文本等困难场景下,高精度版的准确率和召回率更高。
通用文字识别不同版本的差异如下:
<table style="width:715px">
<thead>
<tr>
<th style="width:150px"></th>
<th >【荐】通用印刷体识别(高精度版)</th>
<th style="width:200px"><a href="https://cloud.tencent.com/document/product/866/33526">【荐】通用印刷体识别</a></th>
<th><a href="https://cloud.tencent.com/document/product/866/37831">通用印刷体识别(精简版)</a></th>
</tr>
</thead>
<tbody>
<tr>
<td> 适用场景</td>
<td>适用于文字较多、长串数字、小字、模糊字、倾斜文本等困难场景</td>
<td>适用于所有通用场景的印刷体识别</td>
<td>适用于快速文本识别场景,准召率有一定损失,价格更优惠</td>
</tr>
<tr>
<td>识别准确率</td>
<td>99%</td>
<td>96%</td>
<td>91%</td>
</tr>
<tr>
<td>价格</td>
<td>高</td>
<td>中</td>
<td>低</td>
</tr>
<tr>
<td>支持的语言</td>
<td>中文、英文、中英文</td>
<td>中文、英文、中英文、日语、韩语、西班牙语、法语、德语、葡萄牙语、越南语、马来语、俄语、意大利语、荷兰语、瑞典语、芬兰语、丹麦语、挪威语、匈牙利语、泰语</td>
<td>中文、英文、中英文</td>
</tr>
<tr>
<td>自动语言检测</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>返回文本行坐标</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>自动旋转纠正</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
</tr>
</tbody>
</table>
默认接口请求频率限制:10次/秒。
:param request: Request instance for GeneralAccurateOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.GeneralAccurateOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GeneralAccurateOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GeneralAccurateOCR", params, headers=headers)
response = json.loads(body)
model = models.GeneralAccurateOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GeneralBasicOCR(self, request):
"""本接口支持图像整体文字的检测和识别。可以识别中文、英文、中英文、日语、韩语、西班牙语、法语、德语、葡萄牙语、越南语、马来语、俄语、意大利语、荷兰语、瑞典语、芬兰语、丹麦语、挪威语、匈牙利语、泰语,阿拉伯语20种语言,且各种语言均支持与英文混合的文字识别。
适用于印刷文档识别、网络图片识别、广告图文字识别、街景店招牌识别、菜单识别、视频标题识别、头像文字识别等场景。
产品优势:支持自动识别语言类型,可返回文本框坐标信息,对于倾斜文本支持自动旋转纠正。
通用印刷体识别不同版本的差异如下:
<table style="width:715px">
<thead>
<tr>
<th style="width:150px"></th>
<th style="width:200px">【荐】通用印刷体识别</th>
<th ><a href="https://cloud.tencent.com/document/product/866/34937">【荐】通用印刷体识别(高精度版)</a></th>
<th><a href="https://cloud.tencent.com/document/product/866/37831">通用印刷体识别(精简版)</a></th>
</tr>
</thead>
<tbody>
<tr>
<td> 适用场景</td>
<td>适用于所有通用场景的印刷体识别</td>
<td>适用于文字较多、长串数字、小字、模糊字、倾斜文本等困难场景</td>
<td>适用于快速文本识别场景,准召率有一定损失,价格更优惠</td>
</tr>
<tr>
<td>识别准确率</td>
<td>96%</td>
<td>99%</td>
<td>91%</td>
</tr>
<tr>
<td>价格</td>
<td>中</td>
<td>高</td>
<td>低</td>
</tr>
<tr>
<td>支持的语言</td>
<td>中文、英文、中英文、日语、韩语、西班牙语、法语、德语、葡萄牙语、越南语、马来语、俄语、意大利语、荷兰语、瑞典语、芬兰语、丹麦语、挪威语、匈牙利语、泰语</td>
<td>中文、英文、中英文</td>
<td>中文、英文、中英文</td>
</tr>
<tr>
<td>自动语言检测</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>返回文本行坐标</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>自动旋转纠正</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
</tr>
</tbody>
</table>
默认接口请求频率限制:20次/秒。
:param request: Request instance for GeneralBasicOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.GeneralBasicOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GeneralBasicOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GeneralBasicOCR", params, headers=headers)
response = json.loads(body)
model = models.GeneralBasicOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GeneralEfficientOCR(self, request):
"""本接口支持图像整体文字的检测和识别。支持中文、英文、中英文、数字和特殊字符号的识别,并返回文字框位置和文字内容。
适用于快速文本识别场景。
产品优势:与通用印刷体识别接口相比,精简版虽然在准确率和召回率上有一定损失,但价格更加优惠。
通用印刷体识别不同版本的差异如下:
<table style="width:715px">
<thead>
<tr>
<th style="width:150px"></th>
<th >通用印刷体识别(精简版)</th>
<th style="width:200px"><a href="https://cloud.tencent.com/document/product/866/33526">【荐】通用印刷体识别</a></th>
<th><a href="https://cloud.tencent.com/document/product/866/34937">【荐】通用印刷体识别(高精度版)</a></th>
</tr>
</thead>
<tbody>
<tr>
<td> 适用场景</td>
<td>适用于快速文本识别场景,准召率有一定损失,价格更优惠</td>
<td>适用于所有通用场景的印刷体识别</td>
<td>适用于文字较多、长串数字、小字、模糊字、倾斜文本等困难场景</td>
</tr>
<tr>
<td>识别准确率</td>
<td>91%</td>
<td>96%</td>
<td>99%</td>
</tr>
<tr>
<td>价格</td>
<td>低</td>
<td>中</td>
<td>高</td>
</tr>
<tr>
<td>支持的语言</td>
<td>中文、英文、中英文</td>
<td>中文、英文、中英文、日语、韩语、西班牙语、法语、德语、葡萄牙语、越南语、马来语、俄语、意大利语、荷兰语、瑞典语、芬兰语、丹麦语、挪威语、匈牙利语、泰语</td>
<td>中文、英文、中英文</td>
</tr>
<tr>
<td>自动语言检测</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>返回文本行坐标</td>
<td>支持</td>
<td>支持</td>
<td>支持</td>
</tr>
<tr>
<td>自动旋转纠正</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
<td>支持旋转识别,返回角度信息</td>
</tr>
</tbody>
</table>
默认接口请求频率限制:10次/秒。
:param request: Request instance for GeneralEfficientOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.GeneralEfficientOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GeneralEfficientOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GeneralEfficientOCR", params, headers=headers)
response = json.loads(body)
model = models.GeneralEfficientOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GeneralFastOCR(self, request):
"""本接口支持图片中整体文字的检测和识别,返回文字框位置与文字内容。相比通用印刷体识别接口,识别速度更快。
默认接口请求频率限制:10次/秒。
:param request: Request instance for GeneralFastOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.GeneralFastOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GeneralFastOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GeneralFastOCR", params, headers=headers)
response = json.loads(body)
model = models.GeneralFastOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GeneralHandwritingOCR(self, request):
"""本接口支持图片内手写体文字的检测和识别,针对手写字体无规则、字迹潦草、模糊等特点进行了识别能力的增强。
默认接口请求频率限制:10次/秒。
:param request: Request instance for GeneralHandwritingOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.GeneralHandwritingOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GeneralHandwritingOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GeneralHandwritingOCR", params, headers=headers)
response = json.loads(body)
model = models.GeneralHandwritingOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def GetTaskState(self, request):
"""支持查询智能表单录入任务的状态。本产品免费公测中,您可以点击demo(超链接:https://ocr.smartform.cloud.tencent.com/)试用,如需购买请与商务团队联系。
:param request: Request instance for GetTaskState.
:type request: :class:`tencentcloud.ocr.v20181119.models.GetTaskStateRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.GetTaskStateResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("GetTaskState", params, headers=headers)
response = json.loads(body)
model = models.GetTaskStateResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def HKIDCardOCR(self, request):
"""本接口支持中国香港身份证人像面中关键字段的识别,包括中文姓名、英文姓名、姓名电码、出生日期、性别、证件符号、首次签发日期、最近领用日期、身份证号、是否是永久性居民身份证;具备人像照片裁剪等扩展功能。
默认接口请求频率限制:5次/秒。
:param request: Request instance for HKIDCardOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.HKIDCardOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.HKIDCardOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("HKIDCardOCR", params, headers=headers)
response = json.loads(body)
model = models.HKIDCardOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def HmtResidentPermitOCR(self, request):
"""港澳台居住证OCR支持港澳台居住证正反面全字段内容检测识别功能,包括姓名、性别、出生日期、地址、身份证号、签发机关、有效期限、签发次数、通行证号码关键字段识别。可以应用于港澳台居住证信息识别场景,例如银行开户、用户注册等。
默认接口请求频率限制:20次/秒。
:param request: Request instance for HmtResidentPermitOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.HmtResidentPermitOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.HmtResidentPermitOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("HmtResidentPermitOCR", params, headers=headers)
response = json.loads(body)
model = models.HmtResidentPermitOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def IDCardOCR(self, request):
"""本接口支持中国大陆居民二代身份证正反面所有字段的识别,包括姓名、性别、民族、出生日期、住址、公民身份证号、签发机关、有效期限,识别准确度达到99%以上。
另外,本接口还支持多种增值能力,满足不同场景的需求。如身份证照片、人像照片的裁剪功能,同时具备9种告警功能,如下表所示。
<table style="width:650px">
<thead>
<tr>
<th width="150">增值能力</th>
<th width="500">能力项</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">裁剪功能</td>
<td>身份证照片裁剪(去掉证件外多余的边缘、自动矫正拍摄角度)</td>
</tr>
<tr>
<td>人像照片裁剪(自动抠取身份证头像区域)</td>
</tr>
<tr>
<td rowspan="9">告警功能</td>
<td>身份证有效日期不合法,即有效日期不符合5年、10年、20年、长期期限
</td>
</tr>
<tr>
<td>身份证边框不完整告警</td>
</tr>
<tr>
<td>身份证复印件告警</td>
</tr>
<tr>
<td>身份证翻拍告警</td>
</tr>
<tr>
<td>身份证框内遮挡告警</td>
</tr>
<tr>
<td>临时身份证告警</td>
</tr>
<tr>
<td>身份证疑似存在PS痕迹告警</td>
</tr>
<tr>
<td>图片模糊告警(可根据图片质量分数判断)</td>
</tr>
</tbody>
</table>
默认接口请求频率限制:20次/秒。
:param request: Request instance for IDCardOCR.
:type request: :class:`tencentcloud.ocr.v20181119.models.IDCardOCRRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.IDCardOCRResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("IDCardOCR", params, headers=headers)
response = json.loads(body)
model = models.IDCardOCRResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ImageEnhancement(self, request):
"""文本图像增强是面向文档类图片提供的图像增强处理能力,包括切边增强、图像矫正、阴影去除、摩尔纹去除等;可以有效优化文档类的图片质量,提升文字的清晰度。
默认接口请求频率限制:10次/秒。
:param request: Request instance for ImageEnhancement.
:type request: :class:`tencentcloud.ocr.v20181119.models.ImageEnhancementRequest`
:rtype: :class:`tencentcloud.ocr.v20181119.models.ImageEnhancementResponse`
"""
try: