Let's Make Robots! | RobotShop

Q[Resolved]:Raspberry PI,Opencv can not open camera

opencv2.4.6 BUG V4L doesn't work,just use version

when i run the samples:
 //capture = cvCreateCameraCapture(CV_CAP_ANY);//cvCaptureFromCAM(0);//-1//CV_CAP_ANY
 none of them work.
 ERROR: capture is NULL.

thus,i was in trouble.i've bought a new camera(Bus 002 Device 004: ID 0ac8:301b Z-Star Microelectronics Corp. ZC0301 Webcam),which was even worse,not support v4l.maybe i should buy one more on the support list.

I have install main of the library,and run cmake many times to check.
make install with this link http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/

now i was test int ubuntu 12.04 ,and opencv-2.4.6

the next thing, i want to coss compiling the opencv.because compiling is slow in raspberry pi.(some library have compile,and got trouble).

 I wonder who have meet that problem,or can help me to slove it, thanks,T_T...

HERE is my record(Terminal in ubuntu):

$ ls -l /dev/v4l/by-id
total 0
lrwxrwxrwx 1 root root 12 Aug  2 11:17 usb-Alcor_Micro__Corp._USB_2.0_PC_Camera-video-index0 -> ../../video0

$ lsmod | grep video
uvcvideo                     72249  0
videobuf2_core           32212  1 uvcvideo
videobuf2_vmalloc      12757  1 uvcvideo
videobuf2_memops    13213  1 videobuf2_vmalloc
videodev                     100265  4 uvcvideo,videobuf2_core,gspca_zc3xx,gspca_main

$ lsusb
Bus 001 Device 009: ID 058f:3881 Alcor Micro Corp.
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

$ lsusb -d 058f:3881 -v |grep "14 Video"
Couldn't open device, some information will be missing
      bFunctionClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
$ xawtv -hwscan
This is xawtv-3.102, running on Linux/i686 (3.5.0-23-generic)
looking for available devices
port 98-113
    type : Xvideo, image scaler
    name : XA G3D Textured Video

port 114-114
    type : Xvideo, image scaler
    name : VMware Overlay Video Engine

/dev/video0: OK                         [ -device /dev/video0 ]
    type : libv4l
    name : USB 2.0 PC Camera
    flags:  capture

$ xawtv
This is xawtv-3.102, running on Linux/i686 (3.5.0-23-generic)
xinerama 0: 1440x900+0+0
vid-open-auto: using grabber/webcam device /dev/video0
Alsa devices: cap: (null) (/dev/video0), out: default

$ mplayer tv:// -tv fps=25
MPlayer svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: USB 2.0 PC Camera
 Capabilities:  video capture  streaming
 supported norms:
 inputs: 0 = Camera 1;
 Current input: 0
 Current format: YUYV
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 640x480 => 640x480 Packed YUY2
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
Audio: no sound
Starting playback...

$ luvcview
luvcview 0.2.6

SDL information:
  Video driver: x11
  A window manager is available
Device information:
  Device path:  /dev/video0
Stream settings:
  Frame format: YUYV (MJPG is not supported by device)
  Frame size:   640x480
  Frame rate:   30 fps


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Well there are several issues regarding the webcams, the raspi usb bus. I have a couple of very cheap webcams and a somewhat more expensive one. All of them work fine (at least up to 640x480 in resolution) on ubuntu. However, on the raspi (using raspbian derivatives at least) the cheaper webcams can only handle lower resolutions no matter the program I use, whereas the somewhat more expensive can deal with higher resolution (also supports mjpeg) but still for some reasons not all applications there handle it so well.


My advice would be to use the supported cam list as a guide and before acquiring any of them search the internet for reports of people using the webcam on the raspi for purposes similar to the one you intend. 

Thank you for you advice,i will buy somemore webcamera for test..>_<