ubuntu 下安装摄像头驱动


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")  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM