我正在使用OV7670
和ESP32
捆绑包:https://github.com/bitluni/ESP32CameraI2S进行wifi摄像头项目。
如何在SPIFFS
中使用File
保存位图?
部分代码:
void Get_photo (AsyncWebServerRequest * request) {
camera-> oneFrame ();
File file = SPIFFS.open ("/ Images / test.bmp", FILE_WRITE); // How to save to this file?
for (int i = 0; i <BMP :: headerSize; i ++)
{
bmpHeader [i];
}
for (int i = 0; i <camera-> xres * camera-> yres * 2; i ++)
{
camera-> frame [i];
}
Serial.println ("PHOTO_OK!");
}
答案 0 :(得分:0)
不确定您仍然需要答案,但这可能会对某人有所帮助。您正在读取值,但未将其写入文件。
Iso_outliers = IsolationForest().fit(X_train)
Iso_outliers_train = Iso_outliers.predict(X_train)
请记住,由于两个文件不能使用相同的名称,因此每次调用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
。
希望能帮助某人。