sudo apt-get install cheese
sudo apt-get install camorama
然后可以打开应用cheese,观察可以得到图像。
也可以通过代码获取图像。python代码如下:
1 import cv2.cv as cv 2 3 import time 4 5 if __name__ == '__main__': 6 7 cv.NamedWindow("camera",1) 8 capture = cv.CaptureFromCAM(0) 9 num = 0; 10 while True: 11 img = cv.QueryFrame(capture) 12 cv.ShowImage("camera",img) 13 14 key = cv.WaitKey(10) 15 if key == 27: 16 break 17 if key == ord(' '): 18 num = num+1 19 filename = "frmaes_%s.jpg" % num 20 cv.SaveImage(filename,img) 21 22 23 del(capture) 24 cv.DestroyWindow("camera")