If you connect the camera module with sprense and execute the following sample code with Arduino IDE,
The error statement "variable or field'CamCB'declared void" appears.
void CamCB(CamImage img)
seems to be an error, but I don't know how to change it.
If you are familiar with programming, please reply.
//#include [SDHCI.h]
// #include [stdio.h]
//#include [Camera.h]/*Required for Camera Library*/
// # define BAUDRATE (115200)
SDClass theSD;
int take_picture_count = 0; / * Variable for the filename to be written to the SDCard and the maximum number of files to be created */
/* Preview Callback*/
/* Callback from camera library when video frame is captured */
void CamCB (CamImage img)
{
if(img.isAvailable())
{
/* Convert to RGB 565*/
img.convertPixFormat(CAM_IMAGE_PIX_FMT_RGB565);
This is the function that is registered with /*startStreaming() and called when the camera preview is output.
Within this function, check if the CamImage instance obtained as the function argument is available.
The pixel format has since been converted to RGB 565. After the conversion, it shows the data size and memory address obtained with getImgSize() and getImgBuff().
Typically, you will output image data to the display you connected to at this stage to create a view of the camera's finder.*/
Serial.print("Image data size=");
Serial.print(img.getImgSize(), DEC);
Serial.print(", ");
Serial.print("buffaddr=");
Serial.print((unsigned long)img.getImgBuff(),HEX);
Serial.println("");
}
else
{
Serial.print("Failed to get video stream image\n";
}
}
/*setup()*/
void setup()
{
Serial.begin (BAUDRATE);
while(!Serial)
{
;
}
/* Begin() without parameters is
* Number of buffers = 130 FPS.QVGA, YUV 4:2:2 format
*/
Serial.println("Prepar camera");
the Camera.begin();
/* If you receive video data from a camera device, click
* Call CamCB in Camera Library
*/
Serial.println("Start streaming");
theCamera.startStreaming(true.CamCB);
/* Set auto white balance*/
Serial.println("Set Auto white balance parameter");
theCamera.setAutoWhiteBalanceMode(CAM_WHITE_BALANCE_DAYLIGHT);
/* Set parameters for still images
* QUADVGA and JPEG if:
*/
Serial.println("Start streaming");
TheCamera.setStillPictureImageFormat(
CAM_IMGSIZE_QUADVGA_H,
CAM_IMGSIZE_QUADVGA_V,
CAM_IMAGE_PIX_FMT_JPG);
}
void loop()
{
sleep(1);
/*You can change the format of the still image here if necessary.
*/
/*theCamera.setStillPictureImageFormat(
* CAM_IMGSIZE_HD_H,
* CAM_IMGSIZE_HD_V,
*CAM_IMAGE_PIX_FMT_JPG);
*/
/* This code allows you to take 100 photos every second from the start.
*/
if(take_picture_count<100)
{
/* To take still images
* Unlike video streams,
* This API waits for image data to be received.
*/
Serial.println("call takePicture()");
CamImage img=theCamera.takePicture();
/* Check the availability of img instances
* If an error occurs, it cannot be used.
*/
if(img.isAvailable())
{
/* Create a file
*/
char filename [16] = {0};
sprintf(filename, "PICT%03d.jpg", take_picture_count);
Serial.print("Save take picture as");
Serial.print(filename);
Serial.println("");
/* Save to SD Card by File Name
*/
File myFile=theSD.open(filename, FILE_WRITE);
myFile.write(img, getImgBuff(), img.getImgSize());
myFile.close();
}
take_picture_count++;
}
}
The error is due to the inclusion of Camera.h being commented out.
//#include [SDHCI.h]
// #include [stdio.h]
//#include [Camera.h]/*Required for Camera Library*/
If you remove the comment out of , the compilation will go through as follows:
#include<SDHCI.h>
# include <stdio.h>
# Required for include<Camera.h>/*Camera library*/
© 2024 OneMinuteCode. All rights reserved.