Hi,
I have recently started prototyping on Arduino Nano 33 BLE Sense Board to grab camera frames from the OV7670 camera module. I successfully managed to run the pre-built example available on Arduino Nano with QVGA image resolution (320x240) but when I try using the QQVGA one, the output image has some artifacts (test_qvga.png
)
Below, I report the code used to obtain QQVGA images from the camera module:
#include <Arduino_OV767X.h>
uint8_t pixels[160 * 120 * 2];
void setup() {
Serial.begin(115600);
while (!Serial);
Serial.println("OV767X Camera Capture");
Serial.println();
if (!Camera.begin(QQVGA, RGB565, 1)) {
Serial.println("Failed to initialize camera!");
while (1);
}
Serial.println("Camera settings:");
Serial.print("\twidth = ");
Serial.println(Camera.width());
Serial.print("\theight = ");
Serial.println(Camera.height());
Serial.print("\tbits per pixel = ");
Serial.println(Camera.bitsPerPixel());
Serial.println();
//Camera.testPattern();
Serial.println("Press the button to read a frame ...");
Serial.println();
}
void loop() {
Serial.println("Reading frame");
Serial.println();
Camera.readFrame(pixels);
int numPixels = Camera.width() * Camera.height();
for (int i = 0; i < numPixels * 2; i+=2) {
//uint16_t p = pixels[i];
uint16_t p = (pixels[i] << 8) | pixels[i+1];
uint8_t r = ((p >> 11) & 0x1f) << 3;
uint8_t g = ((p >> 5) & 0x3f) << 2;
uint8_t b = ((p >> 0) & 0x1f) << 3;
Serial.println(r);
Serial.println(g);
Serial.println(b);
}
delay(1000);
}
Do you have any ideas what it could be wrong?
Many thanks in advance,
Gian Marco