Go Down

Topic: Serial Camera Interface (Read 5325 times) previous topic - next topic

RjPrimer

Hi guys, I recently bought egizmo serial camera, C328, can you help me interface it with my arduino? Thanks!!!!!!

here is the camera http://www.e-gizmo.com/KIT/serial%20camera.html

PaulS

The Technical Manual, available on the link you posted, shows that there are two ways to connect that camera to a computer, one of which is perfect for the Arduino. What do you need help with?

RjPrimer

I've read previous posts about the arduino code on capturing images, btw I'm a newbie in arduino codes so I really need your help right here guys

the code goes like this

#include <CameraC328R.h>
#include <NewSoftSerial.h>
#define LED_PIN 13
#define PAGE_SIZE 64
#define USB_BAUD 115200
#define CAMERA_BAUD 14400
NewSoftSerial mySerial(2, 3);
CameraC328R camera(&mySerial);
uint16_t pictureSizeCount = 0;
/**
* This callback is called EVERY time a JPEG data packet is received.
*/
void getJPEGPicture_callback( uint16_t pictureSize, uint16_t packageSize,
uint16_t packageCount, byte* package )
{
// packageSize is the size of the picture part of the package
pictureSizeCount += packageSize;
Serial.write(package,packageSize);
if( pictureSizeCount >= pictureSize )
{
digitalWrite( LED_PIN, LOW );
Serial.flush();
}
}
void setup()
{
Serial.begin( USB_BAUD );
mySerial.begin(CAMERA_BAUD);
pinMode( LED_PIN, OUTPUT );
digitalWrite( LED_PIN, LOW );
}
void loop()
{
if( Serial.available() ){
while(Serial.read() != -1);
digitalWrite( LED_PIN, HIGH );
if( !camera.sync() )
{

Serial.println( "Sync failed." );
return;
}
if( !camera.initial( CameraC328R::CT_JPEG, CameraC328R::PR_160x120,
CameraC328R::JR_640x480 ) )
{
Serial.println( "Initial failed." );
return;
}
if( !camera.setPackageSize( 64 ) )
{
Serial.println( "Package size failed." );
return;
}
if( !camera.setLightFrequency( CameraC328R::FT_50Hz ) )
{
Serial.println( "Light frequency failed." );
return;
}
if( !camera.snapshot( CameraC328R::ST_COMPRESSED, 0 ) )
{
Serial.println( "Snapshot failed." );
return;
}
pictureSizeCount = 0;
if( !camera.getJPEGPicture( CameraC328R::PT_JPEG, PROCESS_DELAY,
&getJPEGPicture_callback ) )
{
Serial.println( "Get JPEG failed." );
return;
}
}
}


Ive downloaded properly the c328 and newsoftserial library but im still getting these errors :

In file included from sketch_sep22a.cpp:1:
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:24:22: error: WProgram.h: No such file or directory
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:25:24: error: WConstants.h: No such file or directory
In file included from sketch_sep22a.cpp:2:
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\NewSoftSerial/NewSoftSerial.h:33:2: error: #error NewSoftSerial has been moved into the Arduino core as of version 1.0. Use SoftwareSerial instead.
In file included from sketch_sep22a.cpp:1:
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:130: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:132: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:137: error: 'byte' does not name a type
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:138: error: 'byte' does not name a type
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:139: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:139: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:139: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:139: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:139: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:141: error: 'byte' has not been declared
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:144: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:145: error: ISO C++ forbids declaration of 'byte' with no type
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:121: error: 'NULL' was not declared in this scope
In file included from sketch_sep22a.cpp:2:
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\NewSoftSerial/NewSoftSerial.h:99: error: conflicting return type specified for 'virtual void NewSoftSerial::write(uint8_t)'
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
sketch_sep22a.cpp: In function 'void loop()':
sketch_sep22a:62: error: invalid conversion from 'void (*)(uint16_t, uint16_t, uint16_t, byte*)' to 'void (*)(uint16_t, uint16_t, uint16_t, int*)'
sketch_sep22a:62: error: initializing argument 3 of 'bool CameraC328R::getJPEGPicture(CameraC328R::PictureType, uint16_t, void (*)(uint16_t, uint16_t, uint16_t, int*))'

can you help me debug this errors? Ive placed the libraries in the libraries folder already

RjPrimer

Im having problem with this line

if( !camera.getJPEGPicture( CameraC328R::PT_JPEG, PROCESS_DELAY, &getJPEGPicture_callback ) )
    {


with this error
invalid conversion from 'void (*)(uint16_t, uint16_t, uint16_t, byte*)' to 'void (*)(uint16_t, uint16_t, uint16_t, int*)'

can you please help mee!!

here is the tutorial


http://sensorapp.net/?p=310

dxw00d

Quote
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:24:22: error: WProgram.h: No such file or directory
C:\Users\msi\Desktop\for Arduino Seminar\arduino-1.0\libraries\CameraC328R/CameraC328R.h:25:24: error: WConstants.h: No such file or directory


That library is not compatible with the 1.0+ versions of the Arduino IDE. You're the second person to be asking about that library this week.

As I said in the other thread:

You need to either:
. Use a pre-1.0 version of the IDE.
. Find a newer version of the library, or contact the author and get them to update it.
. Update it yourself.

If you want to update it yourself, there are a number of things you need to do.
. See point 2 at http://arduino.cc/forum/index.php/topic,97455.0.html.
. The library makes use of NewSoftSerial. You will need to replace all occurrences of NewSoftSerial with SoftwareSerial.
. Replace all:
Code: [Select]
Serial.print(data,BYTE);
with
Code: [Select]
Serial.write(data);
. There may be other things too.



RjPrimer

Thanks Buddy, more arduino programming questions to come!

PGT

i am curious..
it turns out that the arduino has too little memory to store an image.
One wouldnt put a arduino in between a cam if it can be attached directly.
Are you sending the image to an extension board directly ? (wifi or ... ? )

And is the cam / arduino combination in .. well in speed match, because camera's can be fast.

RjPrimer

I'll get the image through the Processing as suggested by the tutorial, the baud rate for both the arduino and the serial camera is given, it will be stored in the processing project folder


The Technical Manual, available on the link you posted, shows that there are two ways to connect that camera to a computer, one of which is perfect for the Arduino. What do you need help with?


Sir Can I Request for an Overall (actual connections / codes) Tutorials / Guide for setting up an Arduino with a serial cam triggered by a PIR Sensor.. Captured picture must be on a desktop or laptop pc.. Thanks In Advance

RjPrimer

my processing was able to display 'Read 4 bytes' only and the image that is being produced is Invalid T_T

rovelle

Who could give the updated code of the c328 serial camera..i really need this for our project...please help me!..thanks in advance..i will appreciate it a lot...:D

Coding Badly


Please post replies to @rovelle here... http://arduino.cc/forum/index.php/topic,141279.msg1075608.html#msg1075608

Go Up