Hi all,
My project is like this, when the button is pressed, it takes a photo at that moment. And I am sending it over tcp. My point is this:
I take pictures with the pins of the camera attached, there is no problem normally, it works fine and sends. I take a photo after removing the pins of the camera, the system pretends to take a photo and sends and receives information from somewhere, but this is wrong. Then, when I take a photo with the pins out for the second time, it gives an error that the pins are not inserted. I can't get this error when I was supposed to get it the first time.
My opinion; After taking a photo, it informs the system that the pins are ready, next time you can take a photo.
fb = esp_camera_fb_get();
esp_camera_fb_return(fb);
I think it has to do with these functions.
I clean inside fb, inside buf and len, but from here the camera pulls the literal. How can I do this in a controlled way?
Every time I call the CameraVideo function, I take a picture and send it. Here I want to check the camera pins before taking every photo how can I do it?
Thanks all.
void cameraVideo()
{
size_t _jpg_buf_len = 0;
uint8_t * _jpg_buf = NULL;
int m = 0;
count = 0;
bool ok = 0;
camera_fb_t *fb = 0;
while (m < 1) {
do {
m++;
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
ESP.restart();
return;
}
// Photo file name
Serial.printf("Picture file name: %s\n", FILE_PHOTO);
File file = SPIFFS.open(FILE_PHOTO, FILE_WRITE);
// Insert the data in the photo file
if (!file) {
Serial.println("Failed to open file in writing mode");
}
else {
_jpg_buf_len = fb->len;
_jpg_buf = fb->buf;
file.write(_jpg_buf, _jpg_buf_len);
Serial.print("The picture has been saved in ");
Serial.print(FILE_PHOTO);
}
// Close the file
file.close();
ok = checkPhoto(SPIFFS);
if (fb) {
esp_camera_fb_return(fb);
fb = NULL;
_jpg_buf = NULL;
} else if (_jpg_buf) {
free(_jpg_buf);
_jpg_buf = NULL;
}
free(fb);
} while (!ok);
photostatusPackage(SPIFFS);
dirCheck2(SPIFFS);
}
}