Interfacing with a Camera
Jeremy Gillick
Posts: 7
I am a software guy new to microcontrollers and am trying to figure out how to inteface a Propeller Microcontroller with a camera sensor like this one from SparkFun:
http://www.sparkfun.com/commerce/product_info.php?products_id=8668
The problem is I can't find any information or tutorials on interfacing with cameras.
What I want to do is use the microncontroller as a proxy to get the image data from the camera and directly stream it to an SD card or send it to my server through a cellular module. I can't use the CMU Cam because the device needs to be as small as possible.
I chose that camera because it can do on-board JPEG compression. From what I've read in the datasheet it looks like the data is sent through DOUT0 - 7. I'm not really sure what to make of the rest of the details. I've done several smaller projects with microcontrollers involving serial communication and other sensors and I can usually pick up on things if I see a working example.
Are there any resources or examples that can help me figure out how to do this?
http://www.sparkfun.com/commerce/product_info.php?products_id=8668
The problem is I can't find any information or tutorials on interfacing with cameras.
What I want to do is use the microncontroller as a proxy to get the image data from the camera and directly stream it to an SD card or send it to my server through a cellular module. I can't use the CMU Cam because the device needs to be as small as possible.
I chose that camera because it can do on-board JPEG compression. From what I've read in the datasheet it looks like the data is sent through DOUT0 - 7. I'm not really sure what to make of the rest of the details. I've done several smaller projects with microcontrollers involving serial communication and other sensors and I can usually pick up on things if I see a working example.
Are there any resources or examples that can help me figure out how to do this?
Comments
One problem is that you can't slow the read from the camera the processor must read at the rate the camera wants to sent it. Thats going to be hard to keep up with, without some hardware, theres some people trying using fpga's. Aother option is using a fifo such as the al440B. This allows the camera speed and the processor speed to be different. I am using the al440B with a different camera but I haven't tried with this camera sensor.
In general, how does someone learn about interfacing with cameras? I think I understand the concept of FIFO chips but don't completely grasp the purpose of an FPGA in this sort of application. If you're pulling the data as raw bytes, how do you convert that to a viewable image? Are there any tutorials or sites with the code and circuit diagrams?
Thanks.
The other thing to realize is cameras output in different formats, jpeg is a compressed format and you will need to decompress it to display. I haven't seen a jpeg decompressor for the prop though I dont see why it isn't doable. Other formats are rgb and yuv, both are uncompressed. Depending on the resolution you want you may have problems with the prop because of memory. e.g. if the camera outputs vga (smaller resolution than the TCM8204), this is 640*480*2bytes per frame (uncompressed). This will not fit in a props memory. This is solvable in a many ways: lower resolution, black and white, or process a few lines from the camera at a time, i.e. read 4 lines from the fifo, process them, read the next 4 lines, etc.
If you are interested in an example circuit using a fifo, look at the manual for the cmucam3 camera, it uses a al440B fifo and the manual gives a schematic.
http://www.rayslogic.com/propeller/Programming/Cameras/cameras.htm
But, yours looks better with 8-bit interface and a Megapixel...·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Good thread.
IMO, to date the easiest approach would be to do as Rayman does. He is very modest, but he did the right work on a dandy little camera. He modified code originally posted by Harrison. The nice thing about this camera is that you can sub-sample it... to get raw data... all the way from a tiny little image up to 640X480?
I would get the exact same camera as he did because the lens seems good enough for stereo-photogrammetry.
Rayman's second link is dead right now... and I have never been able to find Harrison's code.
Help anyone?
Rayman... would you like to sell the prototype of your stereo camera?
Rich
I didn't mean to insult you ... I just happen to think you are doing some of the best work around.
Rich
* Put the FIFO in between the camera and the microcontroller.
* Take the output bits from all 8 FIFO pins and concatenate them together. (YUV or RGB format)
* After the data downloads to the SD card and is transferred to the computer it can be converted from the raw format to a compressed format like JPEG.
Is this correct?
Thanks.
I have a ov6620 connected to a al440b to a prop. Its not working yet, was debugging the hardware when I got sidetracked onto other projects.
On a similar topic, I'm trying to find a good SD card interface and am torn between:
* http://www.sparkfun.com/commerce/product_info.php?products_id=8215
* http://www.saelig.com/miva/merchant.mvc?Screen=PROD&Product_Code=FF015&Category_Code=FF
* http://www.active-robots.com/products/accessories/ummc.shtml
Any thoughts or preferences? And any more pointers or references for camera development are very much appreciated.
Thanks.
I have used ucontroller.com
Those SD card boards look like direct connections so any sort of FAT filesystem will have to be managed by a library, right?
I'll definitely checkout that book, thanks for the recommendation!
It is a little pricey, but I love it and never get tired of talking about it... and "that" is the uOLED-prop-96 from 4D systems... it has a Prop... it has a uSD card holder. The new version now has a 5MHz crystal... all of the prototype functions that you need to get images in and out of the Prop are included in the demo... what you pay for the hardware will save you hours and hours and hours of looking around and trying to figure it all out yourself. AND it is just so darned cute, you will fall in love with it[noparse]:)[/noparse]
For much of what I want to do, I don't really need real time imaging and I want to get the computer completely out of the loop... so a slow serial camera or a regular analog model with acquisition done over many frames of video for a single image would work just fine for me.
The only note of caution that I have for you is to make sure that whatever you spend your time on that there is a lasting supply. Years ago I spent a lot of time and effort on a Kodak camera, which had already been discontinued and was later taken completely off the market... a huge pain that eventually lead to the demise of my little medical imaging company. More recently Phil had the same experience with a camera for the Prop. There are lots of ways to skin this cat... just make sure you aren't wasting your time on a dead cat.
Rich
That is the coolest little device ever -- I want one! Are there any good examples out there for interfacing it with a camera? I'm now adding that to my wish list of things to order and play with. Thanks.
Thanks.
I just purchased one of those cams from Electronics123. The file in the code "PreviewPlace.dat", is that a file I need to install on my SD card?
Thanks,
Tagamet
Let me know what approach you take as far as Camera, ect. I have not been able to obtain much information on video interfacing either but will definetly buy the book as mentioned earlier in the thread.
http://www.saelig.com/BOVI/BOVI009.htm
Cost looks reasonable...
I've got the PreviewPlace.dat file in place & am using your C328v3.spin program (I'm using fsrw & FullDuplexSerialExtended from the OBEX). I changed the name of FDSE to match the object, everything compiles correctly, the camera just never syncs. I've let it try to snyc many times w/ no success. I've changed the baud rate multiple times. I have the CS/DI/SCLK/DO on the SD card adapter connected to P7-P4, 3.3V & GND connected to the Prop output on the rails, the Parallax VGA-PS/2 Adapter connected to P16-P27, 5V from the 5V regulator & rail GND. I got some VGA demos to display info on my monitor so it works. Do I need to change any monitor settings? I'd like to preview the picture & save it to the SD card.
Thanks,
Tagamet
P.S. - I have the c328 camera from electronics123.com
But, here are some things to check...
Make sure you are giving it power (3.3VDC).
Make sure you don't have TX and RX reversed.
Tagamet
Thanks again,
Tagamet
You do have the old, C328 and not the new C329, right?
I have the C328RS. The datasheet listed on electronics123.com is the same. The code I'm using is the C328v3.spin (only differences are that I made a constant for the baudrate & entered a few serial debug statements to see where I get in the code) & I have a new discovery. If I disconnect the ground to the camera while the program is running, it connects @ 115200 baud. I then get to the 2 separate Command Accepted serial statements. But I still don't get a preview.
Thanks again,
Tagamet