最近用QT做界面,想做一个调用摄像头做颜色识别的窗口,百度搜索了一下才知道在QT内用opencv是可以调用摄像头来获取图像,只怪本人刚入门这行,小白一枚。(该段原理属于百度得到)opencv提供的highgui库调用Linux本身的v4l2机制就能控制摄像头,在qt中开一个30ms的定时器,不断通过摄像头捕捉图像,这30ms就是帧速,捕捉的图像在opencv中是lplimage类型,在qt中调用图像一般是Qimage类型,所以需要进行格式转换,摄像头捕捉的图像显示窗口为QWidget部件。
环境:Ubuntu12.04.2 + opencv2.3+Qt4.8.0
安装opencv步骤:
1)终端下运行sudo apt-cache search opencv,显示如下:
harpia - Image Processing/Computer Vision Automatic Prgm. Tool
libcv-dev - development files for libcv
libcv2.3 - computer vision library
libcvaux-dev - development files for libcvaux
libcvaux2.3 - computer vision extension library
libhighgui-dev - development files for libhighgui
libhighgui2.3 - computer vision GUI library
opencv-doc - OpenCV documentation and examples
python-open