[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/videosource.h cvd_src/videosource.cpp
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd cvd/videosource.h cvd_src/videosource.cpp |
Date: |
Fri, 23 Oct 2009 17:10:13 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 09/10/23 17:10:13
Modified files:
cvd : videosource.h
cvd_src : videosource.cpp
Log message:
Move open_video_source to DVBuffer3. Also clean up a bit.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource.cpp?cvsroot=libcvd&r1=1.12&r2=1.13
Patches:
Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- cvd/videosource.h 23 Oct 2009 14:49:43 -0000 1.18
+++ cvd/videosource.h 23 Oct 2009 17:10:10 -0000 1.19
@@ -30,7 +30,7 @@
#endif
#if CVD_HAVE_DVBUFFER
-#include <cvd/Linux/dvbuffer.h>
+#include <cvd/Linux/dvbuffer3.h>
#endif
#if CVD_HAVE_QTBUFFER
@@ -149,15 +149,15 @@
#endif
#if CVD_HAVE_DVBUFFER
- template <class T> VideoBuffer<T>* makeDVBuffer2(int , int , int , int ,
int )
+ template <class T> VideoBuffer<T>* makeDVBuffer2(int , ImageRef , float ,
ImageRef)
{
throw VideoSourceException("DVBuffer2 cannot handle types other than
byte, Rgb<byte>");
}
- template <> VideoBuffer<byte>* makeDVBuffer2(int cam, int dmabufs, int
bright, int exposure, int fps);
- template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, int dmabufs,
int bright, int exposure, int fps);
+ template <> VideoBuffer<byte>* makeDVBuffer2(int cam, ImageRef size, float
fps, ImageRef offset);
+ template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset);
- void get_dc1394_options(const VideoSource& vs, int& dma_bufs, int& bright,
int& exposure, int& fps);
+ void get_dc1394_options(const VideoSource& vs, ImageRef& size, float& fps,
ImageRef& offset);
#endif
@@ -222,9 +222,10 @@
#if CVD_HAVE_DVBUFFER
else if (vs.protocol == "dc1394") {
int cam_no = atoi(vs.identifier.c_str());
- int dma_bufs, bright, exposure, fps;
- get_dc1394_options(vs, dma_bufs, bright, exposure, fps);
- return makeDVBuffer2<T>(cam_no, dma_bufs, bright, exposure, fps);
+ ImageRef size, offset;
+ float fps;
+ get_dc1394_options(vs, size, fps, offset);
+ return makeDVBuffer2<T>(cam_no, size, fps, offset);
}
#endif
#if CVD_HAVE_FFMPEG
Index: cvd_src/videosource.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- cvd_src/videosource.cpp 11 Mar 2009 21:35:13 -0000 1.12
+++ cvd_src/videosource.cpp 23 Oct 2009 17:10:12 -0000 1.13
@@ -3,6 +3,7 @@
#include <cvd/colourspaces.h>
namespace CVD {
+ using namespace std;
void tolower(std::string& s)
{
@@ -31,6 +32,34 @@
throw ParseException("invalid interlaced/fields setting
'"+s+"' (must be true/false or yes/no or 1/0)");
}
+ ImageRef parseImageRef(string s, bool is_size)
+ {
+ ImageRef size;
+ tolower(s);
+ if (is_size && s == "vga")
+ size = ImageRef(640,480);
+ else if (is_size && s == "qvga")
+ size = ImageRef(320,240);
+ else if (is_size && s == "pal")
+ size = ImageRef(720,576);
+ else if (is_size && s == "ntsc")
+ size = ImageRef(720,480);
+ else if (is_size && s == "xga")
+ size = ImageRef(1024,768);
+ else {
+ std::istringstream size_in(s);
+ char x;
+ if (!(size_in >> size.x >> x >> size.y))
+ {
+ if(is_size)
+ throw ParseException("invalid image
size specification: '"+ s +"'\n\t valid specs: qvga, vga, pal, ntsc, xga,
<width>x<height>");
+ else
+ throw ParseException("invalid image
position specification: '"+ s + "'\n\t valid specs: <width>x<height>");
+ }
+ }
+ return size;
+ }
+
std::string escape(char c)
{
static std::string escaped[256];
@@ -290,24 +319,9 @@
size = ImageRef(0,0);
for (VideoSource::option_list::const_iterator it=vs.options.begin(); it
!= vs.options.end(); ++it) {
- if (it->first == "size") {
- std::string s = it->second;
- tolower(s);
- if (s == "vga")
- size = ImageRef(640,480);
- else if (s == "qvga")
- size = ImageRef(320,240);
- else if (s == "pal")
- size = ImageRef(720,576);
- else if (s == "ntsc")
- size = ImageRef(720,480);
- else {
- std::istringstream size_in(s);
- char x;
- if (!(size_in >> size.x >> x >> size.y))
- throw ParseException("invalid image size specification:
'"+it->second+"'\n\t valid specs: vga, qvga, pal, ntsc, <width>x<height>");
- }
- } else
+ if (it->first == "size")
+ size = parseImageRef(it->second, true);
+ else
throw VideoSourceException("invalid option for 'v4l2' protocol:
"+it->first+"\n\t valid options: size, input, interlaced, fields");
}
}
@@ -352,24 +366,9 @@
interlaced = false;
verbose=0;
for (VideoSource::option_list::const_iterator it=vs.options.begin(); it
!= vs.options.end(); ++it) {
- if (it->first == "size") {
- std::string s = it->second;
- tolower(s);
- if (s == "vga")
- size = ImageRef(640,480);
- else if (s == "qvga")
- size = ImageRef(320,240);
- else if (s == "pal")
- size = ImageRef(720,576);
- else if (s == "ntsc")
- size = ImageRef(720,480);
- else {
- std::istringstream size_in(s);
- char x;
- if (!(size_in >> size.x >> x >> size.y))
- throw ParseException("invalid image size specification:
'"+it->second+"'\n\t valid specs: vga, qvga, pal, ntsc, <width>x<height>");
- }
- } else if (it->first == "input") {
+ if (it->first == "size")
+ size = parseImageRef(it->second, true);
+ else if (it->first == "input") {
input = atoi(it->second.c_str());
} else if (it->first == "verbose") {
verbose = parseBoolFlag(it->second);
@@ -422,33 +421,30 @@
#endif
#if CVD_HAVE_DVBUFFER
- template <> CVD::VideoBuffer<CVD::byte>* makeDVBuffer2(int cam, int
dmabufs, int bright, int exposure, int fps)
+ template <> CVD::VideoBuffer<CVD::byte>* makeDVBuffer2(int cam,
ImageRef size, float fps, ImageRef offset)
{
- return new CVD::DVBuffer2<CVD::byte>(cam,dmabufs,bright,exposure,fps);
+ return new CVD::DVBuffer3<CVD::byte>(cam,size, fps, offset);
}
- template <> CVD::VideoBuffer<CVD::Rgb<CVD::byte> >* makeDVBuffer2(int cam,
int dmabufs, int bright, int exposure, int fps)
+ template <> CVD::VideoBuffer<CVD::Rgb<CVD::byte> >* makeDVBuffer2(int
cam, ImageRef size, float fps, ImageRef offset)
{
- return new CVD::DVBuffer2<CVD::Rgb<CVD::byte>
>(cam,dmabufs,bright,exposure,fps);
+ return new CVD::DVBuffer3<CVD::Rgb<CVD::byte> >(cam, size, fps,
offset);
}
- void get_dc1394_options(const VideoSource& vs, int& dma_bufs, int& bright,
int& exposure, int& fps)
+ void get_dc1394_options(const VideoSource& vs, ImageRef& size, float&
fps, ImageRef& offset)
{
- dma_bufs = 3;
- bright = -1;
- exposure = -1;
- fps = 30;
+ size = offset = ImageRef(-1, -1);
+ fps = -1;
+
for (VideoSource::option_list::const_iterator it=vs.options.begin(); it
!= vs.options.end(); ++it) {
if (it->first == "fps")
fps = atoi(it->second.c_str());
- else if (it->first == "dma_bufs" || it->first == "dma_buffers")
- dma_bufs = atoi(it->second.c_str());
- else if (it->first == "brightness" || it->first == "bright")
- bright = atoi(it->second.c_str());
- else if (it->first == "exp" || it->first == "exposure")
- exposure = atoi(it->second.c_str());
+ else if (it->first == "size")
+ size = parseImageRef(it->second, true);
+ else if (it->first == "offset")
+ offset = parseImageRef(it->second, false);
else
- throw VideoSourceException("invalid option for dc1394 protocol:
"+it->first+"\n\t valid options: dma_bufs, brightness, exposure, fps");
+ throw VideoSourceException("invalid option for
dc1394 protocol: "+it->first+"\n\t valid options: fps, size, offset");
}
}
#endif
@@ -468,20 +464,8 @@
size = ImageRef(640, 480);
showsettings = false;
for (VideoSource::option_list::const_iterator it=vs.options.begin(); it
!= vs.options.end(); ++it) {
- if (it->first == "size") {
- std::string s = it->second;
- tolower(s);
- if (s == "vga")
- size = ImageRef(640,480);
- else if (s == "qvga")
- size = ImageRef(320,240);
- else {
- std::istringstream size_in(s);
- char x;
- if (!(size_in >> size.x >> x >> size.y))
- throw ParseException("invalid image size specification:
'"+it->second+"'\n\t valid specs: vga, qvga, <width>x<height>");
- }
- }
+ if (it->first == "size")
+ size = parseImageRef(it->second, true);
else if(it->first == "showsettings") {
showsettings = atoi(it->second.c_str());
} else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd cvd/videosource.h cvd_src/videosource.cpp,
Edward Rosten <=