I am trying to POST HTTP request to Detect Text in images converted to base64 from mat image. When I run the code, I get
{
"responses":[
{
"error":{
"code":3,
"message":"Bad image data."
}
}
]
}
My curl POST field is a JSON string like this:
{
"requests":[
{
"image":{
"content":"lZ+elp+elp+elp+elZ+elZ6dlZ6dlZ6dlJ6dlJ2ck52ck52ck52ck52ck52bk5ybkpyakpyakpyakZuZkJqYj5m...........srW0srWzsrWzsrWzsrWz"
},
"features":[
{
"type":"TEXT_DETECTION"
}
]
}
]
}
I am not sure if the base64 encoded image is valid. Please help !
I have found a solution by converting the Mat object into vector and then encode.
std::vector<uchar> array;
cv::imencode(".png",mat_img, array);
std::string encoded = Base64::encode(array);