Как сохранить растровое изображение с помощью OV7670 ESP32 и SPIFFS?


person Michael S    schedule 28.10.2018    source источник


Ответы (1)


Не уверен, что вам все еще нужен ответ, но он может кому-то помочь. Вы читаете значения, но не записываете их в файл.

void Get_photo (AsyncWebServerRequest * request) {

  camera-> oneFrame ();
  File file = SPIFFS.open ("/ Images / test.bmp", FILE_WRITE); // Here the file is opened

  if (!file) {
    Serial.println("Error opening the file."); // Good practice to check if the file was correctly opened
    return; // If file not opened, do not proceed
  }

  for (int i = 0; i <BMP :: headerSize; i ++)
  {
    file.write(bmpHeader [i]); // Writes header information to the BMP file
  }

  for (int i = 0; i <camera-> xres * camera-> yres * 2; i ++)
  {
    file.write(camera-> frame [i]); // Writes pixel information to the BMP file
  }

  file.close(); // Closing the file saves its content

  Serial.println ("PHOTO_OK!");

}

Имейте в виду, что каждый раз, когда вы вызываете Get_photo, он перезаписывает test.bmp, потому что два файла не могут иметь одинаковое имя.

Надеюсь, это кому-то поможет.

person Victor Oliveira    schedule 08.07.2019