PDA

View Full Version : [Question(s)] Raspberry Pi2 and USB Webcam



dmcman73
03-22-2015, 08:23 AM
After making some modifications to the Darwin 1.6 code so that I could compile it on the Intel NUC system I have with Ubuntu Server 14.4 32 bit, I was able to compile everything and test the camera_vision. Everything worked flawlessly on that portion of it, crystal clear image and it was able to highlight all red objects for the tracking.

Yesterday I just received a Raspberry Pi 2 and loaded it with Raspbian Wheezy. I installed all of the dependencies as I did with the NUC, plugged in the same exact USB camera into the raspberry Pi, built all of the modules with no issues and ran the same tests. When I looked at the video image from the raspberry pi as I did with the NUC, the image was dark and in fact, the system was outlining every object red.

Both tests were in the same room, using the same camera with the same lighting. Has anyone else run into this issue? Could it be the Raspberry Pi 2 is underpowered? I read that some USB webcams had poor video quality when plugged into the Raspberry Pi and needed a powered USB hub so, I plugged one in, powered it up and plugged the webcam into the hub to get power from it. Same quality.

I guess the next step would be to test the "native" webcam that they make for the Pi and plug it directly into the ribbon cable connector built into the board.

jwatte
03-22-2015, 01:33 PM
Check the output voltage with a voltmeter.

Also, maybe the USB webcam drivers are different, and treat white balance, shutter speed, and other things differently?

I power my RPi and RPi 2 with a 5V input on the GPIO pins, and when I have a weak power supply, that does cause issues. A 2A supply is not just a suggestion, I'd say it's a requirement.

dmcman73
03-23-2015, 05:29 AM
Here's the latest: Not only was the color all off and everything being highlighted red but the image was upside-down. Rather than fool around with the Raspbian OS I switched over to using Ubuntu on the Pi2. I ran the Camera tutorial and the image was crystal clear and right side up. Awesome! I did the color test tutorial and... The image went right back to be dark and everything being highlighted red. I stopped the tutorial and went back to the camera one and the image went from being clear to back to being dark and all objects being highlighted red. I don't have these issues using the same camera and code base on my NUC. Hopefully when my Odroid-XU3 comes in I won't have the same issues.

There is one more thing I just thought of to try. I do have a wireless keyboard dangle plugged into the Pi and remember reading somewhere some people having some weird issues with the USB on the Pi with one plugged in. I'll try taking that out tonight when I get home.

jwatte
03-23-2015, 11:44 AM
That sounds like a data format issue, more than anything else.
Are you enumerating and printing the video formats available?
Which format are you actually getting?
Do you try to force a particular format?

tician
03-23-2015, 04:49 PM
It sounds more like the auto-calibration is getting messed up and/or the example programs are loading bad values from the config.ini in each project folder (usually just contain the 'reset' value to trigger auto-calibration). If it is already available for your OS, then try testing the camera with guvcview. It should let you change all relevant image parameters to verify that it is not the camera, driver conflicts, and/or power issues.

If you are getting errors with the camera code, you may need to add fix in '/Linux/build/LinuxCamera.cpp' where it somehow gets its buffer size messed up at line ~386. It happened after an upgrade, but cannot remember what it was that caused it or if it was only my systems.


for(int i = 0; i < fbuffer->m_YUVFrame->m_ImageSize; i++)
{
if (i >= buffers[buf.index].length) // WTF!? Why break now?
break;

fbuffer->m_YUVFrame->m_ImageData[i] = ((unsigned char*)buffers[buf.index].start)[i];
}

dmcman73
03-24-2015, 08:49 AM
Thanks for the info tican.

After doing a lot of research, it seems like I'm not the only one having issues with a USB camera attached to the Raspberry Pi. Other users have posted issues similar to mine with either weird artifacts, very poor video quality, etc. I tried using a powered USB as many have suggested (so that it's not drawing power from the Pi's USB ports) but that didn't work either.

I know it's not the camera because it works great with the Intel NUC system I have.

I may just leave the Pi alone and wait from my Odroid to come in and test with that as I am leaning more towards using the Odroid. I would use the NUC but, I don't think it would be wise if I am using the AX-12A servos since the NUC is a bit heavier and will need a bit more power.

LloydF
03-28-2015, 10:50 AM
Yes, I have found the same issues, oddly enough if you compile the opencv and run facedetect or smiledetect, every thing runs correctly on the webcam.

jwatte
03-28-2015, 11:50 AM
if you compile the opencv and run facedetect or smiledetect, every thing runs correctly

What does that tell you about possible solutions, and about possible sources of the problem?

LloydF
05-29-2015, 09:57 AM
Seems there is a bug in the code for web cams. Looks like they will fix it in next release. I see a fix out there just not tried it out myself yet.
Digging around various forums I found the following links to information which may be of help:

https://bugzilla.kernel.org/show_bug.cgi?id=81611
https://bugs.launchpad.net/ubuntu/+sour ... ug/1362358 (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1362358)
http://www.mail-archive.com/linux-media ... 80158.html (http://www.mail-archive.com/[email protected]/msg80158.html)