在pcduino的ubuntu系统上使用 摄像头

主要参考这篇文章http://www.cnblogs.com/liu-jun/p/3489675.html


在完成opencv编译,安装之后。使用摄像头。


g++编译的代码main.cpp如下:

#include <cv.h>
#include <opencv/highgui.h>
#include<stdio.h>
#include<opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char *argv[])
{
      CvCapture* pCapture = cvCreateCameraCapture(0);
      cvNamedWindow("Video", 1);

      while(1)
      {
          IplImage* pFrame=cvQueryFrame( pCapture );
          if(!pFrame)break;
          cvShowImage("Video",pFrame);
          char c=cvWaitKey(33);
          if(c==27)break;
      }
      cvReleaseCapture(&pCapture);
      cvDestroyWindow("Video");
      return 0;
}

g++ `pkg-config opencv --cflags` main.cpp  -o main `pkg-config opencv --libs` 


读取摄像头结果如下图:

在pcduino的ubuntu系统上使用 摄像头_第1张图片

More Information

  • If you encounter problems installing OpenCV, see the companion guide, “A Comprehensive OpenCV Installation Troubleshooting Guide.”
  • Utkarsh Sinha runs AiShack, a site that has easy-to-understand tutorials using OpenCV to solve real-world problems: http://www.aishack.in/topics/tutorials/
  • Sebastian Montabone has several articles on installing OpenCV and image processing. His web site is http://www.samontab.com/
  • FakeOutdoorsman’s posted an excellent dependency install guide, which is located on the Ubuntu forums: http://ubuntuforums.org/showthread.php?t=786095

你可能感兴趣的:(在pcduino的ubuntu系统上使用 摄像头)