I managed to create base64 file in backend with function: for (x, y, w, h) on and y: frame=put_glass(glass, img, x, y, w, h) res,glass1 = cv2.imencode(".JPEG",frame) image = Image.fromarray(glass1) buff = BytesIO() picture.save(buff, format="JPEG") new_image_string = base64.b64encode(buff.getvalue()).decode("utf-8") return(new_image_string)
however the base64 string is returning the photo in blue, I think it has to do with cv2.imshow, because when I call this method I use glass1 to display the image and not the frame
Guess you are looking for something like this:
await api2.post('/glass1/', formData, headers)
.then((response) => {
const data = response.data
return data.blob()
})
.then((data) => {
const reader = new FileReader();
reader.onload = function() {
const b64 = reader.result
document.getElementById("img").src = b64;
}
reader.readAsDataURL(data)
})