v01d
Posts: 5
Joined: Fri Jul 20, 2012 2:33 am

thinking about interfacing camera modules with raspberry pi

Fri Jul 20, 2012 2:42 am

Hi,
I would like to ask some things to clear up some things I've been thinking. Beware that I'm no expert in electronics so maybe I'm mistaken in some things.

My goal: to build a low-weight stereo camera rig which can be used by the raspberry pi.

For the camera modules, I initially looked up for the OV7670 but I'm now more interested in the MT9M111. These two have the possibility to feed them with an external clock input, which I think is the way to synchronize both cameras (essential for stereo vision). This clock is in the order of 54Mhz for the MT9. The output clock under which pixels are outputed is around 24Mhz for this module. The module simply provides 8 lines (bits). 16 bits consist of a pixel (RGB555, for instance).

Assuming that I solve how to generate the 54Mhz clock signal for both modules (I think there are some ICs that do this), I have one important question (maybe several other simpler ones):

How does one read data from a camera (or camera pair) like this, where I have to read 8 lines simultaneosly at 24MHz? I think the GPIO clock is up to par, right? What would be the required interface to read these lines at that speed and feed them to the RPi? Some kind of intermediate memory? Something using DMA? I'm quite lost with this.

Thank you!

FWIW: if I ever get to produce this, it will be open-source... just to provide some incentive to my question =)

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Mon Jul 23, 2012 2:05 pm

I've bought two OV7670 camera boards for a very similar project. These cameras are complete webcams without the usb it seems. I was wondering how you were planning on hooking your's up to the pi?

One thing I found out is that there is a driver for the OV7670. It includes most, if not all of the magic bytes that set things up. I'm confused about how to actually get the pi talking to them, and connecting though.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 31215
Joined: Sat Jul 30, 2011 7:41 pm

Re: thinking about interfacing camera modules with raspberry

Mon Jul 23, 2012 2:48 pm

I don't think the GPIO's are fast enough. On the GPU there is two dedicated CSI-2 interface for cameras which can run extremely fast, (96Mhz) but there is only one channel exported on the Raspi, so no use for stereo (The GPU can actually do it)

For your purposes, I'm thinking some sort of high speed device (PIC?) to get frames from the camera, multiplex them together then send the data via USB to the Raspi. You won't get very high resolution or frame rate though.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Mon Jul 23, 2012 4:39 pm

Actually frame rate isn't the big concern here. I want to avoid cpu overhead in handling usb and decrypting. Raw data feed would be wonderful. I'm looking to use it with robotics with opencv so the less encrypting/decripting to do the better.

However with your frame rate comment in mind, I'm thinking of ordering a 2nd pi, and use one pi per camera. Then one of the pi's can integrate the results.

My big problem is connecting the pi to the board, and getting the drivers to talk to it.

I've seen arduino code which apparently works with this camera. So I expect the camera does most of the work, and it's simply a matter of downloading.

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am

Re: thinking about interfacing camera modules with raspberry

Wed Jul 25, 2012 6:46 pm

There exists a CSI two input mux chip from Fairchild.
That would be your best solution.
The problem is that you would need some very nifty driver SW to use that.
Sort of like:take picture, switch to other channel, take picture, switch back etc.
I am afraid there is no way to do that without extreme intimate knowledge of the BCM2835 hardware.

User avatar
jbeale
Posts: 3902
Joined: Tue Nov 22, 2011 11:51 pm

Re: thinking about interfacing camera modules with raspberry

Wed Jul 25, 2012 6:50 pm

iplayfast wrote:I've seen arduino code which apparently works with this camera. So I expect the camera does most of the work, and it's simply a matter of downloading.
As far as I know, an Arduino with the ATMEGA328P chip uses 16 MHz as the processor clock. The fastest interface is SPI and it cannot run faster than the CPU clock, so I don't know how a 24 MHz pixel clock from a camera module could be accepted unless you are skipping every other bit, or something like that. You could use an external chip as a buffer, but unless you are skipping pixels or skipping lines, it might need enough memory to buffer an entire frame. Unless the camera itself has a hardware handshake to slow down the output. Or you do a rude hack like grabbing the first pixel of the first frame, the second pixel of the second frame, etc. (which has actually been done to get tiny images out of an optical mouse chip) but you'll have horrible image skew with any subject or camera movement and it would not be very usable for machine vision. Unless your robot moves R-E-A-L-L-Y slowly.

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Wed Jul 25, 2012 6:59 pm

This particular camera has a fifo buffer, so frames could be grabbed, but obviously an arduino wouldn't be able to keep up.

v01d
Posts: 5
Joined: Fri Jul 20, 2012 2:33 am

Re: thinking about interfacing camera modules with raspberry

Wed Jul 25, 2012 11:50 pm

Hi! didn't receive all answers! I didn't expect so many responses, so I'll try to answer each.

iplayfast: I've just realized exactly what you state, that I could create a USB interface. I don't know much about that, but it would be the best. Do you have any idea on how to create such circuit? I've just googled around and there seem to exist specific ICs that serve this function (like MAX3420E for example). I don't know how easy it is to get it (I would have to order abroad).
I actually use a minoru camera at this moment and it is simply a couple of usb cameras connected through a bus, so bandwidth (USB2.0?) and frame rate can be at least 640x480@15fps for sure. This would be more than enough for me (I'm also in robotics).
Do you have any work on this idea?

jamesh: I've considered that exact Idea but I'm not sure on how to then interface the PIC with the Pi, since the Pi's GPIO is so slow. The USB interface would solve this I guess.

Gert: that is indeed interesting, I will consider this. The only problem is that the OV7670 is not CSI I think. Or is it?

iplayfast: yes, it has a fifo, but only for half-frame afaik, so you still need to get data quick enough

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Thu Jul 26, 2012 4:13 am

I have done some work with two usb webcams with Linux, and it is possible, but you need to have two separate usb interfaces. There isn't enough bandwidth on one usb line to support two cameras.

v01d
Posts: 5
Joined: Fri Jul 20, 2012 2:33 am

Re: thinking about interfacing camera modules with raspberry

Thu Jul 26, 2012 12:48 pm

The minoru 3D camera has two usb cameras connected in one. I guess it depends on resolution, FPS and compression of data.
But, did you say you were able to sync them by hardware?

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Thu Jul 26, 2012 4:12 pm

No, I just meant that you can have two usb webcams connected to a linux box, but the need to be on separate usbports.

Rasoul
Posts: 3
Joined: Fri Feb 01, 2013 10:15 pm

Re: thinking about interfacing camera modules with raspberry

Mon Feb 18, 2013 1:26 pm

I recommend to use Minoru 3D Webcam with Raspberry Pi board. That is more practical (and less expensive) than other solutions for stereo vision experiments with Raspberry Pi boards.

unklegeorge
Posts: 6
Joined: Wed Feb 06, 2013 5:10 am

Re: thinking about interfacing camera modules with raspberry

Tue Feb 19, 2013 11:45 pm

Sounds like you could use an FPGA , maybe something like this: http://www.xess.com/prods/prod048.php

Then you could program the FPGA to mux and buffer the parallel camera output to the RPi SPI bus. It would also let you control the 'shutter' on multiple cameras so call the frames are in sync. There would be enough logic room to implement some pre-processing and compression to get a higher framerate over the SPI bus.

Here's something similar that connected a camera chip to a parallel port.
https://github.com/bitflippersanonymous/fpga-camera

iplayfast
Posts: 8
Joined: Sun Oct 30, 2011 11:35 pm

Re: thinking about interfacing camera modules with raspberry

Wed Feb 20, 2013 3:11 am

Just as an update. I discovered that I was wrong. It has everything to do with the size of the image you are receiving. Get small ones and it works, large ones and it doesn't.

User avatar
jiapei100
Posts: 62
Joined: Sun Mar 04, 2012 10:16 am
Location: Surrey, BC, Canada

Re: thinking about interfacing camera modules with raspberry

Sun Jun 02, 2013 4:01 pm

Extremely interested in this topic and would like to follow.
Anyway, did you find a way out already? How to do that? Do you have a manual for me to follow?


cheers
Pei
Welcome to Vision Open
http://www.visionopen.com

drumminhands
Posts: 25
Joined: Wed Mar 06, 2013 4:37 pm
Location: Boston, MA

Re: thinking about interfacing camera modules with raspberry

Sat Jun 29, 2013 4:38 pm

Like Pei, I too am very interested in this topic. Any news?

User avatar
Parkingware
Posts: 2
Joined: Thu Apr 18, 2013 12:10 pm

Re: thinking about interfacing camera modules with raspberry

Wed Jul 03, 2013 10:16 am

We start with a License Plate Recognition project on the RPI.

First part is getting the camera image. It is possible with the IDS1222LE-M (IDS has a beta driver for this). We do look also for a low budget usb camera like the MT9M111 and OV7670.

Second part is getting our LPR engine (C++ with OpenCV) on the RPI and see what performance it has (or not)

If there is anybody interessed in sharing information then please let met know
Regards,
Gerard

User avatar
drkblog
Posts: 2
Joined: Thu Oct 03, 2013 1:04 pm
Location: Buenos Aires, Argentina

Re: thinking about interfacing camera modules with raspberry

Thu Oct 03, 2013 1:22 pm

jiapei100 wrote:Extremely interested in this topic and would like to follow.
Anyway, did you find a way out already? How to do that? Do you have a manual for me to follow?
Same here!

I have used an OV7670 (with and without FIFO) with Arduino UNO and Mega2560. Not easy, but not impossible. The problem is my project requires to grab a 640x480 frame and there is no enough memory in Arduino for doing so. Even the FIFO version, which can hold one VGA frame, has to be read in one step at 1MHz at least (one byte per microsecond). Right now I have two options: modifying the OV7670 module for fixing a design flaw which prevents me from reading the FIFO frame in parts; or migrating the project to Raspberry Pi where I have enough RAM.

Although I'm not an expert, I've a lot of experience with the OV7670 now.

vaibhav.wayne
Posts: 3
Joined: Sun Oct 04, 2015 8:16 am

Re: thinking about interfacing camera modules with raspberry

Sun Oct 04, 2015 8:19 am

Hey! I am new to rpi. I am working on a project which requires feed from camera. I've bought an ov7670, as it was cheap and affordable. I'm facing difficulty in connecting my camera module to the rpi. Any help please?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13013
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: thinking about interfacing camera modules with raspberry

Sun Oct 04, 2015 9:24 pm

You are likely to struggle with OV7670. It is a parallel interface which will run faster than you can sensibly read GPIOs. I am not aware of anyone who has got that sensor working on a Pi.

For 99% of cases, the official Pi camera fits the bill at a modest price.
If you really want to push the boat out, look for a sensor with a CSI-2 interface and you should be able to receive the data as described here. You may still be digging a hole for yourself though.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

vaibhav.wayne
Posts: 3
Joined: Sun Oct 04, 2015 8:16 am

Re: thinking about interfacing camera modules with raspberry

Mon Oct 05, 2015 2:34 pm

Can you please explain exactly what speed (rate of transfer) problem are you referring to?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13013
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: thinking about interfacing camera modules with raspberry

Mon Oct 05, 2015 2:54 pm

Take a basic use case of VGA@30 as RGB. That's 640*480*3*30 = 27,648,000bits/sec ignoring any overheads.
You have an 8 bit bus, so that has to run at 3,456,000bytes/sec, or 3.456MHz. You have an outside chance of sampling the GPIOs at that rate if you use something that directly accesses the registers from userspace (eg wiringPi). However you are on a multitasking OS, so you have no control over being pre-empted by the OS to allow something else to run. Handling that sensibly is near-impossible as a userspace app.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Interfacing (DSI, CSI, I2C, etc.)”