Can the source code be modified to allow two cameras on one CBC?

2 replies [Last post]
DavidMutchler
Title: NooBot+
Joined: 06/17/2009
Posts:
BotPoints: 24
User offline. Last seen 5 years 35 weeks ago.

In this year's Botball contest it may be helpful to have both cameras mounted on one CBC, using the two USB ports. I tried plugging two cameras into one CBC and (not surprisingly) the CBC user interface recognized only one of them.

Where does the limitation to one camera come from? Is it somewhere in the camera code that is part of the source code? Or is the limitation because of hardware issues?

I looked around in the source code under cbcui/src/vision and found interesting things including this line:
m_camDevice = open("/dev/video0", O_RDWR);

but I don't know enough about devices to know whether the 2nd camera is happily working and the vision code is simply not opening the relevant device, or whether the camera libraries prohibit both working at once, or ...

Performance is not an issue for us here - slow tracking is ok.

Thanks in advance!

... David Mutchler, mentor for some Terre Haute, Indiana teams

AdamF
Title: MiniBot+
Joined: 03/17/2010
Posts:
BotPoints: 62
User offline. Last seen 9 years 19 weeks ago.

I think Jeremy will be of more help in this area, but I'll try to help you out.

The driver that the CBC firmware uses is a generic and frankly crappy all-purpose webcam driver. It was not written by KIPR, but has been hacked together to work with the CBC. I believe the camera is basically mounted to a directory and when the tracking code wants to update the image it cats the image data in that directory to a temporary location and then analyzes it.

If you managed to rewrite the driver, then you would have to deal with the tracking code in the firmware. I'm not sure how you would fix it to work with 2 cams... maybe add arguments to all the functions that return blob data to you that would choose which cam to use for that call? The real problem is that again the low-level functions that analyze the images are probably really specific to the driver being used.

It may be possible but I would be surprised if you could get it working in time for your regional. It may be worth trying to shift paradigms and doing what you think you need two cameras for with one. Perhaps you can actuate the camera to point in multiple directions? Or creatively position it to view both things you need to view in the same frame? Just tossing some ideas out there. Our team had lots of trouble getting the cam to work like we wanted last year and found ourselves saying "well it would be great if we could set a color channel to black" or "I wish the blobs were more consistently sized" I'm working on a paper for GCER that will discuss the limits of the vision system and how to use it in different ways that get around those issues and get the most out of the camera.

Adam Farabaugh
Hampton High School

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 18 weeks ago.

Hey David, sorry for the delayed reply.

I actually have multiple cameras working fine (we used it in regionals). I was going to add the feature to the NHS Patchset, but got busy with school and didn't have a chance to release it. I'll see if I can find some time to release a new version of the NHS Patchset with multiple camera support (and the 2011 KIPR features while I'm at it).

(Sorry about the slow release cycle of the NHS Patchset this year; I've been really busy.)

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS