We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › receive CMUCam3 JPEG dump, and saving to file
Page Index Toggle Pages: 1
receive CMUCam3 JPEG dump, and saving to file (Read 917 times)
receive CMUCam3 JPEG dump, and saving to file
Dec 6th, 2007, 3:11pm
 
The CMUCam3 has a feature (in CMUCam2 emulation-mode) that allows it to dump a JPEG image (in binary format) back via serial.

I am capturing the incoming data using the serial.read() function, and placing them into a large char array (I tried using an int and a byte array before as well).

Doing a println on a char-converted copy of the int array in Processing appears to reveal what looks like the JPEG file, with the two starting bytes 0xFF+0xD8, the JFIF JPEG header et al, but where I'm stuck at is trying to save this array into a file.

I have tried the saveStrings() function but that seems to convert the bytes into something else (alphanumeric text and readable chars, probably).

This leaves me with saveBytes(), but I don't quite know how to correctly convert ints to java's signed bytes; the 0-255 values of the ints wrap around if I just do a byte(int) conversion (correct me if I'm wrong), and simply subtracting 128 from the int doesn't work either.

So my question is this: how do I save the JPEG framedump from the CMUCam3 (or any other serial device, for that matter) while preserving its binary form?


Any thoughts?

Page Index Toggle Pages: 1