Arduino 如何使用OV7670 ESP32和SPIFFS保存位图?
我正在使用Arduino 如何使用OV7670 ESP32和SPIFFS保存位图?,arduino,esp32,spiffs,Arduino,Esp32,Spiffs,我正在使用OV7670和ESP32捆绑包进行wifi摄像头项目: 如何在文件中使用SPIFFS保存位图 守则的一部分: 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
OV7670
和ESP32
捆绑包进行wifi摄像头项目:
如何在文件中使用SPIFFS
保存位图
守则的一部分:
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!");
}
void Get_photo(AsyncWebServerRequest*请求){
照相机->单帧();
File File=SPIFFS.open(“/Images/test.bmp”,File_WRITE);//如何保存到此文件?
对于(int i=0;i yres*2;i++)
{
相机->帧[i];
}
Serial.println(“PHOTO_OK!”);
}
不确定您是否仍然需要答案,但它可能会帮助某些人。您正在读取值,但没有将其写入文件
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!");
}
void Get_photo(AsyncWebServerRequest*请求){
照相机->单帧();
File File=SPIFFS.open(“/Images/test.bmp”,File_WRITE);//在这里打开文件
如果(!文件){
Serial.println(“打开文件时出错”);//检查文件是否正确打开的良好做法
return;//如果文件未打开,请不要继续
}
对于(int i=0;i yres*2;i++)
{
file.write(摄影机->帧[i]);//将像素信息写入BMP文件
}
file.close();//关闭文件将保存其内容
Serial.println(“PHOTO_OK!”);
}
请记住,每次调用Get_photo
,它都会覆盖test.bmp
,因为两个文件不能具有相同的名称
希望这能帮助别人