It's a been quite while, when I published the the first article about C328R Jpeg camera. It turns out to be the most discussed article on my blog. With new features, that came with .NET Micro Framework 3.0, I've decided to make a little update to C328R class.
C328R camera module
What's new
One thing that changed in version 3.0 of Micro Framework was the serial port API. Since C328R camera module is operated via serial port, the update was necessary. Anyway, this brings one big advantage of one compatible class for .NET Micro Framework and full .NET Framework. In next days I will try to connect the camera to desktop computer and to talk to it from C#. Long story short, the constructor and initialization of the C328R class might look like this.
// Create camera C328R camera = new C328R(new SerialPort("COM2", 115200)); // Synchronize with camera camera.Sync(); // Set baud rate - optional camera.SetBaudRate(C328R.BaudRate.Baud115200); // Set light frequency - optional camera.LigtFrequency(C328R.FrequencyType.F50Hz); // Initiate camera and picture details camera.Initial(C328R.ColorType.Jpeg, C328R.PreviewResolution.R160x120, C328R.JpegResolution.R640x480);
Saving picture to SD card
The only thing I've changed in the demo application is the persistence of the picture on the SD card. Since .NET Micro Framework 3.0 introduced
native support for the file system, I thought it would be nice to integrate it. Tahoe-II comes
with SD card slot which is mapped as directory called \SD1. Make sure to change this directory to fit your hardware. Some sample images
taken by the camera and stored to the SD card are attached.
Notice that saving picture to SD card takes few seconds.
private void SaveFileOnDisk(byte[] pictureData) { // This directory is valid for Tahoe-II SD card slot only!! Directory.SetCurrentDirectory(@"\SD1"); // Some unique picture name based on time string pictureName = string.Concat( "IMG_", DateTime.Now.Hour.ToString(), DateTime.Now.Minute.ToString(), DateTime.Now.Second.ToString(), ".jpeg"); // Save the data into file using (FileStream fs = new FileStream(pictureName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { fs.Write(pictureData, 0, pictureData.Length); fs.Close(); } }
Download
Old and new version are now bundled in one zip archive.
Download demo here C328R_stuff.zip [32 Kb].
Sample pictures
Part of my office desk
Things on my office desk
Self portrait
[1] Nice self portrait
I love your self portrait :-), maybe you need to take some time off...
Picture analysis:
1. Your office desk looks a little empty
2. You drink Coca Cola
3. You are interested in robotics
The picture of the cheer leaders could be clearer (maybe a better camera module?)
best regards
Peter