[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/videosource.h cvd/Linux/v4lbuffer.h ...
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd cvd/videosource.h cvd/Linux/v4lbuffer.h ... |
Date: |
Wed, 26 Nov 2008 22:15:45 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 08/11/26 22:15:44
Modified files:
cvd : videosource.h
cvd/Linux : v4lbuffer.h
cvd_src : videosource.cpp
cvd_src/Linux : v4l2buffer.cc v4lbuffer.cc
progs : video_play_source.cc
Log message:
Fix for bttv driver in v4lbuffer and (depracated?) v4l2buffer.
Added Rgb8 capture mode, which comes out very blue.
Added grey hack capture mode, which grabs a planar format if grey isn't
available.
Added very verbose mode to v4lbuffer, with optional switch in
open_video_source
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4lbuffer.h?cvsroot=libcvd&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource.cpp?cvsroot=libcvd&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/v4l2buffer.cc?cvsroot=libcvd&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/v4lbuffer.cc?cvsroot=libcvd&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/video_play_source.cc?cvsroot=libcvd&r1=1.2&r2=1.3
Patches:
Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cvd/videosource.h 25 Nov 2008 18:32:30 -0000 1.14
+++ cvd/videosource.h 26 Nov 2008 22:15:42 -0000 1.15
@@ -104,7 +104,7 @@
void get_files_options(const VideoSource& vs, int& fps, int& ra_frames,
VideoBufferFlags::OnEndOfBuffer& eob);
#if CVD_HAVE_V4L1BUFFER
- template <class T> VideoBuffer<T>* makeV4L1Buffer(const std::string& dev,
const ImageRef& size)
+ template <class T> VideoBuffer<T>* makeV4L1Buffer(const std::string&,
const ImageRef& )
{
throw VideoSourceException("V4L1Buffer cannot handle types other than
byte, bayer, yuv422, Rgb<byte>");
}
@@ -129,6 +129,7 @@
template <> VideoBuffer<bayer>* makeV4LBuffer(const std::string& dev,
const ImageRef& size, int input, bool interlaced, bool verbose);
template <> VideoBuffer<yuv422>* makeV4LBuffer(const std::string& dev,
const ImageRef& size, int input, bool interlaced, bool verbose);
template <> VideoBuffer<Rgb<byte> >* makeV4LBuffer(const std::string& dev,
const ImageRef& size, int input, bool interlaced, bool verbose);
+ template <> VideoBuffer<Rgb8>* makeV4LBuffer(const std::string& dev, const
ImageRef& size, int input, bool interlaced, bool verbose);
void get_v4l2_options(const VideoSource& vs, ImageRef& size, int& input,
bool& interlaced, bool& verbose);
@@ -136,7 +137,7 @@
#if CVD_HAVE_FFMPEG
- template <class T> VideoBuffer<T>* makeVideoFileBuffer(const std::string&
file, VideoBufferFlags::OnEndOfBuffer eob)
+ template <class T> VideoBuffer<T>* makeVideoFileBuffer(const std::string&
, VideoBufferFlags::OnEndOfBuffer )
{
throw VideoSourceException("VideoFileBuffer cannot handle types other
than byte, Rgb<byte>");
}
@@ -149,7 +150,7 @@
#endif
#if CVD_HAVE_DVBUFFER
- template <class T> VideoBuffer<T>* makeDVBuffer2(int cam, int dmabufs, int
bright, int exposure, int fps)
+ template <class T> VideoBuffer<T>* makeDVBuffer2(int , int , int , int ,
int )
{
throw VideoSourceException("DVBuffer2 cannot handle types other than
byte, Rgb<byte>");
}
@@ -162,7 +163,7 @@
#endif
#if CVD_HAVE_QTBUFFER
- template <class T> VideoBuffer<T> * makeQTBuffer( const ImageRef & size,
int input, bool showsettings)
+ template <class T> VideoBuffer<T> * makeQTBuffer( const ImageRef & , int ,
bool )
{
throw VideoSourceException("QTBuffer cannot handle types other than
vuy422");
}
Index: cvd/Linux/v4lbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4lbuffer.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- cvd/Linux/v4lbuffer.h 25 Nov 2008 18:32:30 -0000 1.10
+++ cvd/Linux/v4lbuffer.h 26 Nov 2008 22:15:43 -0000 1.11
@@ -37,6 +37,7 @@
#include <cvd/videobuffer.h>
#include <cvd/byte.h>
#include <cvd/rgb.h>
+#include <cvd/rgb8.h>
#include <cvd/timer.h>
#include <cvd/colourspaces.h>
#include <fcntl.h>
@@ -107,6 +108,12 @@
static const unsigned int v4l2_fmt = V4L2_PIX_FMT_RGB24;
static const unsigned int v4l1_palette = VIDEO_PALETTE_RGB24;
};
+
+ template<> struct format<Rgb8>
+ {
+ static const unsigned int v4l2_fmt = V4L2_PIX_FMT_RGB32;
+ static const unsigned int v4l1_palette = VIDEO_PALETTE_RGB32;
+ };
#endif
class V4L2Client
Index: cvd_src/videosource.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- cvd_src/videosource.cpp 25 Nov 2008 18:32:30 -0000 1.9
+++ cvd_src/videosource.cpp 26 Nov 2008 22:15:43 -0000 1.10
@@ -336,11 +336,17 @@
return new CVD::V4LBuffer<CVD::Rgb<CVD::byte> >(dev, size, input,
interlaced, 0, verbose);
}
+ template <> CVD::VideoBuffer<CVD::Rgb8>* makeV4LBuffer(const std::string&
dev, const CVD::ImageRef& size, int input, bool interlaced, bool verbose)
+ {
+ return new CVD::V4LBuffer<CVD::Rgb8>(dev, size, input, interlaced, 0,
verbose);
+ }
+
void get_v4l2_options(const VideoSource& vs, ImageRef& size, int& input,
bool& interlaced, bool& verbose)
{
size = ImageRef(640,480);
input = -1;
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;
Index: cvd_src/Linux/v4l2buffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/v4l2buffer.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- cvd_src/Linux/v4l2buffer.cc 24 Apr 2008 23:30:39 -0000 1.15
+++ cvd_src/Linux/v4l2buffer.cc 26 Nov 2008 22:15:44 -0000 1.16
@@ -290,7 +290,8 @@
sv4l2RequestBuffers.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
//|V4L2_BUF_ATTR_DEVICEMEM;
sv4l2RequestBuffers.memory=V4L2_MEMORY_MMAP;
- if(0!=ioctl(m_nVideoFileDesc,VIDIOC_REQBUFS,&sv4l2RequestBuffers))
+ //bttv now returns num_buffers
+ if(ioctl(m_nVideoFileDesc,VIDIOC_REQBUFS,&sv4l2RequestBuffers)==-1)
throw Exceptions::V4L2Buffer::DeviceSetup(devname, "Request
capture buffers");
num_buffers = sv4l2RequestBuffers.count;
Index: cvd_src/Linux/v4lbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/v4lbuffer.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- cvd_src/Linux/v4lbuffer.cc 26 Nov 2008 19:09:10 -0000 1.8
+++ cvd_src/Linux/v4lbuffer.cc 26 Nov 2008 22:15:44 -0000 1.9
@@ -186,10 +186,6 @@
{
actual_fmt = f.pixelformat;
}
-
- //Turbobodge!!!! Remove this!! FIXME FIXME FIXME
- if(fmt == fourcc("RGB3") && f.pixelformat == fourcc("BGR3"))
- actual_fmt = f.pixelformat;
}
if(errno != EINVAL)
@@ -199,7 +195,7 @@
log << "Seleced format: " << unfourcc(fmt) << "\n";
-/* if (caps.driver == string("bttv"))
+ if (strcmp((const char*)caps.driver,"bttv") == 0)
{
v4l2_std_id stdId=V4L2_STD_PAL;
if(ioctl(fd, VIDIOC_S_STD, &stdId ))
@@ -212,7 +208,7 @@
if (0 != ioctl(fd, VIDIOC_S_INPUT, &v4l2Input))
throw string("VIDIOC_S_INPUT");
}
-*/
+
// Get / Set capture format.
struct v4l2_format format;
format.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -234,17 +230,27 @@
format.fmt.pix.pixelformat = fmt;
format.fmt.pix.field = fields ? V4L2_FIELD_ALTERNATE : V4L2_FIELD_ANY;
- log << "S_FMT with size/format/fields: " << format.fmt.pix.width <<
"x" << format.fmt.pix.height << " / "
- << unfourcc(format.fmt.pix.pixelformat) << hex << " (0x" <<
format.fmt.pix.pixelformat << dec << ") / " << format.fmt.pix.field << "\n";
+ log << "Setting format (VIDIOC_S_FMT)\n";
+ log << " size: " << format.fmt.pix.width << "x" <<
format.fmt.pix.height << "\n";
+ log << " format: " << unfourcc(format.fmt.pix.pixelformat) << "\n";
+ log << " field flag: " << format.fmt.pix.field << "\n";
+ log << " bytes per line: " << format.fmt.pix.bytesperline << "\n";
+ log << " image size: " << format.fmt.pix.sizeimage << "\n";
+ log << " colourspace: " << format.fmt.pix.colorspace << "\n";
if (0 != ioctl(fd, VIDIOC_S_FMT, &format))
throw string("VIDIOC_S_FMT");
+ log << "Getting format (VIDIOC_G_FMT)\n";
if (0 != ioctl(fd, VIDIOC_G_FMT, &format))
throw string("VIDIOC_G_FMT");
- log << "G_FMT gives size/format/fields: " << format.fmt.pix.width <<
"x" << format.fmt.pix.height << " / "
- << unfourcc(format.fmt.pix.pixelformat) << hex << " (0x" <<
format.fmt.pix.pixelformat << dec << ") / " << format.fmt.pix.field << "\n";
+ log << " size: " << format.fmt.pix.width << "x" <<
format.fmt.pix.height << "\n";
+ log << " format: " << unfourcc(format.fmt.pix.pixelformat) << "\n";
+ log << " field flag: " << format.fmt.pix.field << "\n";
+ log << " bytes per line: " << format.fmt.pix.bytesperline << "\n";
+ log << " image size: " << format.fmt.pix.sizeimage << "\n";
+ log << " colourspace: " << format.fmt.pix.colorspace << "\n";
if (fmt != format.fmt.pix.pixelformat)
@@ -254,13 +260,22 @@
reqbufs.count = 10;
reqbufs.memory = V4L2_MEMORY_MMAP;
reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (0 != ioctl(fd,VIDIOC_REQBUFS,&reqbufs))
- throw string("VIDIOC_REQBUFS");
- cerr << "wtttf\n";
+ log << "Issuing VIDIOC_REQBUFS ioctl.\n";
+ int ret = ioctl(fd,VIDIOC_REQBUFS,&reqbufs);
+ log << " Return code: " << ret << "\n";
+
+ //WARNING!!!!!
+ //The documentation says -1 for error, 0 otherwise.
+ //The BTTV driver returns num_bufs on success!
+ //So the test against 0 fails.
+ if (ioctl(fd,VIDIOC_REQBUFS,&reqbufs) == -1)
+ throw string("VIDIOC_REQBUFS");
num_bufs = reqbufs.count;
+ log << "Number of buffers: " << num_bufs << "\n";
+
if (reqbufs.count < 2)
throw string("Insufficient buffers available");
vector<State::Frame> frames(reqbufs.count);
Index: progs/video_play_source.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/video_play_source.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- progs/video_play_source.cc 25 Nov 2008 12:06:34 -0000 1.2
+++ progs/video_play_source.cc 26 Nov 2008 22:15:44 -0000 1.3
@@ -44,7 +44,8 @@
VideoDisplay display(buffer->size());
- while(buffer->frame_pending())
+ //while(buffer->frame_pending())
+ for(;;)
{
VideoFrame<C>* frame = buffer->get_frame();
glDrawPixels(*frame);
@@ -55,14 +56,22 @@
int main(int argc, char* argv[])
{
- bool mono=0;
+ int type =0;
int arg=1;
- if(argc-1 >=1 && argv[arg] == string("-mono"))
+ if(argc-1 >=1)
+ {
+ if(argv[arg] == string("-mono"))
{
arg++;
- mono=1;
+ type=1;
+ }
+ else if(argv[arg] == string("-rgb8"))
+ {
+ arg++;
+ type=2;
+ }
}
if(arg != argc-1)
@@ -72,8 +81,10 @@
}
try
{
- if(mono)
+ if(type == 1)
play<byte>(argv[arg]);
+ else if(type == 2)
+ play<Rgb8>(argv[arg]);
else
play<Rgb<byte> >(argv[arg]);
}