20240630
This commit is contained in:
1 parent
a10178426b
commit
5f6011fb86
3 files changed
+900
-11
No files matched your search
+92
@@ -243,6 +243,37 @@
|
||||
"print (time.strftime(\"%a %b %d %H:%M:%S %Y\", time.localtime()))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-06-29T15:48:22.519722Z",
|
||||
"iopub.status.busy": "2024-06-29T15:48:22.518971Z",
|
||||
"iopub.status.idle": "2024-06-29T15:48:22.528988Z",
|
||||
"shell.execute_reply": "2024-06-29T15:48:22.527881Z",
|
||||
"shell.execute_reply.started": "2024-06-29T15:48:22.519655Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'此亦宝力菱成上所不可缺者兹举其基本变化十'"
|
||||
]
|
||||
},
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from opencc import OpenCC\n",
|
||||
"\n",
|
||||
"cc = OpenCC('t2s')\n",
|
||||
"cc.convert(\"此亦寶力菱成上所不可缺者兹舉其基本變化十\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
@@ -1355,6 +1386,67 @@
|
||||
"#print (ll)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 腾讯文字识别"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2024-06-30T02:34:13.028764Z",
|
||||
"iopub.status.busy": "2024-06-30T02:34:13.027355Z",
|
||||
"iopub.status.idle": "2024-06-30T02:34:14.315546Z",
|
||||
"shell.execute_reply": "2024-06-30T02:34:14.313944Z",
|
||||
"shell.execute_reply.started": "2024-06-30T02:34:13.028687Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{\"TextDetections\": [{\"DetectedText\": \"勢上控制敵方此可謂新怖局之一般策略其實準此意義初亦不限定於三連星之形式只須探取與舊法地域主義相反\", \"Confidence\": 99, \"Polygon\": [{\"X\": 66, \"Y\": 45}, {\"X\": 82, \"Y\": 1191}, {\"X\": 45, \"Y\": 1191}, {\"X\": 29, \"Y\": 46}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":13}}\", \"ItemPolygon\": {\"X\": 29, \"Y\": 45, \"Width\": 54, \"Height\": 1147}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"據現行新依局法之形式觀之大概先以築成三連星之陣形次依第四線及第五線配置與全局保持聯絡於是從大\", \"Confidence\": 96, \"Polygon\": [{\"X\": 104, \"Y\": 93}, {\"X\": 117, \"Y\": 1191}, {\"X\": 79, \"Y\": 1191}, {\"X\": 65, \"Y\": 93}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":19}}\", \"ItemPolygon\": {\"X\": 65, \"Y\": 93, \"Width\": 53, \"Height\": 1099}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"三四起手更屬實利主義不與敵爭自安於小地到底難望有十分之發展故依實際的參究兩者畢竟俱不適當\", \"Confidence\": 98, \"Polygon\": [{\"X\": 138, \"Y\": 47}, {\"X\": 153, \"Y\": 1095}, {\"X\": 115, \"Y\": 1096}, {\"X\": 100, \"Y\": 47}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":5}}\", \"ItemPolygon\": {\"X\": 100, \"Y\": 47, \"Width\": 54, \"Height\": 1050}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"侵分之際父易暴露其弱點至於三三起手實屬非常消極之手法毋寧謂屬與新怖局之主旨相背馳換言之即些手比諸\", \"Confidence\": 95, \"Polygon\": [{\"X\": 175, \"Y\": 45}, {\"X\": 189, \"Y\": 1188}, {\"X\": 149, \"Y\": 1188}, {\"X\": 135, \"Y\": 46}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":11}}\", \"ItemPolygon\": {\"X\": 135, \"Y\": 45, \"Width\": 55, \"Height\": 1144}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"跡不寫人稱道乎其中亦有緣故蓋五五雖亦鴛勢力主義與新怖局法之用意相符願究以離角太遠不便作成根據且在\", \"Confidence\": 95, \"Polygon\": [{\"X\": 209, \"Y\": 45}, {\"X\": 226, \"Y\": 1188}, {\"X\": 187, \"Y\": 1189}, {\"X\": 170, \"Y\": 46}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":12}}\", \"ItemPolygon\": {\"X\": 170, \"Y\": 45, \"Width\": 57, \"Height\": 1145}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"星一式堪擺寫新佑局法之代表其實三連星式猶如六子局所置之形式一然則三三與五五何以提倡不久即消聲匿\", \"Confidence\": 92, \"Polygon\": [{\"X\": 245, \"Y\": 44}, {\"X\": 261, \"Y\": 1187}, {\"X\": 223, \"Y\": 1187}, {\"X\": 207, \"Y\": 44}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":10}}\", \"ItemPolygon\": {\"X\": 207, \"Y\": 44, \"Width\": 55, \"Height\": 1144}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"當新布局法初創之時三及五五之起手法會亦盛行一時然不滿一年已皆匿跡今已鮮見探用現所存者唯三連\", \"Confidence\": 98, \"Polygon\": [{\"X\": 282, \"Y\": 90}, {\"X\": 297, \"Y\": 1187}, {\"X\": 259, \"Y\": 1187}, {\"X\": 244, \"Y\": 91}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":18}}\", \"ItemPolygon\": {\"X\": 244, \"Y\": 90, \"Width\": 54, \"Height\": 1098}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"即以勞力寫第一義地域寫第二義蓋此即新舊兩法根本之差異點也\", \"Confidence\": 94, \"Polygon\": [{\"X\": 315, \"Y\": 42}, {\"X\": 328, \"Y\": 711}, {\"X\": 290, \"Y\": 712}, {\"X\": 277, \"Y\": 43}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":4}}\", \"ItemPolygon\": {\"X\": 277, \"Y\": 42, \"Width\": 52, \"Height\": 671}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"足取主張起手即擇第四線及第五線配子初時不求固定之地域專圖以勢力制敵篇用戰之策略其觀點適與奮法相反\", \"Confidence\": 97, \"Polygon\": [{\"X\": 353, \"Y\": 41}, {\"X\": 370, \"Y\": 1184}, {\"X\": 330, \"Y\": 1184}, {\"X\": 313, \"Y\": 42}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":9}}\", \"ItemPolygon\": {\"X\": 313, \"Y\": 41, \"Width\": 58, \"Height\": 1144}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"舊局法既都先佔一及兩邊故類以得地屬第勢力第義自新局論出說斥舊法偏於一隅不\", \"Confidence\": 89, \"Polygon\": [{\"X\": 392, \"Y\": 89}, {\"X\": 406, \"Y\": 1184}, {\"X\": 365, \"Y\": 1184}, {\"X\": 351, \"Y\": 89}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":17}}\", \"ItemPolygon\": {\"X\": 351, \"Y\": 89, \"Width\": 56, \"Height\": 1096}, \"Words\": [], \"WordCoordPoint\": []}, {\"DetectedText\": \"富於變化留白以活動之餘地也\", \"Confidence\": 99, \"Polygon\": [{\"X\": 423, \"Y\": 41}, {\"X\": 427, \"Y\": 358}, {\"X\": 389, \"Y\": 359}, {\"X\": 384, \"Y\": 42}], \"AdvancedInfo\": \"{\\\"Parag\\\":{\\\"ParagNo\\\":2}}\", \"ItemPolygon\": {\"Line truncated
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import types\n",
|
||||
"from tencentcloud.common import credential\n",
|
||||
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
||||
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
||||
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
||||
"from tencentcloud.ocr.v20181119 import ocr_client, models\n",
|
||||
"import base64\n",
|
||||
" \n",
|
||||
"cred = credential.Credential(\"AKIDoZHHEB2lHbluEZvN8uYHwcdvacqfmDeJ\",\"fEkr2VucwEQXXVN8jCd0CFBxdAe6Xny9\")\n",
|
||||
"httpProfile = HttpProfile()\n",
|
||||
"httpProfile.endpoint = \"ocr.tencentcloudapi.com\" \n",
|
||||
"clientProfile = ClientProfile()\n",
|
||||
"clientProfile.httpProfile = httpProfile \n",
|
||||
"client = ocr_client.OcrClient(cred, \"ap-beijing\", clientProfile) \n",
|
||||
"req = models.GeneralAccurateOCRRequest()\n",
|
||||
"with open(\"001.jpg\",\"rb\") as f:\n",
|
||||
" img_data = f.read()\n",
|
||||
"img_base64 = base64.b64encode(img_data)\n",
|
||||
"params = {\n",
|
||||
" \"ImageBase64\": img_base64.decode('utf-8')\n",
|
||||
"}\n",
|
||||
"req.from_json_string(json.dumps(params))\n",
|
||||
"\n",
|
||||
"# 返回的resp是一个GeneralAccurateOCRResponse的实例,与请求对象对应\n",
|
||||
"resp = client.GeneralAccurateOCR(req)\n",
|
||||
"print(resp.to_json_string())\n",
|
||||
"\n",
|
||||
"#except TencentCloudSDKException as err:\n",
|
||||
"# print(err)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in new issue
Block a user