OV7670 + SD Card

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.

zip files are not accepted here.

What is the problem, what is Your question?

More help to post is found here: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Sorry for the zip file but I don't know how else I can show others, what I'm trying to do here. My problem is why does the image is not coming out like intended. Why are there stripes of colors and not just a proper image. I can't identify if the problem is with my Arduino code, hardware or Python project.

How would anyone (apart from you) know the image the camera was taking was not of a green diagonal tube on the edge of a shelf\support ?

The picture is supposed to be a sensor module for Arduino against a black cabinet or wall.

Try another target for the foto! It looks like a very close picture of something.

Unzip the file and post it in code tags.
.
Posting schematics might help us but as You get data from the camera it doesn't look that an elementary mistake there.