Hi,
I'm doing a project of taking photos and saving to SD card or uploading to web server. I used Adafruit TTL Serial Camera (VC0706) and successfully saved photos to SD card using the VC0706 library they provided. The saving approach is to create a jpg file in SD card and transfer binary data through arduino serial to the file. The problem is: sometimes the photos saved are of bad quality, such as the photos I attached here, there are several pixels transferred incorrectly. When I go on trying to use CC3000 Wi-Fi board to upload photos to web server, although I used TCP, the photos saved are of even worse quality than SD card.
Does anyone know how to improve the photo saving quality?
The code clip is the photo saving.
File imgFile = SD.open(filename, FILE_WRITE);
// Get the size of the image (frame) taken
uint16_t jpglen = cam.frameLength();
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.print(" byte image.");
int32_t time = millis();
pinMode(8, OUTPUT);
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
imgFile.write(buffer, bytesToRead);
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
Serial.print('.');
wCount = 0;
}
//Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes");
jpglen -= bytesToRead;
}
imgFile.close();

