Looks like there may be some recent incompatibility with the GigaR1 and gc2145 ?
used the tutorial from here:
https://docs.arduino.cc/tutorials/giga-r1-wifi/giga-camera/
I think I've modified what needs to be matched to the Processing code, but I'm still getting no image. I've not used Processing before, so it very well may be user error, but the tutorial is pretty sparse, and could perhaps use some fleshing out. The current code in the tutorial, is also not the same as what is in the current CameraCaptureRawBytes example, and does not work, returning an error related to one of the ov767x camera's which I think can be fixed by commenting them out if you aren't using that camera. I changed the baudrate in Processing to match the Arduino example at 115200
I tried the sketch with camera set to RGB565 and made what looked like the appropriate changes to the Processing sketch, but that errored out, so I changed it to useGrayscale, which does not error, but also does not produce an image.
Processing debug sticks here with debugger busy on:
myPort = new Serial(this, "/dev/cu.usbmodem144201", baudRate); // Mac
*** update ***
In Processing debug, I am now getting a Connection timed out.
I've read a few possible solutions, such as adding a 50ms delay, so far that has not worked.
Arduino code:
#include "camera.h"
#ifdef ARDUINO_NICLA_VISION
#include "gc2145.h"
GC2145 galaxyCore;
Camera cam(galaxyCore);
#define IMAGE_MODE CAMERA_GRAYSCALE
#elif defined(ARDUINO_PORTENTA_H7_M7)
// uncomment the correct camera in use
#include "hm0360.h"
HM0360 himax;
// #include "himax.h"
// HM01B0 himax;
// Camera cam(himax);
Camera cam(himax);
#define IMAGE_MODE CAMERA_GRAYSCALE
#elif defined(ARDUINO_GIGA)
#include "ov767x.h"
// uncomment the correct camera in use
OV7670 ov767x;
// OV7675 ov767x;
Camera cam(ov767x);
#define IMAGE_MODE CAMERA_RGB565
#else
#error "This board is unsupported."
#endif
/*
Other buffer instantiation options:
FrameBuffer fb(0x30000000);
FrameBuffer fb(320,240,2);
If resolution higher than 320x240 is required, please use external RAM via
#include "SDRAM.h"
FrameBuffer fb(SDRAM_START_ADDRESS);
...
// and adding in setup()
SDRAM.begin();
*/
FrameBuffer fb;
unsigned long lastUpdate = 0;
void blinkLED(uint32_t count = 0xFFFFFFFF)
{
pinMode(LED_BUILTIN, OUTPUT);
while (count--) {
digitalWrite(LED_BUILTIN, LOW); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(LED_BUILTIN, HIGH); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}
}
void setup() {
// Init the cam QVGA, 30FPS
if (!cam.begin(CAMERA_R320x240, IMAGE_MODE, 30)) {
blinkLED();
}
blinkLED(5);
}
void loop() {
if(!Serial) {
Serial.begin(115200);
while(!Serial);
}
// Time out after 2 seconds, which sets the (constant) frame rate
bool timeoutDetected = millis() - lastUpdate > 2000;
// Wait for sync byte and timeout
// Notice that this order must be kept, or the sync bytes will be
// consumed prematurely
if ((!timeoutDetected) || (Serial.read() != 1))
{
return;
}
lastUpdate = millis();
// Grab frame and write to serial
if (cam.grabFrame(fb, 3000) == 0) {
Serial.write(fb.getBuffer(), cam.frameSize());
} else {
blinkLED(20);
}
}
Processing sketch:
/*
Use with the Examples -> CameraCaptureRawBytes Arduino sketch.
This example code is in the public domain.
*/
import processing.serial.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Serial myPort;
// must match resolution used in the Arduino sketch
final int cameraWidth = 320;
final int cameraHeight = 240;
// Must match the image mode in the Arduino sketch
final boolean useGrayScale = true;
// Must match the baud rate in the Arduino sketch
final int baudRate = 115200;
final int cameraBytesPerPixel = useGrayScale ? 1 : 2;
final int cameraPixelCount = cameraWidth * cameraHeight;
final int bytesPerFrame = cameraPixelCount * cameraBytesPerPixel;
final int timeout = int((bytesPerFrame / float(baudRate / 10)) * 1000 * 2); // Twice the transfer rate
PImage myImage;
byte[] frameBuffer = new byte[bytesPerFrame];
int lastUpdate = 0;
boolean shouldRedraw = false;
void setup() {
size(320, 240);
// If you have only ONE serial port active you may use this:
//myPort = new Serial(this, Serial.list()[0], baudRate); // if you have only ONE serial port active
// If you know the serial port name
//myPort = new Serial(this, "COM5", baudRate); // Windows
//myPort = new Serial(this, "/dev/ttyACM0", baudRate); // Linux
myPort = new Serial(this, "/dev/cu.usbmodem144201", baudRate); // Mac
// wait for a full frame of bytes
myPort.buffer(bytesPerFrame);
myImage = createImage(cameraWidth, cameraHeight, ALPHA);
// Let the Arduino sketch know we're ready to receive data
myPort.write(1);
}
void draw() {
// Time out after a few seconds and ask for new data
if(millis() - lastUpdate > timeout) {
println("Connection timed out.");
myPort.clear();
myPort.write(1);
}
if(shouldRedraw){
PImage img = myImage.copy();
img.resize(320, 240);
image(img, 0, 0);
shouldRedraw = false;
}
}
int[] convertRGB565ToRGB888(short pixelValue){
//RGB565
int r = (pixelValue >> (6+5)) & 0x01F;
int g = (pixelValue >> 5) & 0x03F;
int b = (pixelValue) & 0x01F;
//RGB888 - amplify
r <<= 3;
g <<= 2;
b <<= 3;
return new int[]{r,g,b};
}
void serialEvent(Serial myPort) {
lastUpdate = millis();
// read the received bytes
myPort.readBytes(frameBuffer);
// Access raw bytes via byte buffer
ByteBuffer bb = ByteBuffer.wrap(frameBuffer);
// Ensure proper endianness of the data for > 8 bit values.
// The 1 byte bb.get() function will always return the bytes in the correct order.
bb.order(ByteOrder.BIG_ENDIAN);
int i = 0;
while (bb.hasRemaining()) {
if(useGrayScale){
// read 8-bit pixel data
byte pixelValue = bb.get();
// set pixel color
myImage.pixels[i++] = color(Byte.toUnsignedInt(pixelValue));
} else {
// read 16-bit pixel data
int[] rgbValues = convertRGB565ToRGB888(bb.getShort());
// set pixel RGB color
myImage.pixels[i++] = color(rgbValues[0], rgbValues[1], rgbValues[2]);
}
}
myImage.updatePixels();
// Ensures that the new image data is drawn in the next draw loop
shouldRedraw = true;
// Let the Arduino sketch know we received all pixels
// and are ready for the next frame
myPort.write(1);
}


