I’m able to successfully process the image with postman, but when I try to send the same image in my android app I keep getting this error:
{“OCRExitCode”:99,“IsErroredOnProcessing”:true,“ErrorMessage”:[“Unable to recognize the file type”],“ProcessingTimeInMilliseconds”:“0”}
I’ve been at it all day and can’t figure out why I’m getting this result.
Here’s my kotlin code if anyone can give insight:
image.compress(Bitmap.CompressFormat.JPEG, 100, baos)
val bytes = baos.toByteArray()
val encoder = Base64.getEncoder()
val body = "data:image/jpeg;base64," + encoder.encodeToString(bytes)
val queue = Volley.newRequestQueue(this)
val url = "https://api.ocr.space/parse/image"
val jsonObjectRequest = object: JsonObjectRequest(Request.Method.POST, url, null,
Listener<JSONObject> {
}, Response.ErrorListener {
}
) {
override fun getHeaders(): Map<String, String> {
var params = HashMap<String, String>()
params["Content-Type"] = "multipart/form-data"
params["apikey"] = "xxx"
return params
}
override fun getParams(): MutableMap<String, String> {
var params = HashMap<String, String>()
params.put("language", "eng")
params.put("scale", "true")
params.put("istable", "true")
params.put("ocrengine", "2")
params.put("detectorientation", "true")
params.put("base64Image", body)
return params
}
}
queue.add(jsonObjectRequest)