Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing with a Camera — Parallax Forums

Interfacing with a Camera

Jeremy GillickJeremy Gillick Posts: 7
edited 2011-11-30 08:23 in Propeller 1
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?
«1

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2008-07-31 07:02
    I dont believe anyones done it yet with a prop. Theres some discussion on sparkfuns forum about people trying with other processors. See http://forum.sparkfun.com/viewtopic.php?t=10314
    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.
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-07-31 07:09
    I was looking at that thread and saw mention of those issues as well. I'm not tied to that camera and haven't ordered it yet and am open to any better options.

    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.
  • TimmooreTimmoore Posts: 1,031
    edited 2008-07-31 07:40
    The fifo is used as a speed translator, the camera clocks a frame into the fifo, the cpu reads from the fifo at its own speed. Using a FPGA is just another way to do the same thing.
    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.
  • VIRANDVIRAND Posts: 656
    edited 2008-07-31 09:57
    What seems most likely to me to be done first here is to interface a Propeller with a camera via it's SD card slot.
  • RaymanRayman Posts: 14,850
    edited 2008-07-31 11:55
    I've got some code for a different camera here:

    http://www.rayslogic.com/propeller/Programming/Cameras/cameras.htm

    But, yours looks better with 8-bit interface and a Megapixel...·
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-31 12:24
    You might be able to clock the data into an external static ram chip DMA style, then read the data from that using the Prop. The Prop would then handle timing and handshaking, but wouldn't have to handle the data transfer in real time. Just a thought.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • rjo_rjo_ Posts: 1,825
    edited 2008-07-31 20:19
    Jeremy,

    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
  • RaymanRayman Posts: 14,850
    edited 2008-07-31 23:29
    Thanks rjo_ but my "stereo camera" is just a piece of plastic with two holes in it for the cameras... Right now, it's under a pile of junk on my desk. But, one day it's going to be on my robot [noparse]:)[/noparse]. I really have no intention of selling anything at the moment...
  • rjo_rjo_ Posts: 1,825
    edited 2008-08-01 04:46
    No problem, I accept gifts[noparse]:)[/noparse]

    I didn't mean to insult you ... I just happen to think you are doing some of the best work around.

    Rich
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-08-02 18:48
    From what I gathered from this forum and the camera datasheet, this is the process.

    * 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.
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-02 20:11
    Yes, thats about right. That is about what I do, though unless you want to do it as a learning exercise, it would be much quicker and easier to get a cmu camera.
    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.
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-08-03 07:37
    I would use the CMU Camera but it's too big for my application. I am building a wearable camera as a research experiment. It does not need to be concealed but I want it to be comfortable to wear and not too heavy. I've just ordered a serial C328 serial camera (http://bit.ly/2ompPi) like the one Raymond used, which should get me started. I'm still thinking it might be smaller to do it all myself using a FIFO and small microcontroller to send the data to an SD card.

    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.
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-03 07:42
    also look at http://www.ucontroller.com and http://www.futurlec.com/Mini_SC.shtml
    I have used ucontroller.com
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-03 07:49
    In terms of references, I would recommend "Video demystified 4th edition" by Keith Jack. It covers video formats - rgb/yuv, video signals, video scaling, framing dropping, etc. maybe an overkill for you since it goes into video compression mpeg/h264
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-08-04 02:47
    Hey Timmoore,

    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!
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-04 03:30
    do a search in the forums for fsrw there is software to do fat on a sd card or propdos or one of the basics for the prop.
  • rjo_rjo_ Posts: 1,825
    edited 2008-08-05 15:39
    Jeremy...

    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
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-08-06 07:07
    rjo_

    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.
  • Jeremy GillickJeremy Gillick Posts: 7
    edited 2008-08-11 20:32
    I guess the last thing that I'd like to know is about parts and where to get them. For the time being I'm going to be prototyping with the JPEG Serial Camera (http://www.electronics123.com/s.nl/it.A/id.2027/.f?sc=8&category=241) to get something up and working. After that I want to go to a higher resolution; like 1.2 Megapixels or higher. Where can I find a camera module at that resolution and which FIFO should I use. Size is also important here since want this to be a wearable camera.

    Thanks.
  • TagametTagamet Posts: 22
    edited 2011-11-04 07:49
    Rayman,

    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
  • John MichaelJohn Michael Posts: 37
    edited 2011-11-18 12:33
    Jeremy, I would like to do the same thing that you are talking about doing. I have started working with the TeLit 865cf Module and learning to interface it to a Propeller. My end project involves sending live video over Cellular to a web-site that my customers can view via their Smart Phones. I have used the 4D displays in the past and they are Very good ..
    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.
  • RaymanRayman Posts: 14,850
    edited 2011-11-18 17:57
    These cameras over at Saelig look to be a lot like the ones I used:
    http://www.saelig.com/BOVI/BOVI009.htm

    Cost looks reasonable...
  • TagametTagamet Posts: 22
    edited 2011-11-22 06:19
    Ray or anyone,

    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
  • RaymanRayman Posts: 14,850
    edited 2011-11-22 08:50
    It's been a very long time since I've played with my C328...
    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.
  • TagametTagamet Posts: 22
    edited 2011-11-22 09:07
    Thanks Ray. I'll try that shortly.

    Tagamet
  • TagametTagamet Posts: 22
    edited 2011-11-22 10:07
    Done that. No luck whatsoever. I'm debugging the program and I see in the GetAck(pCmd0:bGot method that the initial rxcheck is not returning $AA. I'll see what else I can find.

    Thanks again,

    Tagamet
  • RaymanRayman Posts: 14,850
    edited 2011-11-22 11:20
    If you post a close-up photo of your setup and also the "archive" of your code (if it's any different than mine) I'll take a look.
    You do have the old, C328 and not the new C329, right?
  • TagametTagamet Posts: 22
    edited 2011-11-23 10:37
    Ray,

    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
  • RaymanRayman Posts: 14,850
    edited 2011-11-23 11:07
    That's very strange... I think you must have RX and TX reversed... You might also try dropping to 14400 baud...
  • TagametTagamet Posts: 22
    edited 2011-11-23 11:16
    I will do both & try again.
Sign In or Register to comment.