[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/videosource.h cvd/Linux/dvbuffer3.h ...
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd cvd/videosource.h cvd/Linux/dvbuffer3.h ... |
Date: |
Thu, 21 Jan 2010 16:48:28 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 10/01/21 16:48:28
Modified files:
cvd : videosource.h
cvd/Linux : dvbuffer3.h
cvd_src : videosource.cpp videosource_dvbuffer.cc
videosource_nodvbuffer.cc
cvd_src/Linux : dvbuffer3_dc1394v1.cc dvbuffer3_dc1394v2.cc
progs : video_play_source.cc
Log message:
Added verbosity option to DVBuffer3. Accessible using verbose=1 with
open_video_source provided that libdc1394v2 is in use.
Also added camera reset, since this seems to be required in order for
the FireflyMV to accept new settings.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videosource.h?cvsroot=libcvd&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/dvbuffer3.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource.cpp?cvsroot=libcvd&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource_dvbuffer.cc?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videosource_nodvbuffer.cc?cvsroot=libcvd&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/dvbuffer3_dc1394v1.cc?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/dvbuffer3_dc1394v2.cc?cvsroot=libcvd&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/libcvd/progs/video_play_source.cc?cvsroot=libcvd&r1=1.5&r2=1.6
Patches:
Index: cvd/videosource.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videosource.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- cvd/videosource.h 12 Nov 2009 16:26:52 -0000 1.25
+++ cvd/videosource.h 21 Jan 2010 16:48:28 -0000 1.26
@@ -217,22 +217,22 @@
//
// DC1394 buffer
//
- template <class T> VideoBuffer<T>* makeDVBuffer2(int , ImageRef , float
, ImageRef)
+ template <class T> VideoBuffer<T>* makeDVBuffer2(int , ImageRef , float
, ImageRef, bool)
{
throw VideoSourceException("DVBuffer2 cannot handle " +
PNM::type_name<T>::name());
}
- template <> VideoBuffer<byte>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset);
- template <> VideoBuffer<unsigned short>* makeDVBuffer2(int cam,
ImageRef size, float fps, ImageRef offset);
- template <> VideoBuffer<yuv411>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset);
- template <> VideoBuffer<yuv422>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset);
- template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset);
- template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset);
- template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset);
- template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset);
- template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset);
+ template <> VideoBuffer<byte>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<unsigned short>* makeDVBuffer2(int cam,
ImageRef size, float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<yuv411>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<yuv422>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool verbose);
+ template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool verbose);
- void get_dc1394_options(const VideoSource& vs, ImageRef& size, float&
fps, ImageRef& offset);
+ void get_dc1394_options(const VideoSource& vs, ImageRef& size, float&
fps, ImageRef& offset, bool& verbose);
////////////////////////////////////////////////////////////////////////////////
//
@@ -305,8 +305,9 @@
int cam_no = atoi(vs.identifier.c_str());
ImageRef size, offset;
float fps;
- get_dc1394_options(vs, size, fps, offset);
- return makeDVBuffer2<T>(cam_no, size, fps, offset);
+ bool verbose;
+ get_dc1394_options(vs, size, fps, offset, verbose);
+ return makeDVBuffer2<T>(cam_no, size, fps, offset,
verbose);
}
else if (vs.protocol == "file") {
int ra_frames = 0;
Index: cvd/Linux/dvbuffer3.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/dvbuffer3.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd/Linux/dvbuffer3.h 6 May 2009 18:12:04 -0000 1.5
+++ cvd/Linux/dvbuffer3.h 21 Jan 2010 16:48:28 -0000 1.6
@@ -25,6 +25,7 @@
#include <cvd/videobuffer.h>
#include <cvd/byte.h>
#include <cvd/rgb.h>
+#include <inttypes.h>
#include <cvd/colourspaces.h>
namespace CVD
@@ -116,7 +117,10 @@
/// @param fFrameRate Requested frame-rate; if negative, use fastest
available
/// @param irOffset offset of video frame in CCD; if left at (-1,-1) use
default modes or center window
RawDVBuffer3(DV3ColourSpace colourspace,
- unsigned int nCamNumber=0,
+ int nCamNumber=0,
+ uint64_t cam_guid=-1,
+ int cam_unit=-1,
+ bool verbose=0,
ImageRef irSize = ImageRef(-1,-1),
float fFrameRate=-1.0,
ImageRef irOffset = ImageRef(-1,-1));
@@ -138,6 +142,7 @@
void power_on_off(DV3Feature nFeature, bool bValue);
private:
+
ImageRef mirSize;
ImageRef mirOffset;
double mdFramerate;
@@ -159,9 +164,10 @@
DVBuffer3(unsigned int nCamNumber=0,
ImageRef irSize = ImageRef(-1,-1),
float fFPS = -1.0,
- ImageRef irOffset = ImageRef(-1,-1))
+ ImageRef irOffset = ImageRef(-1,-1),
+ bool verbose=0)
: VideoBuffer<pixel_T>(VideoBufferType::Live),
- RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, irSize,
fFPS, irOffset)
+ RawDVBuffer3(DV3::CSConvert<pixel_T>::space, nCamNumber, 0, -1,
verbose, irSize, fFPS, irOffset)
{
if(DV3::CSFilter<pixel_T>::filter != DV3::UNDEFINED &&
colour_filter() != DV3::CSFilter<pixel_T>::filter )
throw(Exceptions::DVBuffer3::All("wrong colour filter
expected"));
Index: cvd_src/videosource.cpp
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- cvd_src/videosource.cpp 12 Nov 2009 16:26:52 -0000 1.15
+++ cvd_src/videosource.cpp 21 Jan 2010 16:48:28 -0000 1.16
@@ -365,7 +365,7 @@
}
- void get_dc1394_options(const VideoSource& vs, ImageRef& size, float&
fps, ImageRef& offset)
+ void get_dc1394_options(const VideoSource& vs, ImageRef& size, float&
fps, ImageRef& offset, bool& verbose)
{
size = offset = ImageRef(-1, -1);
fps = -1;
@@ -377,8 +377,10 @@
size = parseImageRef(it->second, true);
else if (it->first == "offset")
offset = parseImageRef(it->second, false);
+ else if (it->first == "verbose")
+ verbose =
parseBoolFlag(it->second);
else
- throw VideoSourceException("invalid option for
dc1394 protocol: "+it->first+"\n\t valid options: fps, size, offset");
+ throw VideoSourceException("invalid option for
dc1394 protocol: "+it->first+"\n\t valid options: fps, size, offset, verbose");
}
}
Index: cvd_src/videosource_dvbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource_dvbuffer.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/videosource_dvbuffer.cc 26 Oct 2009 15:44:58 -0000 1.1
+++ cvd_src/videosource_dvbuffer.cc 21 Jan 2010 16:48:28 -0000 1.2
@@ -3,49 +3,49 @@
namespace CVD{
- template <> VideoBuffer<byte>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset)
+ template <> VideoBuffer<byte>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<byte>(cam,size, fps, offset);
+ return new DVBuffer3<byte>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<unsigned short>* makeDVBuffer2(int cam,
ImageRef size, float fps, ImageRef offset)
+ template <> VideoBuffer<unsigned short>* makeDVBuffer2(int cam,
ImageRef size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<unsigned short>(cam,size, fps, offset);
+ return new DVBuffer3<unsigned short>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<yuv411>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset)
+ template <> VideoBuffer<yuv411>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<yuv411>(cam,size, fps, offset);
+ return new DVBuffer3<yuv411>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<yuv422>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset)
+ template <> VideoBuffer<yuv422>* makeDVBuffer2(int cam, ImageRef size,
float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<yuv422>(cam,size, fps, offset);
+ return new DVBuffer3<yuv422>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset)
+ template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<bayer_grbg>(cam,size, fps, offset);
+ return new DVBuffer3<bayer_grbg>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset)
+ template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<bayer_gbrg>(cam,size, fps, offset);
+ return new DVBuffer3<bayer_gbrg>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset)
+ template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<bayer_rggb>(cam,size, fps, offset);
+ return new DVBuffer3<bayer_rggb>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset)
+ template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<bayer_bggr>(cam,size, fps, offset);
+ return new DVBuffer3<bayer_bggr>(cam,size, fps, offset, v);
}
- template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset)
+ template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int cam, ImageRef
size, float fps, ImageRef offset, bool v)
{
- return new DVBuffer3<Rgb<byte> >(cam, size, fps, offset);
+ return new DVBuffer3<Rgb<byte> >(cam, size, fps, offset, v);
}
}
Index: cvd_src/videosource_nodvbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videosource_nodvbuffer.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- cvd_src/videosource_nodvbuffer.cc 26 Oct 2009 15:44:58 -0000 1.1
+++ cvd_src/videosource_nodvbuffer.cc 21 Jan 2010 16:48:28 -0000 1.2
@@ -2,47 +2,47 @@
namespace CVD{
- template <> VideoBuffer<byte>* makeDVBuffer2(int, ImageRef, float,
ImageRef)
+ template <> VideoBuffer<byte>* makeDVBuffer2(int, ImageRef, float,
ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<unsigned short>* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<unsigned short>* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<yuv411>* makeDVBuffer2(int, ImageRef, float,
ImageRef)
+ template <> VideoBuffer<yuv411>* makeDVBuffer2(int, ImageRef, float,
ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<yuv422>* makeDVBuffer2(int, ImageRef, float,
ImageRef)
+ template <> VideoBuffer<yuv422>* makeDVBuffer2(int, ImageRef, float,
ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<bayer_grbg>* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<bayer_gbrg>* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<bayer_rggb>* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<bayer_bggr>* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
- template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int, ImageRef,
float, ImageRef)
+ template <> VideoBuffer<Rgb<byte> >* makeDVBuffer2(int, ImageRef,
float, ImageRef, bool)
{
throw VideoSourceException("DVBuffer3 is not compiled in to
libcvd.");
}
Index: cvd_src/Linux/dvbuffer3_dc1394v1.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/dvbuffer3_dc1394v1.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cvd_src/Linux/dvbuffer3_dc1394v1.cc 4 Jun 2009 17:10:20 -0000 1.5
+++ cvd_src/Linux/dvbuffer3_dc1394v1.cc 21 Jan 2010 16:48:28 -0000 1.6
@@ -65,7 +65,10 @@
}
RawDVBuffer3::RawDVBuffer3(DV3ColourSpace colourspace,
- unsigned int nCamNumber,
+ int nCamNumber,
+ uint64_t,
+ int,
+ bool,
ImageRef ,
float fFrameRate,
ImageRef )
Index: cvd_src/Linux/dvbuffer3_dc1394v2.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/dvbuffer3_dc1394v2.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- cvd_src/Linux/dvbuffer3_dc1394v2.cc 6 May 2009 18:12:05 -0000 1.7
+++ cvd_src/Linux/dvbuffer3_dc1394v2.cc 21 Jan 2010 16:48:28 -0000 1.8
@@ -25,8 +25,13 @@
#include <dc1394/dc1394.h>
#include <vector>
#include <algorithm>
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include <string>
using namespace CVD;
+using namespace std;
using namespace DV3;
using CVD::Exceptions::DVBuffer3::All;
@@ -36,6 +41,85 @@
namespace DV3
{
+ class VPrint_
+ {
+ public:
+ VPrint_(bool _p)
+ :p(_p)
+ {}
+
+ template<class C> VPrint_& operator<<(const C& c)
+ {
+ if(p)
+ cerr << c;
+
+ return *this;
+ }
+
+ bool p;
+ };
+
+ class VPrint: public VPrint_
+ {
+ public:
+ VPrint(bool _b)
+ :VPrint_(_b){}
+
+ template<class C> VPrint_& operator<<(const C& c)
+ {
+ if(p)
+ cerr << "RawDVBuffer3: " << c;
+
+ return *this;
+ }
+
+ };
+
+ string coding(dc1394color_coding_t ii)
+ {
+ int i = (int)ii;
+ static vector<string> c;
+
+ if(c.empty())
+ {
+ c.push_back("MONO8");
+ c.push_back("YUV411");
+ c.push_back("YUV422");
+ c.push_back("YUV444");
+ c.push_back("RGB8");
+ c.push_back("MONO16");
+ c.push_back("RGB16");
+ c.push_back("MONO16S");
+ c.push_back("RGB16S");
+ c.push_back("RAW8");
+ c.push_back("RAW16");
+ }
+
+ i-=352;
+ if(i < 0 || i >= (int)c.size())
+ return "error";
+ else
+ return c[i];
+ }
+
+
+ string filter(dc1394color_filter_t f)
+ {
+ switch(f)
+ {
+ case DC1394_COLOR_FILTER_RGGB:
+ return "RGGB";
+ case DC1394_COLOR_FILTER_BGGR:
+ return "BGGR";
+ case DC1394_COLOR_FILTER_GRBG:
+ return "GRBG";
+ case DC1394_COLOR_FILTER_GBRG:
+ return "GBRG";
+ }
+
+ return "error";
+ }
+
struct LibDCParams
{
dc1394_t *pDC1394;
@@ -98,11 +182,16 @@
}
RawDVBuffer3::RawDVBuffer3(DV3ColourSpace colourspace,
- unsigned int nCamNumber,
+ int nCamNumber,
+ uint64_t cam_guid,
+ int cam_unit,
+ bool verbose,
ImageRef irSize,
float fFrameRate,
ImageRef irOffset)
{
+ VPrint log(verbose);
+
mpLDCP = new LibDCParams;
// Create a libDC1394 context.
@@ -117,13 +206,36 @@
error = dc1394_camera_enumerate(mpLDCP->pDC1394, &pCameraList);
if(error) throw(All("Camera enumerate"));
+ log << "Requesting: \n";
+ log << " colourspace: " << colourspace << "\n";
+ log << " camera number: " << nCamNumber << "\n";
+ log << " camera guid: " << cam_guid << "\n";
+ log << " camera unit: " << cam_unit << "\n";
+ log << " size: " << irSize << "\n";
+ log << " framerate: " << fFrameRate << "\n";
+ log << " offset: " << irOffset << "\n";
+
if(pCameraList->num == 0)
{
dc1394_camera_free_list(pCameraList);
throw(All("No cameras found."));
}
+ else
+ {
+ log << "List of cameras:\n";
+ for(unsigned int i=0; i < pCameraList->num; i++)
+ {
+ log << " Camera: " << i << ": unit=" <<
pCameraList->ids[i].unit << " guid=" << hex << pCameraList->ids[i].guid << dec
<< "\n";
+
+ if(nCamNumber == -1 && cam_guid == pCameraList->ids[i].guid)
+ {
+ if(cam_unit == -1 || cam_unit == pCameraList->ids[i].unit)
+ nCamNumber = i;
+ }
+ }
+ }
- if(nCamNumber + 1 > pCameraList->num)
+ if(nCamNumber + 1 > (int)pCameraList->num)
{
dc1394_camera_free_list(pCameraList);
throw(All("Selected camera out of range"));
@@ -139,6 +251,10 @@
// What mode to use?
dc1394color_coding_t nTargetColourCoding =
DC_from_DV3_ColourSpace(colourspace);
+
+ dc1394_camera_reset(mpLDCP->pCamera);
+
+ log << "Target colour coding: " << nTargetColourCoding << " (" <<
coding(nTargetColourCoding) << ")\n";
bool foundAStandardMode = false;
dc1394video_mode_t nMode;
mColourfilter = UNDEFINED;
@@ -244,6 +360,8 @@
}
}
if(!foundAStandardMode){
+ log << "Failed to find a standard mode. Using FORMAT_7\n";
+
dc1394format7modeset_t modeset;
error = dc1394_format7_get_modeset(mpLDCP->pCamera, &modeset);
if(error) throw(All("Could not get Format 7 modes."));
@@ -252,20 +370,52 @@
mirOffset = ImageRef(0,0);
else
mirOffset = irOffset;
- for(; index < DC1394_VIDEO_MODE_FORMAT7_NUM; ++index){
+ for(; index < DC1394_VIDEO_MODE_FORMAT7_NUM ; ++index){
const dc1394format7mode_t & mode = modeset.mode[index];
- // does the mode exist ?
+
+ log << " FORMAT_7 mode index " << index << "\n";
+ log << " present: " << mode.present <<
"\n";
if(!mode.present) continue;
+ log << " size: " << mode.size_x << "x"
<< mode.size_y << "\n";
+ log << " max size: " << mode.max_size_x <<
"x" << mode.max_size_y << "\n";
+ log << " position?: " << mode.pos_x << "x"
<< mode.pos_y << "\n";
+ log << " unit size: " << mode.unit_size_x <<
"x" << mode.unit_size_y << "\n";
+ log << " unit pos: " << mode.unit_pos_x <<
"x" << mode.unit_pos_y << "\n";
+ log << " color codings: " <<
mode.color_codings.num << "\n";
+
+ for(unsigned int i=0; i < mode.color_codings.num; i++)
+ log << " color: " <<
mode.color_codings.codings[i] << "(" << coding(mode.color_codings.codings[i])
<< ")\n";
+ log << " color: " << mode.color_coding << "("
<< coding(mode.color_coding) << ")\n";
+
+ log << " pixnum: " << mode.pixnum << "\n";
+ log << " packet size: " << mode.packet_size <<
"\n";
+ log << " unit pkt size: " <<
mode.unit_packet_size << "\n";
+ log << " max pkt size: " <<
mode.max_packet_size << "\n";
+ log << " total bytes: " << mode.total_bytes <<
"\n";
+ log << " color filter: " << mode.color_filter
<< "(" << filter(mode.color_filter) << ")\n";
+
+ // does the mode exist ?
// does it support the colour format we need ?
unsigned int i;
for(i = 0; i < mode.color_codings.num; ++i)
+ {
if(mode.color_codings.codings[i] ==
nTargetColourCoding)
break;
- if(i == mode.color_codings.num) continue;
+ }
+
+ if(i == mode.color_codings.num)
+ {
+ log << " No matching mode\n";
+ continue;
+ }
if(irSize.x != -1){
// can it support the size ?
if((irSize.x + mirOffset.x) >
(int)mode.max_size_x || (irSize.y + mirOffset.y) > (int)mode.max_size_y ||
irSize.x % mode.unit_size_x != 0 || irSize.y % mode.unit_size_y != 0)
+ {
+ log << " Cannot support
size/offset combination\n";
continue;
+
+ }
} else {
irSize.x = mode.max_size_x;
irSize.y = mode.max_size_y;
@@ -289,6 +439,7 @@
// frame rate calculations
int num_packets = (int)(8000.0/fFrameRate + 0.5);
+ log << "Number of packes: " << num_packets << "\n";
int packet_size = (irSize.x * irSize.y * 8 + num_packets * 8 -
1 ) / (num_packets * 8);
mdFramerate = fFrameRate;
// offset calculations
@@ -299,13 +450,35 @@
mirOffset = irOffset;
}
mirSize = irSize;
- dc1394_format7_set_roi( mpLDCP->pCamera, nMode,
+ log << "Requesting:\n";
+ log << " packet size: " << packet_size << "\n";
+ log << " left: " << mirOffset.x << "\n";
+ log << " right: " << mirOffset.y << "\n";
+ log << " width: " << mirSize.x << "\n";
+ log << " height: " << mirSize.y << "\n";
+ error = dc1394_format7_set_roi( mpLDCP->pCamera, nMode,
nTargetColourCoding,
packet_size,
mirOffset.x, //
left
mirOffset.y, //
top
mirSize.x, //
width
mirSize.y);
// height
+
+ uint32_t pkt_size, offx, offy, posx, posy;
+ error = dc1394_format7_get_roi( mpLDCP->pCamera, nMode,
+
&nTargetColourCoding,
+ &pkt_size,
+ &offx, // left
+ &offy, // top
+ &posx, // width
+ &posy); //
height
+ log << "Got:\n";
+ log << " packet size: " << pkt_size << "\n";
+ log << " left: " << offx << "\n";
+ log << " right: " << offy << "\n";
+ log << " width: " << posx << "\n";
+ log << " height: " << posy << "\n";
+ log << error << "\n";
dc1394color_filter_t filterType;
error = dc1394_format7_get_color_filter(mpLDCP->pCamera, nMode,
&filterType);
mColourfilter = static_cast<DV3ColourFilter>(filterType -
DC1394_COLOR_FILTER_MIN);
Index: progs/video_play_source.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/progs/video_play_source.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- progs/video_play_source.cc 2 Nov 2009 16:50:26 -0000 1.5
+++ progs/video_play_source.cc 21 Jan 2010 16:48:28 -0000 1.6
@@ -53,8 +53,8 @@
//while(buffer->frame_pending())
- cout << "FPS: " << buffer->frame_rate();
- cout << "Size: " << buffer->size();
+ cout << "FPS: " << buffer->frame_rate() << endl;
+ cout << "Size: " << buffer->size() << endl;
RawVideoBuffer* root = buffer->root_buffer();
@@ -67,15 +67,28 @@
}
#endif
+ bool f=1;
+ GLWindow::EventSummary e;
for(;;)
{
+ display.get_events(e);
+ if(e.should_quit())
+ break;
+
VideoFrame<C>* frame = buffer->get_frame();
+ if(f)
+ {
+ cout << "frame size: " << frame->size() << endl;
+ f=0;
+ }
glDrawPixels(*frame);
buffer->put_frame(frame);
glFlush();
display.swap_buffers();
}
+
+ cout << "Exiting\n";
}
int main(int argc, char* argv[])
- [libcvd-members] libcvd cvd/videosource.h cvd/Linux/dvbuffer3.h ...,
Edward Rosten <=