Hi Class. I am new here. I’m using arduino ESP32cam and I managed to make a GET request and see that the OCR system really works.
However, my arduino C++ IDE code generates the base64 String of every photo I take with the ESP32cam.
There are no such examples in the tutorials. The examples deal with photos saved to URLs. It’s not my case. I have the photo already in base64 String inside my code.
I tried to send it using the code below. But it returns this error: “OCRExitCode”:99,“IsErroredOnProcessing”:true,“ErrorMessage”:[“Unable to recognize the file type”,“Unable to detect the file extension, or the file extension is incorrect, and no ‘file type’ provided in request. Please provide a file with a proper content type or extension, or provide a file type in the request to manually set the file extension.”],“ProcessingTimeInMilliseconds”:“0”}
Can anyone explain how to resolve this ? Thanks
HTTPClient http;
http.begin("http://api.ocr.space/parse/image");
http.addHeader("apikey:", "A85066677886547");
http.addHeader("Content-Type", "image/jpg");
String data = "data:image/jpeg;base64,";
String httpRequestData = data + urlencode(photo);
Serial.println(httpRequestData);
int httpResponseCode = http.POST(httpRequestData);
With or without urlencode(photo), the error is the same. The base64 String is photo.
And when I read Serial.println(httpRequestData); I notice that it is the same as the example of the tutorials on the site. So I can’t understand why it doesn’t work.
I’ll test it and come back here to confirm. But let’s assume it works there. My code is generating the same String. I don’t understand. But like I said, I’ll confirm and come back here to say.
Something seems wrong in the C++ code is what motivated me to make the first post here in this forum. Who knows, maybe someone has gone through this before. But it seems not. I’ll keep searching. Thanks.
Enjoying that I’m still here. Question: Is there any way to handle the response event. I mean, the response code. Eliminate fields leaving only the field we want in the String response ?
{"ParsedResults":[{"TextOverlay":{"Lines":[],"HasOverlay":false,"Message":"Text overlay is not provided as it is not requested"},"TextOrientation":"0","FileParseExitCode":1,"ParsedText":"PR • CORTIYU\r\nBC- 1234\r\n","ErrorMessage":"","ErrorDetails":""}],"OCRExitCode":1,"IsErroredOnProcessing":false,"ProcessingTimeInMilliseconds":"671","SearchablePDFURL":"Searchable PDF not generated as it was not requested."}