Visual Servoing Platform  version 3.0.0
vpDirectShowGrabber.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * DirectShow framegrabber.
32  *
33  * Authors:
34  * Bruno Renier
35  * Anthony Saunier
36  *
37  *****************************************************************************/
38 
39 
40 #include <visp3/core/vpConfig.h>
41 #if ( defined(VISP_HAVE_DIRECTSHOW) )
42 
43 #include <visp3/sensor/vpDirectShowGrabber.h>
44 #include <visp3/sensor/vpDirectShowGrabberImpl.h>
45 
49 unsigned int vpDirectShowGrabber::getHeight(){ return grabber->getHeight(); }
50 
54 unsigned int vpDirectShowGrabber::getWidth(){ return grabber->getWidth(); }
55 
56 
62 {
63  grabber = new vpDirectShowGrabberImpl();
64 }
65 
70 {
71  delete grabber;
72 }
78 {
79  grabber->open();
80 }
81 
87 {
88  grabber->open();
89 }
90 
96 {
97  grabber->open();
98 }
99 
100 
110 {
111  grabber->acquire(I);
112 }
113 
123 {
124  grabber->acquire(I);
125 }
126 
127 
131 void vpDirectShowGrabber::close() { grabber->close(); }
132 
138 {
139  return grabber->getDeviceNumber();
140 }
141 
148 bool vpDirectShowGrabber::setDevice(unsigned int id)
149 {
150  return grabber->setDevice(id);
151 }
152 
157 {
158  grabber->displayDevices();
159 }
167 bool vpDirectShowGrabber::setImageSize(unsigned int width,unsigned int height)
168 {
169  return grabber->setImageSize(width, height);
170 }
177 bool vpDirectShowGrabber::setFramerate(double framerate)
178 {
179  return grabber->setFramerate(framerate);
180 }
189 bool vpDirectShowGrabber::setFormat(unsigned int width,unsigned int height,double framerate)
190 {
191  return grabber->setFormat(width, height, framerate);
192 }
193 /*
194  Get capture format
195  \param width : Pointer to a variable that receives the width in pixel
196  \param height : Pointer to a variable that receives the height in pixel
197  \param framerate : Pointer to a variable that receives the framerate in fps
198 */
199 void vpDirectShowGrabber::getFormat(unsigned int &width,unsigned int &height, double &framerate)
200 {
201  grabber->getFormat(width, height, framerate);
202 }
203 
210 {
211  return grabber->getStreamCapabilities();
212 }
213 
221 {
222  return grabber->setMediaType(mediaTypeID);
223 }
224 
225 /*
226  Get current capture MediaType
227 
228  \return the current mediaTypeID
229 */
231 {
232  return grabber->getMediaType();
233 }
234 
235 #elif !defined(VISP_BUILD_SHARED_LIBS)
236 // Work arround to avoid warning: libvisp_sensor.a(vpDirectShowGrabber.cpp.o) has no symbols
237 void dummy_vpDirectShowGrabber() {};
238 #endif
void getFormat(unsigned int &width, unsigned int &height, double &framerate)
bool setMediaType(int mediaTypeID)
bool setFramerate(double framerate)
bool setDevice(unsigned int id)
bool setFormat(unsigned int width, unsigned int height, double framerate)
void acquire(vpImage< unsigned char > &I)
bool setImageSize(unsigned int width, unsigned int height)
unsigned int getDeviceNumber()