I have an amb 82 mini , RLTK8735B , I want to capture image and then store image in internal storage but file system is giving me errors. Currently I dont have an SD Card. I am providing you with my current code , please help me out:
#include “VideoStream.h”
#include "AmebaFatFS.h"
#define CHANNEL 0
#define MAX_IMAGE_SIZE 50000 // Adjust this size according to your image size
// Use a pre-defined resolution, or choose to configure your own resolution
VideoSetting config(1024, 576, CAM_FPS, VIDEO_JPEG, 1);
uint32_t img_addr = 0;
uint32_t img_len = 0;
uint8_t imageBuffer[MAX_IMAGE_SIZE]; // Buffer to store the captured image data
uint32_t imageBufferSize = 0; // Variable to keep track of the image data size
AmebaFatFS fs;
void setup() {
Serial.begin(115200);
// Initialize the file system
bool fsInit = fs.begin();
Serial.print("File system initialization: ");
Serial.println(fsInit ? "successful" : "failed");
// Print the root path
Serial.print("Root path: ");
Serial.println(fs.getRootPath());
// Configure camera and video settings
Camera.configVideoChannel(CHANNEL, config);
Camera.videoInit();
Camera.channelBegin(CHANNEL);
}
void loop() {
if (Serial.available() > 0) {
char c = Serial.read();
if (c == '1') {
Serial.println("Capturing image...");
// Capture the image
Camera.getImage(CHANNEL, &img_addr, &img_len);
Serial.println("Image captured.");
// Check if image size exceeds buffer size
if (img_len > MAX_IMAGE_SIZE) {
Serial.println("Image size exceeds buffer size. Aborting.");
return;
}
// Store the image data in the buffer
memcpy(imageBuffer, (uint8_t*)img_addr, img_len);
imageBufferSize = img_len;
// Print the image size
Serial.print("Image size: ");
Serial.println(imageBufferSize);
// Save the image from buffer to file
File file = fs.open("/captured_image.jpg", FA_WRITE); // Specify file name and location
if (file) {
// Write image data to file
file.write(imageBuffer, imageBufferSize);
file.close();
Serial.println("Image saved to file system.");
} else {
Serial.println("Error opening file for writing.");
}
}
}
delay(1000); // Add delay to prevent continuous capturing
}
I am getting this error:
C:\Users\PMLS\Desktop\Amb82\storeandsend\storeandsend.ino: In function ‘void loop()’:
C:\Users\PMLS\Desktop\Amb82\storeandsend\storeandsend.ino:61:64: error: no matching function for call to ‘AmebaFatFS::open(const char [20], int)’
61 | File file = fs.open(“/captured_image.jpg”, FA_WRITE); // Specify file name and location
| ^
In file included from C:\Users\PMLS\Desktop\Amb82\storeandsend\storeandsend.ino:2:
C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\FileSystem\src/AmebaFatFS.h:21:14: note: candidate: ‘File AmebaFatFS::open(const String&)’
21 | File open(const String& path);
| ^~~~
C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\FileSystem\src/AmebaFatFS.h:21:14: note: candidate expects 1 argument, 2 provided
C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\FileSystem\src/AmebaFatFS.h:22:14: note: candidate: ‘File AmebaFatFS::open(const char*)’
22 | File open(const char* path);
| ^~~~
C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\FileSystem\src/AmebaFatFS.h:22:14: note: candidate expects 1 argument, 2 provided
Using library AmebaMultimedia at version 1.0.0 in folder: C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\Multimedia
Using library AmebaFileSystem at version 1.0.0 in folder: C:\Users\PMLS\AppData\Local\Arduino15\packages\realtek\hardware\AmebaPro2\4.0.6\libraries\FileSystem
exit status 1
Compilation error: no matching function for call to ‘AmebaFatFS::open(const char [20], int)’