fasdfsa commited on
Commit
ca9688b
·
1 Parent(s): f70c124

fix_char_rectangle not done yet.

Browse files
fix_char_rectangle.py CHANGED
@@ -1225,9 +1225,48 @@ def get_selectionsv2(dir, m5):
1225
 
1226
  # return jsonify(transcriptions)
1227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
  if __name__ == '__main__':
1229
 
 
 
 
 
 
 
 
1230
 
 
 
 
 
 
 
 
1231
  dir = '/yingedu/project/ocr_server_test/data/'
1232
  m5 = 'b0cd8663d03d596eab297a8250bf116c'
1233
 
 
1225
 
1226
  # return jsonify(transcriptions)
1227
 
1228
+
1229
+ def rec_wechatocr(img_base64_str):
1230
+ import requests
1231
+
1232
+ url = 'http://127.0.0.1:7788/wechatocr'
1233
+
1234
+ headers = {
1235
+ "Content-Type": "application/json"
1236
+ }
1237
+
1238
+ data = {
1239
+ "img": img_base64_str
1240
+ }
1241
+
1242
+ response = requests.post(url, headers=headers, json=data)
1243
+
1244
+ # 检查请求是否成功
1245
+ if response.status_code == 200:
1246
+ data = response.text
1247
+ else:
1248
+ print(f"请求失败: {response.status_code} - {response.text}")
1249
+ return None
1250
+
1251
+ return data
1252
+
1253
  if __name__ == '__main__':
1254
 
1255
+ import base64
1256
+
1257
+ with open('data/0003.jpg', "rb") as f:
1258
+ img = f.read()
1259
+
1260
+ base64_bytes = base64.b64encode(img)
1261
+ base64_str = base64_bytes.decode('ascii')
1262
 
1263
+ jsn = rec_wechatocr(base64_str)
1264
+
1265
+ if jsn is not None:
1266
+ jsn = jsonparse(jsn)
1267
+ else:
1268
+ raise Exception('something wrong.')
1269
+
1270
  dir = '/yingedu/project/ocr_server_test/data/'
1271
  m5 = 'b0cd8663d03d596eab297a8250bf116c'
1272
 
src/WeChatOcrCpp/WeChatOcrCpp.vcxproj CHANGED
@@ -46,7 +46,7 @@
46
  <CharacterSet>Unicode</CharacterSet>
47
  </PropertyGroup>
48
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49
- <ConfigurationType>DynamicLibrary</ConfigurationType>
50
  <UseDebugLibraries>false</UseDebugLibraries>
51
  <PlatformToolset>v143</PlatformToolset>
52
  <WholeProgramOptimization>true</WholeProgramOptimization>
 
46
  <CharacterSet>Unicode</CharacterSet>
47
  </PropertyGroup>
48
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49
+ <ConfigurationType>Application</ConfigurationType>
50
  <UseDebugLibraries>false</UseDebugLibraries>
51
  <PlatformToolset>v143</PlatformToolset>
52
  <WholeProgramOptimization>true</WholeProgramOptimization>