55 #if defined(ARCH_overo) 60 #include "rnr/rnrconfig.h" 67 #include "opencv/cv.h" 69 #include "econ/econ32.h" 81 CameraEcon32::CameraEcon32(
const std::string &strVideoDevName,
84 CameraCv(strVideoDevName, resVideo, resImage)
89 CameraEcon32::~CameraEcon32()
93 if( m_bufTmpName[0] != 0 )
99 int CameraEcon32::clickImage(Mat &img,
const CamRes &resImage)
107 LOGERROR(
"No ecam object.");
126 save_snap(m_eCam, m_bufTmpName);
129 img = imread(m_bufTmpName, CV_LOAD_IMAGE_COLOR);
133 LOGDIAG3(
"Took a %dx%d still image.", img.cols, img.rows);
146 void CameraEcon32::autoFocus()
150 CamRes CameraEcon32::setCameraResolution(
const CamRes &res)
152 int oldWidth = m_eCam->fmt.fmt.pix.
width;
153 int oldHeight = m_eCam->fmt.fmt.pix.height;
155 m_eCam->fmt.fmt.pix.width = res.
width;
156 m_eCam->fmt.fmt.pix.height = res.
height;
158 m_eCam->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
160 m_eCam->fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565;
161 m_eCam->fmt.fmt.pix.bytesperline = m_eCam->fmt.fmt.pix.width * 2;
162 m_eCam->fmt.fmt.pix.priv = 0;
163 m_eCam->fmt.fmt.pix.sizeimage = m_eCam->fmt.fmt.pix.width * \
164 m_eCam->fmt.fmt.pix.height * 2;
166 if (ioctl(m_eCam->fd_v4l2, VIDIOC_S_FMT, &m_eCam->fmt) < 0)
168 LOGERROR(
"Unable to set camera resolution %dx%d", res.
width, res.
height);
169 m_eCam->fmt.fmt.pix.width = oldWidth;
170 m_eCam->fmt.fmt.pix.height = oldHeight;
179 void CameraEcon32::makeTmpFile()
181 string strX(
"XXXXXX");
182 string strSuffix(
".bmp");
185 sprintf(m_bufTmpName,
"/tmp/camecon32-%s%s", strX.c_str(), strSuffix.c_str());
188 if( (fd = mkstemps(m_bufTmpName, strSuffix.length())) < 0 )
190 LOGERROR(
"mkstemps(%s, %zu) failed.\n", m_bufTmpName, strSuffix.length());
198 sprintf(tmp,
"/tmp/camecon32-%s", strX.c_str());
200 if( (fd = mkstemp(tmp)) < 0 )
202 LOGERROR(
"mkstemp(%s) failed.\n", tmp);
209 rename(tmp, m_bufTmpName);
219 #endif // defined(ARCH_overo) OpenCv implementation of the camera class. The video is streamed via OpenCv calls.
static bool isEqResolution(const CamRes &res1, const CamRes &res2)
Check is two camera resolutions are equal.
CamRes m_resCurrent
current camera resolution
virtual int startVideo(const CamRes &resVideo=CamResDft)
Start the camera streaming video.
Video and still image camera base class.
const CamRes CamResDft
default resolution
bool m_bTakingImage
taking an image is [not] finished
CamRes m_resVideo
current video resolution
OpenCv video and still image camera class.
Econ 3.2 megapixel video and still image camera class.
virtual CamRes setCameraResolution(const CamRes &res)
Set the camera resolution in either video or still image mode.
virtual int stopVideo()
Stop the camera from streaming video.
Camera resolution structure.
int height
height in pixels
CamRes m_resImage
current still image resolution
bool isCameraRunning() const
Test if the camera is on and running.
bool m_bFatal
camera instance is in a fatal state