24 #include <fvutils/colormap/cmfile.h> 26 #include <fvutils/colormap/colormap.h> 27 #include <fvutils/colormap/cmfile_yuvblock.h> 29 #include <fvutils/colormap/yuvcm.h> 30 #include <core/exception.h> 32 #include <sys/utsname.h> 51 for (iterator i = begin(); i != end(); ++i) {
75 __header->
depth = depth;
76 __header->
width = width;
113 if ( (colormap->
depth() != __header->
depth) ||
116 throw fawkes::Exception(
"Colormap dimensions %dx%dx%d do not match expected dimensions %dx%dx%d",
121 printf(
"Adding colormap with dimensions %dx%dx%d\n", colormap->
width(), colormap->
height(), colormap->
depth());
124 for (std::list<ColormapFileBlock *>::iterator i = blocks.begin(); i != blocks.end(); ++i) {
138 for (std::list<FireVisionDataFileBlock *>::iterator i = b.begin(); i != b.end(); ++i) {
139 if ((*i)->type() == CMFILE_TYPE_YUV ) {
150 ColormapFile::assert_header()
154 throw fawkes::Exception(
"Cannot get header information, invalid ctor used or file not read?");
175 for (BlockList::iterator b = bl.begin(); b != bl.end(); ++b) {
176 if ( (*b)->type() != CMFILE_TYPE_YUV ) {
188 unsigned int level = 0;
189 for (BlockList::iterator b = bl.begin(); b != bl.end(); ++b) {
190 if ( (*b)->data_size() != cm->
plane_size() ) {
196 cm->
copy_uvplane((
unsigned char *)(*b)->data_ptr(), level++);
222 std::string rv = format;
224 struct utsname uname_info;
225 uname( &uname_info );
227 size_t loc = rv.find(
"%h" );
228 while (loc != std::string::npos) {
229 rv.replace( loc, 2, uname_info.nodename );
230 loc = rv.find(
"%h" );
252 return __header->
depth;
262 return __header->
width;
size_t _spec_header_size
Size in bytes of _spec_header.
void add_colormap(Colormap *colormap)
Add colormap.
virtual void add_block(FireVisionDataFileBlock *block)
Add a block.
virtual unsigned int depth() const =0
Get depth of colormap.
~ColormapBlockVector()
Destructor.
void copy_uvplane(unsigned char *uvplane, unsigned int level)
Copy single U/V plane.
uint16_t get_depth()
Get depth of colormap.
std::list< FireVisionDataFileBlock * > BlockList
List of FireVision data file blocks.
virtual unsigned int height() const =0
Get height of colormap.
YUV block for colormap file.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
virtual std::list< ColormapFileBlock * > get_blocks()=0
Get file blocks for this colormap.
uint16_t get_height()
Get height of colormap.
ColormapFile()
Constructor.
static bool has_magic_token(const char *filename, unsigned short int magic_token)
Check if file has a certain magic token.
Base class for exceptions in Fawkes.
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
void * _spec_header
Content specific header.
Vector of colormap blocks.
virtual void clear()
Clear internal storage.
FireVision File Format for data files.
virtual unsigned int width() const =0
Get width of colormap.
static std::string compose_filename(const std::string format)
Compose filename.
static bool is_colormap_file(const char *filename)
Check if given file is a colormap file.
uint16_t get_width()
Get width of colormap.
virtual void clear()
Clear internal storage.
unsigned int plane_size() const
Get U/V plane size.
BlockList & blocks()
Get blocks.