I am using Indrek's LiveOV7670 library to gather image data and write the bytes in a binary file stored in my Micro SD Card.
#include <BufferedCameraOV7670.h>
#include <BufferedCameraOV7670_80x120_10hz_Grayscale.h>
#include <BufferedCameraOV7670_QQVGA.h>
#include <BufferedCameraOV7670_QQVGA_10hz.h>
#include <BufferedCameraOV7670_QQVGA_10hz_Grayscale.h>
#include <BufferedCameraOV7670_QQVGA_20hz_Grayscale.h>
#include <BufferedCameraOV7670_QVGA.h>
#include <CameraOV7670.h>
#include <CameraOV7670RegisterDefinitions.h>
#include <CameraOV7670Registers.h>
#include <SD.h>
#include <SPI.h>
// Variables
BufferedCameraOV7670_QQVGA_10hz camera(CameraOV7670::PIXEL_RGB565); // Preconfigured camera for 160x120 Colored resolution with a lineBuffer.
File myFile;
// Function declarations
inline void writeLine() __attribute__((always_inline));
inline void writePixelbyte(uint8_t byte) __attribute__((always_inline));
inline void processFrame() __attribute__((always_inline));
// Function definitions
void writePixelbyte(uint8_t byte) {
myFile.write(byte);
}
void writeLine() {
for (int i = 0; i < 320; i++) { // RGB565 format means 2 byte per pixel that's why 160 x 2 = 320 iterations.
writePixelbyte(camera.getPixelByte(i));
}
}
void processFrame() {
myFile = SD.open((String(millis()) + ".bmp").c_str(), FILE_WRITE);
noInterrupts();
camera.waitForVsync();
camera.ignoreVerticalPadding();
for (uint16_t i = 0; i < camera.getLineCount(); i++) {
camera.readLine();
writeLine();
}
interrupts();
myFile.close();
}
void setup() {
SPI.setClockDivider(SPI_CLOCK_DIV2);
SD.begin(30);
bool cameraInitialized = camera.init();
}
void loop() {
processFrame();
}
This code is the one in use. I am using an Arduino Mega and I have acquired some amount of image decoding in my project.
Normal image that I get (supposed to be a sensor module against a black wall or cabinet).
When I covered the camera lens with my finger.
I am using python to decode the image. The problem is why is the image is not coming out like expected. Why are there stripes of colors and not just a proper image. I don't know if the problem is with my code or hardware
Help will be much appreciated because TBH I am not very good at programming.

