paddi2013
Posts: 24
Joined: Wed Jul 17, 2013 4:30 am

Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 5:24 am

Hello everybody, currently i am doing a project which requires using multiples cameras on a single raspberry pi board. I was wondering if it is possible to use multiple cameras on a single raspberry pi board ? and if it's possible then how to use it.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1423
Joined: Sat Sep 10, 2011 11:43 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 5:37 am

No it is not possible on the Raspberry Pi

Use two Pi's and the network maybe...

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:03 am

Do you have in mind using the dedicated hi-res camera connected to the special connector on the RPi board?

If so, Gordon's answer is correct.

But if you were able to use general-purpose usb-connected cameras, would the os stop you connecting multiple cameras via a usb hub? (Not sure - punting a slightly different question for experts to tackle... )
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

mikerr
Posts: 2774
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:18 am

You can only use one csi camera module per pi,
But using a usb camera as well would work ok for a total of two cameras.

Usb cameras use a lot of cpu, so using two of them isn't advisable.

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:33 am

Is the objective to capture video simultaneously from multiple cameras at normal frame rates?
If so use multiple RasPi/camera combinations and feed the compressed streams over a network.
It's the simplest and possibly the cheapest option, with best performance.

If slow frame rates are acceptable, or only one camera will be running at video rate at any time, then there may be two options:
a. Several USB cameras, only one of which is open at any time
b. If some custom circuitry and camera management software development is an option for you you may be able to multiplex several PiCams onto the one CSI port.

This is by no means a recommendation. I can't say it will work, but it may be a place to start.

paddi2013
Posts: 24
Joined: Wed Jul 17, 2013 4:30 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:44 am

if i would to connect 2 raspberry pi boards each with their own pi cameras, is it possible to save the jpegs into one storage ? lets say an external hard disk ? if i am wrong, please point me to the right direction as i am new in electronics. Please and tq ! :)

ghans
Posts: 7871
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:47 am

If you connect both Pis to the same wireless/wired/mixed
network , you can set up the other one as network drive.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

paddi2013
Posts: 24
Joined: Wed Jul 17, 2013 4:30 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:52 am

PiGraham wrote:Is the objective to capture video simultaneously from multiple cameras at normal frame rates?
If so use multiple RasPi/camera combinations and feed the compressed streams over a network.
It's the simplest and possibly the cheapest option, with best performance.

If slow frame rates are acceptable, or only one camera will be running at video rate at any time, then there may be two options:
a. Several USB cameras, only one of which is open at any time
b. If some custom circuitry and camera management software development is an option for you you may be able to multiplex several PiCams onto the one CSI port.

This is by no means a recommendation. I can't say it will work, but it may be a place to start.
thank you for replying, i am interested in option b, since we are looking into capturing jpegs instead of video. theoretically speaking, how many pi cameras can be multiplexed into one CSI port ? and how complicated will the custom circuit be ? Please and thank you !

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:53 am

paddi2013 wrote:if i would to connect 2 raspberry pi boards each with their own pi cameras, is it possible to save the jpegs into one storage ? lets say an external hard disk ? if i am wrong, please point me to the right direction as i am new in electronics. Please and tq ! :)
Yes. For just two Pis + cams:
Connect the two Pis with a network (could be just a Cat5 cable).
Mount a USB hard disk on one of the Pis and share the mount point as a network drive.
Mount the network drive on the second Pi.
On each Pi specify a file on the HD mount point as output for your jpgs.

There are various ways it could be done.

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 7:57 am

paddi2013 wrote:
PiGraham wrote:Is the objective to capture video simultaneously from multiple cameras at normal frame rates?
If so use multiple RasPi/camera combinations and feed the compressed streams over a network.
It's the simplest and possibly the cheapest option, with best performance.

If slow frame rates are acceptable, or only one camera will be running at video rate at any time, then there may be two options:
a. Several USB cameras, only one of which is open at any time
b. If some custom circuitry and camera management software development is an option for you you may be able to multiplex several PiCams onto the one CSI port.

This is by no means a recommendation. I can't say it will work, but it may be a place to start.
thank you for replying, i am interested in option b, since we are looking into capturing jpegs instead of video. theoretically speaking, how many pi cameras can be multiplexed into one CSI port ? and how complicated will the custom circuit be ? Please and thank you !
Since you wrote
i am new in electronics
I don't think option b is for you at this stage.

How often do you want to capture a jpeg, from how many cameras? How far away from the Pi would these cameras be?

One Pi per camera allows each camera to be far apart (100m cable between Pis)

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

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 8:45 am

I don't think option B is actually possible.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
RaTTuS
Posts: 10406
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 8:51 am

multiple RPI's + Cmaera
and depending on frame / data rates either another RPI running a NAS sever or another box entirely or one of the RPI's holding the store
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 8:57 am

jamesh wrote:I don't think option B is actually possible.
Quite possibly so, but could you give some clues as to why not?

At the most basic, can't the entire interface be multiplexed with tri-state bus drivers to slow-switch from one camera to another?
Allowing something like this:

Code: Select all

selectcamera 1
rapistill -o img1.jpg, -t 5000
selectcamera 2
rapistill -o img2.jpg, -t 5000
selectcamera 3
rapistill -o img3.jpg, -t 5000
Where selectcamera sets one of three OE drives on GPIO.

No sync, no on-the-fly switching. Full init after each switch.

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

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:03 am

The underlying software/HW driving the camera would have a hissy fit, not knowing what on earth was going on.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:17 am

jamesh wrote:The underlying software/HW driving the camera would have a hissy fit, not knowing what on earth was going on.
OK.

Is there some key initialisation at boot? Presumably raspistill doesn't init the camera / IF from scratch, it assumes a known state that a mux would prevent. Is that it? Could a kernel mod potentially re-apply initialisation with switching?
Is the CSI interface never quiescent? Obviously switching the bus when active is a no-no.

Speculating, perhaps initialisation of the video core also initialises the camera at a low level and can't be repeated with the system up, because it's a monolithic operation that would break other things, like display. If it's not possible to init just the CSI / camera, and if init is adaptive to responses from specific camera modules, then it would be impossible init all cameras as one by routing the same commands to all, and impossible to init the current camera without a reboot.
Last edited by PiGraham on Wed Jul 17, 2013 9:26 am, edited 1 time in total.

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

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:23 am

There are two connections to the camera - i2c for controlling it and CSI-2 for data back. Neither of those channels are expected to be multiplexed, so all the code would need to change to be able to know which camera was doing what at any one time. I seriously doubt it could handle switching between multiplexed camera in any rational and useful way. Preview would be impossible at any sane fps for example.

Note that the ISP can actually control two cameras, but to do that it has two CSI-2 ports, but the second port is not available on the Raspi.

All this control is done by the ISP in the VC4, nothing in Linux space.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:32 am

jamesh wrote:I seriously doubt it could handle switching between multiplexed camera in any rational and useful way. Preview would be impossible at any sane fps for example.
I was certainly not suggesting multiplexing a frame rate. I'm not that crazy! ;)

I was only thinking that the init, acg, capture, shutdown sequence might be directed to one of N cameras. Preview frame rate would not be an issue, if it worked at all, since it would still be just one camera, one data stream.

Select a camera, run raspistill for some seconds to get an image and shutdown, then repeat for a different camera. While the one camera was running it would have the system to itself. Switching would be with camera off.
jamesh wrote:All this control is done by the ISP in the VC4, nothing in Linux space.
I can see that there may be some vital initialisation that is a once only thing (from boot) beyond linux control.
Last edited by PiGraham on Wed Jul 17, 2013 9:34 am, edited 1 time in total.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1423
Joined: Sat Sep 10, 2011 11:43 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:33 am

If you had an analogue multiplex between the N camera's then this would be possible.

On my desk I often hot plug the camera's for testing and just run raspivid. (I do not encourage this though, the CSI connector is not developed to work like this and if you had a discharge through the connector you can break it)

But the main issue is getting an analogue multiplex between multiple 1GBit CSI channels, maybe there is a device out there that would enable this... You'd also have to multiplex between the I2C because only one must respond at a time and they'll all have the same I2C device address.

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 9:42 am

gsh wrote:If you had an analogue multiplex between the N camera's then this would be possible.

On my desk I often hot plug the camera's for testing and just run raspivid. (I do not encourage this though, the CSI connector is not developed to work like this and if you had a discharge through the connector you can break it)

But the main issue is getting an analogue multiplex between multiple 1GBit CSI channels, maybe there is a device out there that would enable this... You'd also have to multiplex between the I2C because only one must respond at a time and they'll all have the same I2C device address.

Gordon
That's the basic idea, but witch electronically to swap our one camera and use another.
1Gb switching could be tricky!

Why analogue? CSI is all digital, isn't it?
What is the lane data rate? Is the 1Gb/s the lane data rate, or the channel data rate?

This from VLSI hints the switching should be feasible. It seems multiple simultaneous streams is possible, but obviously that would require access to closed code and data.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1423
Joined: Sat Sep 10, 2011 11:43 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 11:18 am

No CSI is not digital... it's a low voltage differential signal.

Lane frequency is as high as 1Gbit

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 12:00 pm

gsh wrote:No CSI is not digital... it's a low voltage differential signal.

Lane frequency is as high as 1Gbit

Gordon
I see what you mean. We would need a lvds PHY in and out.

There are chips for that. http://www.ti.com/product/sn65lvds125

HDMI switching chips like AD8190 might do the job.

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1423
Joined: Sat Sep 10, 2011 11:43 am

Re: Multiple cameras on a single raspberry pi board

Wed Jul 17, 2013 6:23 pm

Not sure that would work right either, the CSI spec includes dynamic impedance control which switches line termination in and out to reduce power consumption, not sure you'll find anything similar other than a specific CSI interface...

Gordon
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

paddi2013
Posts: 24
Joined: Wed Jul 17, 2013 4:30 am

Re: Multiple cameras on a single raspberry pi board

Thu Jul 18, 2013 3:06 am

i am looking to use around 6 to 12 cameras with the raspberry pi, do u guys know what is the best way to do it ? and also by minimizing the cost ? Please and thankyou

User avatar
RaTTuS
Posts: 10406
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Multiple cameras on a single raspberry pi board

Thu Jul 18, 2013 7:01 am

paddi2013 wrote:i am looking to use around 6 to 12 cameras with the raspberry pi, do u guys know what is the best way to do it ? and also by minimizing the cost ? Please and thankyou
best bet will be 1 RPcamera and 1 Modela A / seat
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

PiGraham
Posts: 3571
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Multiple cameras on a single raspberry pi board

Thu Jul 18, 2013 8:22 am

paddi2013 wrote:i am looking to use around 6 to 12 cameras with the raspberry pi, do u guys know what is the best way to do it ? and also by minimizing the cost ? Please and thankyou
Option 1:
Model A + PiCam + WiFi dongle = N x (£20 + £16 + £10)
WiFi router / AP = £25

12 cameras = £577

Option 2:
Model B + N x USB camera = £30 + N x £16
12 port powered USB hub = £35

12 cameras = £257

Option 3:
Model B + WIFi £30 +£10
Wireless IP cameras N x £35

12 cameras = £460

You may have issues with power supply to 12 USB cameras, but since you only need one of 12 active at any time, and a powered hub *should* be able to supply all ports, you may be OK. Perhaps budget for a good quality brand hub, rather than the cheap generic price I put in there.

I suggest Model B for the USB system for the extra RAM.

I can't give you any assurances that it will work. Start with the hardware compatibility list for webcams.
It certainly won't work if you attempt to activate more than one camera at once.

I don't think you answered the question about how far apart these cameras are going to be. Option 1 gives you much longer distances than option B.

Not all cameras are equal. You will get much better images from a PiCam than a cheap WiFi IP cam (worst) or a webcam.(medium)

There will be other issues to consider, such as ease of installation.

I suspect this is some sort of CCTV system. WiFi will be easier to install. IP cams will be simplest and neatest. You will need some sort of custom case for Pi/PiCam. USB cams will probably not reach to where you want them due to short cable runs.
PiCam WIFi will give you range and top quality images in good light.
If you want good night imaging you should really go for a CCTV camera with switchable IR block filter and a high sensitivity CCD sensor, but then you are getting much more expensive.

Return to “Camera board”