appkit  1.5.1
RoadNarrows Robotics Application Kit
CameraEcon32.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_cam
8 //
9 // File: CameraEcon32.h
10 //
11 /*! \file
12  *
13  * $LastChangedDate: 2013-07-15 11:45:50 -0600 (Mon, 15 Jul 2013) $
14  * $Rev: 3131 $
15  *
16  * \brief Econ 3.2 megapixel video and still image camera class.
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  * \author Daniel Packard (daniel@roadnarrows.com)
20  *
21  * \par Copyright
22  * \h_copy 2012-2017. RoadNarrows LLC.\n
23  * http://www.roadnarrows.com\n
24  * All Rights Reserved
25  */
26 /*
27  * @EulaBegin@
28  *
29  * Permission is hereby granted, without written agreement and without
30  * license or royalty fees, to use, copy, modify, and distribute this
31  * software and its documentation for any purpose, provided that
32  * (1) The above copyright notice and the following two paragraphs
33  * appear in all copies of the source code and (2) redistributions
34  * including binaries reproduces these notices in the supporting
35  * documentation. Substantial modifications to this software may be
36  * copyrighted by their authors and need not follow the licensing terms
37  * described here, provided that the new terms are clearly indicated in
38  * all files where they apply.
39  *
40  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
41  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
42  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
43  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
44  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
45  * THE POSSIBILITY OF SUCH DAMAGE.
46  *
47  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
48  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
49  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
50  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
51  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
52  *
53  * @EulaEnd@
54  */
55 ////////////////////////////////////////////////////////////////////////////////
56 
57 #ifndef _RNR_CAMERA_ECON_32_H
58 #define _RNR_CAMERA_ECON_32_H
59 
60 #if defined(ARCH_overo)
61 
62 #include <limits.h>
63 #include <math.h>
64 
65 #include <string>
66 
67 #include "rnr/rnrconfig.h"
68 #include "rnr/log.h"
69 
70 #include "rnr/appkit/Camera.h"
71 #include "rnr/appkit/CameraCv.h"
72 
73 #include "econ/econ32.h"
74 
75 #include "opencv/cv.h"
76 
77 /*!
78  * \brief RoadNarrows Robotics
79  */
80 namespace rnr
81 {
82  /*!
83  * \brief Special Econ supported camera resolutions.
84  */
85  const CamRes CamResEcon3_2MP = CamRes2048x1536; ///< max camera resolution
86 
87  /*!
88  * \brief Camera physical characteristics.
89  */
90  const double ViewAngleDiag = 65.0; ///< 65\h_deg
91  const double FocusMinMM = 100.0; ///< minimum focus (mm)
92  const double FocusMaxMM = HUGE_VAL; ///< maximum focus (mm)
93  const CvSize2D32f SensorDimMM = {2.7, 3.6}; ///< sensor dimensions
94  const double FocalLenCM = 4.00; ///< focal length (cm)
95 
96  //---------------------------------------------------------------------------
97  // Econ 3.2MP Camera Derived Class
98  //---------------------------------------------------------------------------
99 
100  /*!
101  * \brief Econ 3.2MP implementation of the camera class.
102  *
103  * The video is streamed via OpenCv calls. The still images are taken via
104  * econ methods to gain higher resolution (theoretically).
105  *
106  * \note CameraEcon32 needs to be re-tested on hardware.
107  */
108  class CameraEcon32 : public CameraCv
109  {
110  public:
111  /*
112  * \brief Default initialization constructor.
113  *
114  * \param strVideoDevName Video camera device name.
115  * \param resVideo Video resolution.
116  * \param resImage Image resolution.
117  */
118  CameraEcon32(const std::string &strVideoDevName="/dev/video0",
119  const CamRes &resVideo=CamResQVGA,
120  const CamRes &resImage=CamResVGA);
121 
122  /*!
123  * \brief Destructor.
124  */
125  virtual ~CameraEcon32();
126 
127  /*!
128  * \brief Take a still image.
129  *
130  * \note Any OpenCV video capture must be stopped before executing econ
131  * image capture.
132  *
133  * \param [in,out] img Snap shot image taken.
134  * \param resImage Still image resolution. If equal to CamResDft, then
135  * the initial/last image resolution setting is used.
136  *
137  * \copydoc doc_return_std
138  */
139  virtual int clickImage(cv::Mat &img, const CamRes &resImage=CamResDft);
140 
141  /*!
142  * \brief Auto-focus camera.
143  */
144  virtual void autoFocus();
145 
146  protected:
147  ecam *m_eCam; ///< econ 3.2 MP camera
148  char m_bufTmpName[PATH_MAX]; ///< temporary file name buffer
149 
150  /*!
151  * \brief Set the camera resolution in either video or still image mode.
152  *
153  * \param res Target camera resolution.
154  *
155  * \return Actual resolution set.
156  */
157  virtual CamRes setCameraResolution(const CamRes &res);
158 
159  /*!
160  * \brief Make unique temporary file.
161  */
162  void makeTmpFile();
163 
164  };
165 
166 } // namespace rnr
167 
168 #endif // defined(ARCH_overo)
169 
170 #endif // _RNR_CAMERA_ECON_32_H
Video and still image camera base class.
const CamRes CamResDft
default resolution
Definition: Camera.h:89
OpenCv video and still image camera class.
const CamRes CamResQVGA
Quarter VGA 320 x 240 res.
Definition: Camera.h:90
const CamRes CamRes2048x1536
2048 x 1536 resolution
Definition: Camera.h:95
RoadNarrows Robotics.
Definition: Camera.h:74
const CamRes CamResVGA
VGA 640 x 480 resolution.
Definition: Camera.h:91