MRPT  2.0.3
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
MRPT_ENUM_TYPE_END
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:78
mrpt::hwdrivers::CImageGrabber_OpenCV::m_bInitialized
bool m_bInitialized
Set to false if we could not initialize the camera.
Definition: CImageGrabber_OpenCV.h:70
mrpt::hwdrivers::CAMERA_CV_VFL
@ CAMERA_CV_VFL
Definition: CImageGrabber_OpenCV.h:25
mrpt::hwdrivers::CAMERA_CV_MIL
@ CAMERA_CV_MIL
Definition: CImageGrabber_OpenCV.h:27
mrpt::hwdrivers
Contains classes for various device interfaces.
Definition: C2DRangeFinderAbstract.h:19
mrpt::pimpl
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
mrpt::hwdrivers::TCameraType
TCameraType
These capture types are like their OpenCV equivalents.
Definition: CImageGrabber_OpenCV.h:21
MRPT_FILL_ENUM_MEMBER
MRPT_FILL_ENUM_MEMBER(mrpt::hwdrivers, CAMERA_CV_AUTODETECT)
mrpt::hwdrivers::CAMERA_CV_DC1394
@ CAMERA_CV_DC1394
Definition: CImageGrabber_OpenCV.h:24
MRPT_ENUM_TYPE_BEGIN
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:62
mrpt::hwdrivers::TCaptureCVOptions::TCaptureCVOptions
TCaptureCVOptions()=default
mrpt::hwdrivers::TCaptureCVOptions::frame_height
int frame_height
Definition: CImageGrabber_OpenCV.h:41
mrpt::hwdrivers::CImageGrabber_OpenCV::CImageGrabber_OpenCV
CImageGrabber_OpenCV(int cameraIndex=-1, TCameraType cameraType=CAMERA_CV_AUTODETECT, const TCaptureCVOptions &options=TCaptureCVOptions())
Constructor for cameras:
Definition: CImageGrabber_OpenCV.cpp:35
mrpt::hwdrivers::TCaptureCVOptions::ieee1394_fps
double ieee1394_fps
(IEEE1394 cameras) Frame rate for the capture (0: Leave the default).
Definition: CImageGrabber_OpenCV.h:45
TEnumType.h
mrpt::hwdrivers::CAMERA_CV_DSHOW
@ CAMERA_CV_DSHOW
Definition: CImageGrabber_OpenCV.h:28
mrpt::hwdrivers::TCaptureCVOptions::gain
double gain
(All cameras) Camera gain (0: Leave the default)
Definition: CImageGrabber_OpenCV.h:43
mrpt::hwdrivers::CAMERA_CV_AUTODETECT
@ CAMERA_CV_AUTODETECT
Definition: CImageGrabber_OpenCV.h:23
mrpt::hwdrivers::CImageGrabber_OpenCV::m_capture
mrpt::pimpl< Impl > m_capture
Definition: CImageGrabber_OpenCV.h:72
mrpt::hwdrivers::TCaptureCVOptions::ieee1394_grayscale
bool ieee1394_grayscale
(IEEE1394 cameras) Whether to grab grayscale images (Default=false).
Definition: CImageGrabber_OpenCV.h:47
mrpt::hwdrivers::CImageGrabber_OpenCV
A class for grabing images from a "OpenCV"-compatible camera, or from an AVI video file.
Definition: CImageGrabber_OpenCV.h:65
safe_pointers.h
mrpt::hwdrivers::CImageGrabber_OpenCV::~CImageGrabber_OpenCV
virtual ~CImageGrabber_OpenCV()
Destructor.
Definition: CImageGrabber_OpenCV.cpp:197
mrpt::hwdrivers::CImageGrabber_OpenCV::isOpen
bool isOpen() const
Check whether the camera has been open successfully.
Definition: CImageGrabber_OpenCV.h:98
mrpt::hwdrivers::TCaptureCVOptions
Options used when creating an OpenCV capture object Some options apply to IEEE1394 cameras only.
Definition: CImageGrabber_OpenCV.h:36
mrpt::hwdrivers::TCaptureCVOptions::frame_width
int frame_width
(All cameras) Capture resolution (0: Leave the default)
Definition: CImageGrabber_OpenCV.h:41
pimpl.h
mrpt::hwdrivers::CImageGrabber_OpenCV::Impl
Definition: CImageGrabber_OpenCV.cpp:25
CObservationImage.h
mrpt::hwdrivers::CAMERA_CV_VFW
@ CAMERA_CV_VFW
Definition: CImageGrabber_OpenCV.h:26
mrpt::obs::CObservationImage
Declares a class derived from "CObservation" that encapsules an image from a camera,...
Definition: CObservationImage.h:32
mrpt::hwdrivers::CImageGrabber_OpenCV::getObservation
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab an image from the opened camera.
Definition: CImageGrabber_OpenCV.cpp:210



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Thu May 21 21:53:32 UTC 2020