Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Capture.hpp
00001 /* $Id: $ */
00002 
00003 #ifndef JAFAR_IMAGE_CAPTURE_HPP
00004 #define JAFAR_IMAGE_CAPTURE_HPP
00005 
00006 #include <opencv2/highgui/highgui.hpp> // opencv
00007 
00008 #include "image/Image.hpp"
00009 
00010 namespace jafar { 
00011   namespace image {
00012 
00017     class Capture {
00018       
00019     public:
00020     
00021       Capture(int index = CV_CAP_ANY) : m_cvCapture(0), m_image(0) {
00022   setCamera(index);
00023       }
00024 
00025       ~Capture() {
00026   if (m_cvCapture) cvReleaseCapture(&(m_cvCapture));
00027       }
00028 
00033       void setCamera(int index = CV_CAP_ANY) {
00034   release();
00035   m_cvCapture = cvCreateCameraCapture(CV_CAP_ANY);
00036   if (m_cvCapture)
00037     m_image = new Image(cvQueryFrame(m_cvCapture));
00038   else
00039     JFR_WARNING("Error during initialisation: check the camera and device index.");
00040       }
00041 
00043       jafar::image::Image* image() {return m_image;}
00044 
00046       void grabFrame() {
00047   cvQueryFrame(m_cvCapture);
00048       }
00049 
00051       void release() {
00052   if (m_cvCapture) {
00053     cvReleaseCapture(&(m_cvCapture));
00054     m_cvCapture = 0;
00055   }      
00056       }
00057 
00058     private:
00059 
00060       CvCapture* m_cvCapture;
00061       jafar::image::Image* m_image;
00062 
00063     };
00064 
00065   }
00066 }
00067 
00068 #endif // JAFAR_IMAGE_CAPTURE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:21 for Jafar by doxygen 1.7.6.1
LAAS-CNRS