How to convert OV7670' output into MIME (base64 coding)

pszemek
Posts: 1
Joined: Fri Oct 05, 2018 3:03 pm

How to convert OV7670' output into MIME (base64 coding)

Postby pszemek » Fri Oct 05, 2018 3:13 pm

Hi,

Im trying to send email with photo captured from OV7670 as attachement.

Already I have achieved sending emails with attachement (also images in base64 coding) but I don't know how to convert OV7670 output to something what I could transform to base64.

I'm using Bitluni's driver to OV7670 from https://github.com/bitluni/ESP32CameraI2S, how can I achieve this?

My code:

Code: Select all

// ....
client.println("From: <" + String(FROM) + '>');
client.println("To: <" + to + '>');  
client.print("Subject: ");
client.println(_subject);
client.println("Content-Type: image/png; name=\"picture.png\"\r\nContent-Disposition: attachment; filename=\"picture.png\"\r\nContent-Transfer-Encoding: base64\r\n\r\n");

for(int i = 0; i < BMP::headerSize; i++)
    client.write(bmpHeader[i]);
for(int i = 0; i < camera->xres * camera->yres * 2; i++)
    client.write(camera->frame[i]);
// ...

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to convert OV7670' output into MIME (base64 coding)

Postby chegewara » Fri Oct 19, 2018 8:06 pm

Hi,
sorry for late reply but i just started similar project to yours. This is how i am changing data from camera to base64 string:

Code: Select all

	size_t size = image.size;
	const uint8_t* image = image.data;

	uint8_t *buffer = calloc((size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, sizeof(char));   // <--- equation from internet
	size_t buff_size = 0;
	int err = mbedtls_base64_encode(buffer, (size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, &buff_size, image, size);
	if (err != 0) {
		ESP_LOGE(TAG, "error base64 encoding, error %d, buff size: %d", err, buff_size);  
		return;	
	}

Who is online

Users browsing this forum: PepeTheGreat and 41 guests