ev3dev / ev3dev

ev3dev meta - bug tracking, wiki and releases
http://www.ev3dev.org
GNU General Public License v2.0
634 stars 85 forks source link

USB camera for EV3 #175

Closed sharived closed 9 years ago

sharived commented 9 years ago

Hi, I'm developing a USB camera to be used in a lego robotics environment. I am currently running with a RaspberryPi and a BrickPi from Dexter Industries. I'd like to get this working on an EV3 as well. It seems like it should be pretty straight forward to use ev3dev (please let me know if there are any issues I should be aware of with USB - didn't see any references in the wiki), but would also like to use ev3 out of the box. Do you know if anyone has successfully hooked up a USB device (such as a camera) to the ev3? I'm new to EV3 and appreciate any pointers that can be provided.

Thanks, Shari

ldmberman commented 9 years ago

You can find some information here #64.

JorgePe commented 9 years ago

I had success with a Logitech C170. You can see at link above that Logitech C270 also works. Both are UVC (USB Video Class) devices so I believe most-if-not-all UVC devices will work, see Linux UVC driver and tools.

There are other classes of video devices supported by V4L2, some of them already included in ev3dev kernel. I had success with a LEGOCam from old Mindstorms Vision Command set after requesting ev3dev developers to add the STV06xx driver. Those work as video devices with V4L2. They deliver a video stream, if you just need a photo you grab a frame from the stream. But there are pure photo devices, I had suceeded with my old Canon IXUS 500 using just gphoto2 to control it.

Generally speaking, if it is USB and it works out-of-the-box with Raspberry Pi Raspbian it will work with EV3 ev3dev. But don't forget that EV3 USB is just 1.1, not 2.0 (bandwidth is 11 Mbps, shared with other devices you might use like Wi-Fi). Some drivers will work only with smaller resolutions and slower fps.

dlech commented 9 years ago

I believe most-if-not-all UVC devices will work

I can say for certain that it is not all. I have an HP webcam that came out of a broken laptop screen that does not work. And it is because of...

But don't forget that EV3 USB is just 1.1, not 2.0

Everything looks like it should be working, but when trying to actually get video or even a single frame, I either get errors or corrupt image files. Even at is slowest/lowest resolution settings, this camera still overwhelms the USB connection.

If you are going to buy a camera, it would be best to get one of the known working ones.

bmegli commented 9 years ago

The USB is 1.1 but the second USB port is 2.0.

This second port is OTG 2.0 USB which in principle could work both as guest or host depending how you connect.

Maybe I am wrong here. Maybe this would need some changes in kernel.

@dlech - can second OTG USB 2.0 port be used as both host/guest?

dlech commented 9 years ago

See this discussion on the OTG port. Bottom line is you would have to modify the hardware (replace miniB port with microA/B and possibly add some resistors) in addition to changing the software to make it work.

JorgePe commented 9 years ago

Everything looks like it should be working, but when trying to actually get video or even a single frame, I either get errors or corrupt image files. Even at is slowest/lowest resolution settings, this camera still overwhelms the USB connection

I don't know if it is related but I also had errors and green frames with Logitech C170 when using fswebcam. I found out that many web folks using Logitech (more than one model) with fswebcam skip first 5 or so frames before grabbing one [I had to do that even on my Dell Laptop running Ubuntu]. It seems to be necessary some kind of warmup because when taking several shots I found that I could skip less frames or even don't skip at all.

Also found out that could not grab Logitech C170 with the same pallete/format I was using in my Ubuntu laptop: I was using fswebcam with YUYV and getting 640x480. With same fswebcam command in ev3dev my photo size was just 176x144. Fortunately the driver gives a second format, MJPEG, less bandwidth intense, and using it I got 640x480 again.

dlech commented 9 years ago

Yes, I tried all of these things and still it does not work. I have an older webcam that has terrible picture quality that works though.

sharived commented 9 years ago

Thanks for all the info. I was able to get my camera to work! Luckily I'm using small resolutions, so it was fine with USB1.1

JorgePe commented 9 years ago

Great! Could you tell us what camera it is? It might help others.

sharived commented 9 years ago

I was using the Pixy cam. http://www.cmucam.org/projects/cmucam5/

JorgePe commented 9 years ago

Thanks. I remember kickstarter campaign... never thought it will be used with LEGO.

Odame commented 6 years ago

@sharived Can you give me some heads up/tips on how to use the pixy camera with ev3dev over usb?