MRPT  2.0.0
CImageGrabber_OpenCV.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/config.h>
12 
13 #include <mrpt/core/pimpl.h>
17 
18 namespace mrpt::hwdrivers
19 {
20 /** These capture types are like their OpenCV equivalents. */
22 {
29 };
30 
31 /** Options used when creating an OpenCV capture object
32  * Some options apply to IEEE1394 cameras only.
33  * \sa CImageGrabber_OpenCV
34  * \ingroup mrpt_hwdrivers_grp
35  */
37 {
38  TCaptureCVOptions() = default;
39 
40  /** (All cameras) Capture resolution (0: Leave the default) */
42  /** (All cameras) Camera gain (0: Leave the default) */
43  double gain{0};
44  /** (IEEE1394 cameras) Frame rate for the capture (0: Leave the default). */
45  double ieee1394_fps{0};
46  /** (IEEE1394 cameras) Whether to grab grayscale images (Default=false). */
47  bool ieee1394_grayscale{false};
48 };
49 
50 /** A class for grabing images from a "OpenCV"-compatible camera, or from an AVI
51  * video file.
52  * See the constructor for the options when opening the camera.
53  *
54  * Unless input from AVI files is required, it is recommended to use the more
55  * generic class
56  * mrpt::hwdrivers::CCameraSensor.
57  *
58  * \note This class is only available when compiling MRPT with the flag
59  * "MRPT_HAS_OPENCV" defined.
60  * \note Some code is based on the class CaptureCamera from the Orocos project.
61  * \sa mrpt::hwdrivers::CCameraSensor, CImageGrabber_dc1394
62  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
63  * \ingroup mrpt_hwdrivers_grp
64  */
66 {
67  protected:
68  /** Set to false if we could not initialize the camera.
69  */
71 
72  struct Impl;
74 
75  public:
76  /** Constructor for cameras:
77  * \param cameraIndex Set the camera index, or -1 if it does not matter and
78  * you select AUTODETECT as cameraType.
79  * \param cameraType Can be any value of TCameraType, or
80  * CAMERA_CV_AUTODETECT if there is only one camera.
81  * \param options Capture options, defined in
82  * mrpt::hwdrivers::TCaptureCVOptions. If not provided, all the default
83  * options will be used.
84  */
86  int cameraIndex = -1, TCameraType cameraType = CAMERA_CV_AUTODETECT,
87  const TCaptureCVOptions& options = TCaptureCVOptions());
88 
89  /** Constructor for AVI files:
90  */
91  CImageGrabber_OpenCV(const std::string& AVI_fileName);
92 
93  /** Destructor
94  */
95  virtual ~CImageGrabber_OpenCV();
96 
97  /** Check whether the camera has been open successfully. */
98  bool isOpen() const { return m_bInitialized; }
99  /** Grab an image from the opened camera.
100  * \param out_observation The object to be filled with sensed data.
101  *
102  * \return false on any error, true if all go fine.
103  */
104  bool getObservation(mrpt::obs::CObservationImage& out_observation);
105 
106 }; // End of class
107 
108 } // namespace mrpt::hwdrivers
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
TCameraType
These capture types are like their OpenCV equivalents.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
Contains classes for various device interfaces.
CImageGrabber_OpenCV(int cameraIndex=-1, TCameraType cameraType=CAMERA_CV_AUTODETECT, const TCaptureCVOptions &options=TCaptureCVOptions())
Constructor for cameras:
bool ieee1394_grayscale
(IEEE1394 cameras) Whether to grab grayscale images (Default=false).
int frame_width
(All cameras) Capture resolution (0: Leave the default)
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:78
double ieee1394_fps
(IEEE1394 cameras) Frame rate for the capture (0: Leave the default).
MRPT_FILL_ENUM_MEMBER(mrpt::hwdrivers, CAMERA_CV_AUTODETECT)
A class for grabing images from a "OpenCV"-compatible camera, or from an AVI video file...
double gain
(All cameras) Camera gain (0: Leave the default)
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab an image from the opened camera.
Options used when creating an OpenCV capture object Some options apply to IEEE1394 cameras only...
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:62
bool isOpen() const
Check whether the camera has been open successfully.
bool m_bInitialized
Set to false if we could not initialize the camera.



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020