I use google vision api to detect the ocr.

However, I got no ocr text.

On the other hand, I uploaded the image to https://cloud.google.com/vision/ and 
got DBR Weddings\n.

Is it normal?

How should I correct my code?

Thank you very much.

Here is my code:


import requestsfrom PIL import Imagefrom io import BytesIOimport cv2import 
base64import ast

url = r'https://drive.google.com/uc?id=1pjofUsy5V4v7DSVsRERw6S-Zo36hO1bZ'
feature_json_obj = [{'type': 'TEXT_DETECTION', 'maxResults': 100}]
img = Image.open(BytesIO(requests.get(url).content))
arr = cv2.cvtColor(np.asarray(img.convert('RGB'), dtype=np.uint8), 
cv2.COLOR_RGB2BGR)

content_json_obj = {'content': 
base64.b64encode(a_numpy.tostring()).decode('UTF-8')}
request_list = {'requests': [{'features': feature_json_obj, 'image': 
content_json_obj, 'imageContext': {'languageHints': "zh-TW"}}]}
req = 
requests.post(url='https://vision.googleapis.com/v1/images:annotate?key=my_key',
 data = str.encode(str(request_list)), headers={'Content-Type': 
'application/json'}).text
receive_data = req.encode(sys.stdin.encoding, 
"replace").decode(sys.stdin.encoding)
data = 
ast.literal_eval(receive_data)['responses'][0]['fullTextAnnotation']['text']#get
 google-vision result

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/70e6ab18-2e98-4be6-ae78-8c9617df85be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine... Frankie Chan

Reply via email to