* depending on what webcam do you have, you need to install the corresponding drivers (UVC, gspca, sq930x, etc.)
* first, I install UVC driver but the /dev/video0 is missing; later I realized that it is because UVC does not support my webcam.
* now I can use guvcview to open the video; or open the video stream by OpenCV
#!/usr/bin/env python # 29.April.2011 # test the webcam in Ubuntu import cv cap = cv.CaptureFromCAM(0) win_name = 'video' cv.NamedWindow(win_name) while True: frame = cv.QueryFrame(cap) cv.ShowImage(win_name, frame) c = '%c' % (cv.WaitKey(10) & 255) if c in ['q', 'Q', 'x1b']: break cv.DestroyWindow(win_name)
Example of an image