pcduino上使用QT+opencv实现拍照功能
本帖最后由 Lily 于 2014-2-24 12:44 编辑试验器材:pcDuino一套、USB摄像头一个http://linksprite.com/wiki/index.php5?title=Products-description#pcDuino
1.如何搭建QT+opencv环境http://cnlearn.linksprite.com/
2、将摄像头的USB接口插入USB HUB里,输入代码:#include <QtCore/QCoreApplication>#include <cv.h>#include <highgui.h>#include <stdio.h>#include <qdebug.h> IplImage* DoPyrDown (IplImage* img, intfilter = IPL_GAUSSIAN_5x5){ CvSize size = cvSize (img->width / 2, img->height / 2); IplImage* outImage = cvCreateImage (size, img->depth,img->nChannels); cvPyrDown (img, outImage); cvReleaseImage (&img); returnoutImage;} int main(int argc, char *argv[]){ cvNamedWindow ("vedio"); qDebug() << "vedio window!" << endl; CvCapture* capture; qDebug() << "find Camera!" << endl; if (1 == argc){ capture = cvCreateCameraCapture(0); } else { capture = cvCreateCameraCapture (atoi(argv)); } assert (NULL != capture); IplImage* frame; char keyCode; qDebug() << "wait keyevent!" << endl; while ((keyCode = cvWaitKey(30))){ if (keyCode == 65){ qDebug() << "keyCode == 65" << endl; break; } if (keyCode == 27){ qDebug() << "take photo" << endl; IplImage* outImage = cvCreateImage(cvGetSize(frame), frame->depth,frame->nChannels); cvCopy(frame, outImage, NULL); outImage = DoPyrDown(outImage); char* outImageName = "test.jpg"; cvSaveImage(outImageName, outImage); cvReleaseImage(&outImage); qDebug() << "save photo successful" << endl; } frame = cvQueryFrame (capture); if (!frame){ break; } cvShowImage("vedio",frame); } qDebug() << "begin to release!" << endl; cvReleaseImage(&frame); cvDestroyAllWindows(); return 0;}
3、代码运行后,可按ESC键进行拍照,照片会保存到指定路径
本帖最后由 cxpcxpcxp 于 2014-2-28 15:54 编辑
pcDuino ? 帧率多少??
页:
[1]