Commit 21ef00f2 authored by Manuel Günther's avatar Manuel Günther

Based package on bob.io.base; Removed dependency on bob-io.

parent 2f203d4f
......@@ -17,7 +17,7 @@
#include <boost/algorithm/string.hpp>
#include <string>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
// The following documentation is mostly coming from wikipedia:
// http://en.wikipedia.org/wiki/BMP_file_format
......@@ -601,7 +601,7 @@ static boost::shared_ptr<std::FILE> make_cfile(const char *filename, const char
/**
* LOADING
*/
static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
static void im_peek(const std::string& path, bob::io::base::array::typeinfo& info) {
// 1. BMP structures
bmp_header_t bmp_hdr;
bmp_dib_header_t bmp_dib_hdr;
......@@ -621,7 +621,7 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
throw std::runtime_error("bmp: error while parsing bmp header (current file position does not match the offset value indicating where the data is stored)");
// 5. Set depth and number of dimensions
info.dtype = bob::core::array::t_uint8;
info.dtype = bob::io::base::array::t_uint8;
info.nd = 3;
info.shape[0] = 3;
info.shape[1] = bmp_dib_hdr.height;
......@@ -629,7 +629,7 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
info.update_strides();
}
static void im_load(const std::string& filename, bob::core::array::interface& b) {
static void im_load(const std::string& filename, bob::io::base::array::interface& b) {
// 1. BMP structures
bmp_header_t bmp_hdr;
bmp_dib_header_t bmp_dib_hdr;
......@@ -651,7 +651,7 @@ static void im_load(const std::string& filename, bob::core::array::interface& b)
bmp_read_raster(in_file.get(), &bmp_dib_hdr, n_bytes_per_row, rasterdata.get());
// 6. Convert data using the color map and put it in the RGB buffer
const bob::core::array::typeinfo& info = b.type();
const bob::io::base::array::typeinfo& info = b.type();
long unsigned int frame_size = info.shape[1] * info.shape[2];
uint8_t *element_r = static_cast<uint8_t*>(b.ptr());
uint8_t *element_g = element_r+frame_size;
......@@ -863,9 +863,9 @@ static void bmp_write_dib_header(FILE * out_file, size_t height, size_t width)
}
// Save images in Windows V1 format with a 24 bits depth (without color map)
static void im_save_color(const bob::core::array::interface& b, FILE * out_file)
static void im_save_color(const bob::io::base::array::interface& b, FILE * out_file)
{
const bob::core::array::typeinfo& info = b.type();
const bob::io::base::array::typeinfo& info = b.type();
size_t height = info.shape[1];
size_t width = info.shape[2];
......@@ -905,14 +905,14 @@ static void im_save_color(const bob::core::array::interface& b, FILE * out_file)
}
}
static void im_save(const std::string& filename, const bob::core::array::interface& array) {
const bob::core::array::typeinfo& info = array.type();
static void im_save(const std::string& filename, const bob::io::base::array::interface& array) {
const bob::io::base::array::typeinfo& info = array.type();
// 1. BMP file opening
boost::shared_ptr<std::FILE> out_file = make_cfile(filename.c_str(), "wb");
// 2. Write image
if(info.dtype == bob::core::array::t_uint8) {
if(info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 3) {
if(info.shape[0] != 3) throw std::runtime_error("color image does not have 3 planes on 1st. dimension");
im_save_color(array, out_file.get());
......@@ -930,7 +930,7 @@ static void im_save(const std::string& filename, const bob::core::array::interfa
}
}
class ImageBmpFile: public bob::io::File {
class ImageBmpFile: public bob::io::base::File {
public: //api
......@@ -965,11 +965,11 @@ class ImageBmpFile: public bob::io::File {
return m_filename.c_str();
}
virtual const bob::core::array::typeinfo& type_all() const {
virtual const bob::io::base::array::typeinfo& type_all() const {
return m_type;
}
virtual const bob::core::array::typeinfo& type() const {
virtual const bob::io::base::array::typeinfo& type() const {
return m_type;
}
......@@ -981,11 +981,11 @@ class ImageBmpFile: public bob::io::File {
return s_codecname.c_str();
}
virtual void read_all(bob::core::array::interface& buffer) {
virtual void read_all(bob::io::base::array::interface& buffer) {
read(buffer, 0); ///we only have 1 image in an image file anyways
}
virtual void read(bob::core::array::interface& buffer, size_t index) {
virtual void read(bob::io::base::array::interface& buffer, size_t index) {
if (m_newfile)
throw std::runtime_error("uninitialized image file cannot be read");
......@@ -998,7 +998,7 @@ class ImageBmpFile: public bob::io::File {
im_load(m_filename, buffer);
}
virtual size_t append (const bob::core::array::interface& buffer) {
virtual size_t append (const bob::io::base::array::interface& buffer) {
if (m_newfile) {
im_save(m_filename, buffer);
m_type = buffer.type();
......@@ -1010,7 +1010,7 @@ class ImageBmpFile: public bob::io::File {
throw std::runtime_error("image files only accept a single array");
}
virtual void write (const bob::core::array::interface& buffer) {
virtual void write (const bob::io::base::array::interface& buffer) {
//overwriting position 0 should always work
if (m_newfile) {
append(buffer);
......@@ -1023,7 +1023,7 @@ class ImageBmpFile: public bob::io::File {
private: //representation
std::string m_filename;
bool m_newfile;
bob::core::array::typeinfo m_type;
bob::io::base::array::typeinfo m_type;
size_t m_length;
static std::string s_codecname;
......@@ -1032,6 +1032,6 @@ class ImageBmpFile: public bob::io::File {
std::string ImageBmpFile::s_codecname = "bob.image_bmp";
boost::shared_ptr<bob::io::File> make_bmp_file (const char* path, char mode) {
boost::shared_ptr<bob::io::base::File> make_bmp_file (const char* path, char mode) {
return boost::make_shared<ImageBmpFile>(path, mode);
}
......@@ -11,7 +11,7 @@
#define BOB_IO_IMAGE_FILE_H
#include <boost/shared_ptr.hpp>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
/**
* This defines the factory method F that can create codecs of this type.
......@@ -31,11 +31,11 @@
* Returns a newly allocated File object that can read and write data to the
* file using a specific backend.
*/
boost::shared_ptr<bob::io::File> make_tiff_file (const char* path, char mode);
boost::shared_ptr<bob::io::File> make_jpeg_file (const char* path, char mode);
boost::shared_ptr<bob::io::File> make_gif_file (const char* path, char mode);
boost::shared_ptr<bob::io::File> make_netpbm_file (const char* path, char mode);
boost::shared_ptr<bob::io::File> make_png_file (const char* path, char mode);
boost::shared_ptr<bob::io::File> make_bmp_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_tiff_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_jpeg_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_gif_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_netpbm_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_png_file (const char* path, char mode);
boost::shared_ptr<bob::io::base::File> make_bmp_file (const char* path, char mode);
#endif /* BOB_IO_IMAGE_FILE_H */
......@@ -17,7 +17,7 @@
#include <boost/algorithm/string.hpp>
#include <string>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
extern "C" {
#include <gif_lib.h>
......@@ -312,13 +312,13 @@ static boost::shared_ptr<GifFileType> make_efile(const char *filename)
/**
* LOADING
*/
static void im_peek(const std::string& path, bob::core::array::typeinfo& info)
static void im_peek(const std::string& path, bob::io::base::array::typeinfo& info)
{
// 1. GIF file opening
boost::shared_ptr<GifFileType> in_file = make_dfile(path.c_str());
// 2. Set typeinfo variables
info.dtype = bob::core::array::t_uint8;
info.dtype = bob::io::base::array::t_uint8;
info.nd = 3;
info.shape[0] = 3;
info.shape[1] = in_file->SHeight;
......@@ -326,9 +326,9 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info)
info.update_strides();
}
static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::core::array::interface& b)
static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::io::base::array::interface& b)
{
const bob::core::array::typeinfo& info = b.type();
const bob::io::base::array::typeinfo& info = b.type();
const size_t height0 = info.shape[1];
const size_t width0 = info.shape[2];
const size_t frame_size = height0*width0;
......@@ -432,14 +432,14 @@ static void im_load_color(boost::shared_ptr<GifFileType> in_file, bob::core::arr
}
}
static void im_load(const std::string& filename, bob::core::array::interface& b)
static void im_load(const std::string& filename, bob::io::base::array::interface& b)
{
// 1. GIF file opening
boost::shared_ptr<GifFileType> in_file = make_dfile(filename.c_str());
// 2. Read content
const bob::core::array::typeinfo& info = b.type();
if(info.dtype == bob::core::array::t_uint8) {
const bob::io::base::array::typeinfo& info = b.type();
if(info.dtype == bob::io::base::array::t_uint8) {
if( info.nd == 3) im_load_color(in_file, b);
else {
boost::format m("GIF: cannot read object of type `%s' from file `%s'");
......@@ -457,9 +457,9 @@ static void im_load(const std::string& filename, bob::core::array::interface& b)
/**
* SAVING
*/
static void im_save_color(const bob::core::array::interface& b, boost::shared_ptr<GifFileType> out_file)
static void im_save_color(const bob::io::base::array::interface& b, boost::shared_ptr<GifFileType> out_file)
{
const bob::core::array::typeinfo& info = b.type();
const bob::io::base::array::typeinfo& info = b.type();
const int height = info.shape[1];
const int width = info.shape[2];
const size_t frame_size = height * width;
......@@ -516,16 +516,16 @@ static void im_save_color(const bob::core::array::interface& b, boost::shared_pt
#endif
}
static void im_save(const std::string& filename, const bob::core::array::interface& array)
static void im_save(const std::string& filename, const bob::io::base::array::interface& array)
{
// 1. GIF file opening
boost::shared_ptr<GifFileType> out_file = make_efile(filename.c_str());
// 2. Set the image information here:
const bob::core::array::typeinfo& info = array.type();
const bob::io::base::array::typeinfo& info = array.type();
// 3. Writes content
if(info.dtype == bob::core::array::t_uint8) {
if(info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 3) {
if(info.shape[0] != 3)
throw std::runtime_error("color image does not have 3 planes on 1st. dimension");
......@@ -545,7 +545,7 @@ static void im_save(const std::string& filename, const bob::core::array::interfa
}
class ImageGifFile: public bob::io::File {
class ImageGifFile: public bob::io::base::File {
public: //api
......@@ -580,11 +580,11 @@ class ImageGifFile: public bob::io::File {
return m_filename.c_str();
}
virtual const bob::core::array::typeinfo& type_all() const {
virtual const bob::io::base::array::typeinfo& type_all() const {
return m_type;
}
virtual const bob::core::array::typeinfo& type() const {
virtual const bob::io::base::array::typeinfo& type() const {
return m_type;
}
......@@ -596,11 +596,11 @@ class ImageGifFile: public bob::io::File {
return s_codecname.c_str();
}
virtual void read_all(bob::core::array::interface& buffer) {
virtual void read_all(bob::io::base::array::interface& buffer) {
read(buffer, 0); ///we only have 1 image in an image file anyways
}
virtual void read(bob::core::array::interface& buffer, size_t index) {
virtual void read(bob::io::base::array::interface& buffer, size_t index) {
if (m_newfile)
throw std::runtime_error("uninitialized image file cannot be read");
......@@ -613,7 +613,7 @@ class ImageGifFile: public bob::io::File {
im_load(m_filename, buffer);
}
virtual size_t append (const bob::core::array::interface& buffer) {
virtual size_t append (const bob::io::base::array::interface& buffer) {
if (m_newfile) {
im_save(m_filename, buffer);
m_type = buffer.type();
......@@ -625,7 +625,7 @@ class ImageGifFile: public bob::io::File {
throw std::runtime_error("image files only accept a single array");
}
virtual void write (const bob::core::array::interface& buffer) {
virtual void write (const bob::io::base::array::interface& buffer) {
//overwriting position 0 should always work
if (m_newfile) {
append(buffer);
......@@ -638,7 +638,7 @@ class ImageGifFile: public bob::io::File {
private: //representation
std::string m_filename;
bool m_newfile;
bob::core::array::typeinfo m_type;
bob::io::base::array::typeinfo m_type;
size_t m_length;
static std::string s_codecname;
......@@ -648,6 +648,6 @@ class ImageGifFile: public bob::io::File {
std::string ImageGifFile::s_codecname = "bob.image_gif";
boost::shared_ptr<bob::io::File> make_gif_file (const char* path, char mode) {
boost::shared_ptr<bob::io::base::File> make_gif_file (const char* path, char mode) {
return boost::make_shared<ImageGifFile>(path, mode);
}
......@@ -18,7 +18,7 @@
#include <boost/algorithm/string.hpp>
#include <string>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
#include <jpeglib.h>
......@@ -57,7 +57,7 @@ static void my_error_exit (j_common_ptr cinfo){
/**
* LOADING
*/
static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
static void im_peek(const std::string& path, bob::io::base::array::typeinfo& info) {
// 1. JPEG structures
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
......@@ -85,7 +85,7 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
}
// Set depth and number of dimensions
info.dtype = bob::core::array::t_uint8;
info.dtype = bob::io::base::array::t_uint8;
info.nd = (cinfo.output_components == 1? 2 : 3);
if(info.nd == 2)
{
......@@ -103,8 +103,8 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
}
template <typename T> static
void im_load_gray(struct jpeg_decompress_struct *cinfo, bob::core::array::interface& b) {
const bob::core::array::typeinfo& info = b.type();
void im_load_gray(struct jpeg_decompress_struct *cinfo, bob::io::base::array::interface& b) {
const bob::io::base::array::typeinfo& info = b.type();
T *element = static_cast<T*>(b.ptr());
const int row_stride = info.shape[1];
......@@ -126,8 +126,8 @@ void imbuffer_to_rgb(size_t size, const T* im, T* r, T* g, T* b) {
}
template <typename T> static
void im_load_color(struct jpeg_decompress_struct *cinfo, bob::core::array::interface& b) {
const bob::core::array::typeinfo& info = b.type();
void im_load_color(struct jpeg_decompress_struct *cinfo, bob::io::base::array::interface& b) {
const bob::io::base::array::typeinfo& info = b.type();
long unsigned int frame_size = info.shape[1] * info.shape[2];
T *element_r = static_cast<T*>(b.ptr());
......@@ -147,7 +147,7 @@ void im_load_color(struct jpeg_decompress_struct *cinfo, bob::core::array::inter
}
}
static void im_load(const std::string& filename, bob::core::array::interface& b) {
static void im_load(const std::string& filename, bob::io::base::array::interface& b) {
// 1. JPEG structures
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
......@@ -168,8 +168,8 @@ static void im_load(const std::string& filename, bob::core::array::interface& b)
jpeg_start_decompress(&cinfo);
// 6. Read content
const bob::core::array::typeinfo& info = b.type();
if(info.dtype == bob::core::array::t_uint8) {
const bob::io::base::array::typeinfo& info = b.type();
if(info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 2) im_load_gray<uint8_t>(&cinfo, b);
else if( info.nd == 3) im_load_color<uint8_t>(&cinfo, b);
else {
......@@ -195,8 +195,8 @@ static void im_load(const std::string& filename, bob::core::array::interface& b)
* SAVING
*/
template <typename T>
static void im_save_gray(const bob::core::array::interface& b, struct jpeg_compress_struct *cinfo) {
const bob::core::array::typeinfo& info = b.type();
static void im_save_gray(const bob::io::base::array::interface& b, struct jpeg_compress_struct *cinfo) {
const bob::io::base::array::typeinfo& info = b.type();
const T* element = static_cast<const T*>(b.ptr());
......@@ -220,8 +220,8 @@ void rgb_to_imbuffer(size_t size, const T* r, const T* g, const T* b, T* im) {
}
template <typename T>
static void im_save_color(const bob::core::array::interface& b, struct jpeg_compress_struct *cinfo) {
const bob::core::array::typeinfo& info = b.type();
static void im_save_color(const bob::io::base::array::interface& b, struct jpeg_compress_struct *cinfo) {
const bob::io::base::array::typeinfo& info = b.type();
long unsigned int frame_size = info.shape[1] * info.shape[2];
......@@ -243,8 +243,8 @@ static void im_save_color(const bob::core::array::interface& b, struct jpeg_comp
}
}
static void im_save (const std::string& filename, const bob::core::array::interface& array) {
const bob::core::array::typeinfo& info = array.type();
static void im_save (const std::string& filename, const bob::io::base::array::interface& array) {
const bob::io::base::array::typeinfo& info = array.type();
// 1. JPEG structures
struct jpeg_compress_struct cinfo;
......@@ -269,7 +269,7 @@ static void im_save (const std::string& filename, const bob::core::array::interf
jpeg_start_compress(&cinfo, true);
// Writes content
if(info.dtype == bob::core::array::t_uint8) {
if(info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 2) im_save_gray<uint8_t>(array, &cinfo);
else if(info.nd == 3) {
......@@ -296,7 +296,7 @@ static void im_save (const std::string& filename, const bob::core::array::interf
}
class ImageJpegFile: public bob::io::File {
class ImageJpegFile: public bob::io::base::File {
public: //api
......@@ -331,11 +331,11 @@ class ImageJpegFile: public bob::io::File {
return m_filename.c_str();
}
virtual const bob::core::array::typeinfo& type_all() const {
virtual const bob::io::base::array::typeinfo& type_all() const {
return m_type;
}
virtual const bob::core::array::typeinfo& type() const {
virtual const bob::io::base::array::typeinfo& type() const {
return m_type;
}
......@@ -347,11 +347,11 @@ class ImageJpegFile: public bob::io::File {
return s_codecname.c_str();
}
virtual void read_all(bob::core::array::interface& buffer) {
virtual void read_all(bob::io::base::array::interface& buffer) {
read(buffer, 0); ///we only have 1 image in an image file anyways
}
virtual void read(bob::core::array::interface& buffer, size_t index) {
virtual void read(bob::io::base::array::interface& buffer, size_t index) {
if (m_newfile)
throw std::runtime_error("uninitialized image file cannot be read");
......@@ -364,7 +364,7 @@ class ImageJpegFile: public bob::io::File {
im_load(m_filename, buffer);
}
virtual size_t append (const bob::core::array::interface& buffer) {
virtual size_t append (const bob::io::base::array::interface& buffer) {
if (m_newfile) {
im_save(m_filename, buffer);
m_type = buffer.type();
......@@ -376,7 +376,7 @@ class ImageJpegFile: public bob::io::File {
throw std::runtime_error("image files only accept a single array");
}
virtual void write (const bob::core::array::interface& buffer) {
virtual void write (const bob::io::base::array::interface& buffer) {
//overwriting position 0 should always work
if (m_newfile) {
append(buffer);
......@@ -389,7 +389,7 @@ class ImageJpegFile: public bob::io::File {
private: //representation
std::string m_filename;
bool m_newfile;
bob::core::array::typeinfo m_type;
bob::io::base::array::typeinfo m_type;
size_t m_length;
static std::string s_codecname;
......@@ -398,6 +398,6 @@ class ImageJpegFile: public bob::io::File {
std::string ImageJpegFile::s_codecname = "bob.image_jpeg";
boost::shared_ptr<bob::io::File> make_jpeg_file (const char* path, char mode) {
boost::shared_ptr<bob::io::base::File> make_jpeg_file (const char* path, char mode) {
return boost::make_shared<ImageJpegFile>(path, mode);
}
......@@ -17,7 +17,7 @@
#include <boost/algorithm/string.hpp>
#include <string>
#include <bob/io/File.h>
#include <bob.io.base/File.h>
extern "C" {
// This header must come last, as it brings a lot of global stuff that messes up other headers...
......@@ -42,7 +42,7 @@ static boost::shared_ptr<std::FILE> make_cfile(const char *filename, const char
/**
* LOADING
*/
static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
static void im_peek(const std::string& path, bob::io::base::array::typeinfo& info) {
struct pam in_pam;
boost::shared_ptr<std::FILE> in_file = make_cfile(path.c_str(), "r");
......@@ -75,8 +75,8 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
info.update_strides();
// Set depth
if (in_pam.bytes_per_sample == 1) info.dtype = bob::core::array::t_uint8;
else if (in_pam.bytes_per_sample == 2) info.dtype = bob::core::array::t_uint16;
if (in_pam.bytes_per_sample == 1) info.dtype = bob::io::base::array::t_uint8;
else if (in_pam.bytes_per_sample == 2) info.dtype = bob::io::base::array::t_uint16;
else {
boost::format m("unsupported image depth (%d bytes per samples) when reading file");
m % in_pam.bytes_per_sample;
......@@ -85,8 +85,8 @@ static void im_peek(const std::string& path, bob::core::array::typeinfo& info) {
}
template <typename T> static
void im_load_gray(struct pam *in_pam, bob::core::array::interface& b) {
const bob::core::array::typeinfo& info = b.type();
void im_load_gray(struct pam *in_pam, bob::io::base::array::interface& b) {
const bob::io::base::array::typeinfo& info = b.type();
T *element = static_cast<T*>(b.ptr());
tuple *tuplerow = pnm_allocpamrow(in_pam);
......@@ -112,8 +112,8 @@ void imbuffer_to_rgb(size_t size, const tuple* tuplerow, T* r, T* g, T* b) {
}
template <typename T> static
void im_load_color(struct pam *in_pam, bob::core::array::interface& b) {
const bob::core::array::typeinfo& info = b.type();
void im_load_color(struct pam *in_pam, bob::io::base::array::interface& b) {
const bob::io::base::array::typeinfo& info = b.type();
long unsigned int frame_size = info.shape[2] * info.shape[1];
T *element_r = static_cast<T*>(b.ptr());
......@@ -133,7 +133,7 @@ void im_load_color(struct pam *in_pam, bob::core::array::interface& b) {
pnm_freepamrow(tuplerow);
}
static void im_load (const std::string& filename, bob::core::array::interface& b) {
static void im_load (const std::string& filename, bob::io::base::array::interface& b) {
struct pam in_pam;
boost::shared_ptr<std::FILE> in_file = make_cfile(filename.c_str(), "r");
......@@ -144,9 +144,9 @@ static void im_load (const std::string& filename, bob::core::array::interface& b
pnm_readpaminit(in_file.get(), &in_pam, sizeof(struct pam));
#endif
const bob::core::array::typeinfo& info = b.type();
const bob::io::base::array::typeinfo& info = b.type();
if (info.dtype == bob::core::array::t_uint8) {
if (info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 2) im_load_gray<uint8_t>(&in_pam, b);
else if( info.nd == 3) im_load_color<uint8_t>(&in_pam, b);
else {
......@@ -156,7 +156,7 @@ static void im_load (const std::string& filename, bob::core::array::interface& b
}
}
else if (info.dtype == bob::core::array::t_uint16) {
else if (info.dtype == bob::io::base::array::t_uint16) {
if(info.nd == 2) im_load_gray<uint16_t>(&in_pam, b);
else if( info.nd == 3) im_load_color<uint16_t>(&in_pam, b);
else {
......@@ -177,8 +177,8 @@ static void im_load (const std::string& filename, bob::core::array::interface& b
* SAVING
*/
template <typename T>
static void im_save_gray(const bob::core::array::interface& b, struct pam *out_pam) {
const bob::core::array::typeinfo& info = b.type();
static void im_save_gray(const bob::io::base::array::interface& b, struct pam *out_pam) {
const bob::io::base::array::typeinfo& info = b.type();
const T *element = static_cast<const T*>(b.ptr());
......@@ -203,8 +203,8 @@ void rgb_to_imbuffer(size_t size, const T* r, const T* g, const T* b, tuple* tup
}
template <typename T>
static void im_save_color(const bob::core::array::interface& b, struct pam *out_pam) {
const bob::core::array::typeinfo& info = b.type();
static void im_save_color(const bob::io::base::array::interface& b, struct pam *out_pam) {
const bob::io::base::array::typeinfo& info = b.type();
long unsigned int frame_size = info.shape[2] * info.shape[1];
const T *element_r = static_cast<const T*>(b.ptr());
......@@ -223,9 +223,9 @@ static void im_save_color(const bob::core::array::interface& b, struct pam *out_
pnm_freepamrow(tuplerow);
}
static void im_save (const std::string& filename, const bob::core::array::interface& array) {
static void im_save (const std::string& filename, const bob::io::base::array::interface& array) {
const bob::core::array::typeinfo& info = array.type();
const bob::io::base::array::typeinfo& info = array.type();
struct pam out_pam;
boost::shared_ptr<std::FILE> out_file = make_cfile(filename.c_str(), "w");
......@@ -246,8 +246,8 @@ static void im_save (const std::string& filename, const bob::core::array::interf
out_pam.height = (info.nd == 2 ? info.shape[0] : info.shape[1]);
out_pam.width = (info.nd == 2 ? info.shape[1] : info.shape[2]);
out_pam.depth = (info.nd == 2 ? 1 : 3);
out_pam.maxval = (bob::core::array::t_uint8 ? 255 : 65535);
out_pam.bytes_per_sample = (info.dtype == bob::core::array::t_uint8 ? 1 : 2);
out_pam.maxval = (bob::io::base::array::t_uint8 ? 255 : 65535);
out_pam.bytes_per_sample = (info.dtype == bob::io::base::array::t_uint8 ? 1 : 2);
out_pam.format = PAM_FORMAT;
if( ext.compare(".pbm") == 0)
{
......@@ -274,7 +274,7 @@ static void im_save (const std::string& filename, const bob::core::array::interf
pnm_writepaminit(&out_pam);
// Writes content
if(info.dtype == bob::core::array::t_uint8) {
if(info.dtype == bob::io::base::array::t_uint8) {
if(info.nd == 2) im_save_gray<uint8_t>(array, &out_pam);
else if(info.nd == 3) {
......@@ -289,7 +289,7 @@ static void im_save (const std::string& filename, const bob::core::array::interf
}
else if(info.dtype == bob::core::array::t_uint16) {
else if(info.dtype == bob::io::base::array::t_uint16) {
if(info.nd == 2) im_save_gray<uint16_t>(array, &out_pam);
else if(info.nd == 3) {
......@@ -313,7 +313,7 @@ static void im_save (const std::string& filename, const bob::core::array::interf
class ImageNetpbmFile: public bob::io::File {
class ImageNetpbmFile: public bob::io::base::File {
public: //api
......@@ -347,11 +347,11 @@ class ImageNetpbmFile: public bob::io::File {
return m_filename.c_str();
}
virtual const bob::core::array::typeinfo& type_all() const {
virtual const bob::io::base::array::typeinfo& type_all() const {
return m_type;
}
virtual const bob::core::array::typeinfo& type() const {
virtual const bob::io::base::array::typeinfo& type() const {
return m_type;
}
......@@ -363,11 +363,11 @@ class ImageNetpbmFile: public bob::io::File {
return s_codecname.c_str();
}
virtual void read_all(bob::core::array::interface& buffer) {
virtual void read_all(bob::io::base::array::interface& buffer) {
read(buffer, 0); ///we only have 1 image in an image file anyways
}
virtual void read(bob::core::array::interface& buffer, size_t index) {
virtual void read(bob::io::base::array::interface& buffer, size_t index) {
if (m_newfile)
throw std::runtime_error("uninitialized image file cannot be read");
......@@ -381,7 +381,7 @@ class ImageNetpbmFile: public bob::io::File {
im_load(m_filename, buffer);
}
virtual size_t append (const bob::core::array::interface& buffer) {
virtual size_t append (const bob::io::base::array::interface& buffer) {
if (m_newfile) {
im_save(m_filename, buffer);
m_type = buffer.type();
......@@ -393,7 +393,7 @@ class ImageNetpbmFile: public bob::io::File {
throw std::runtime_error("image files only accept a single array");
}
virtual void write (const bob::core::array::interface& buffer) {
virtual void write (const bob::io::base::array::interface& buffer) {
//overwriting position 0 should always work
if (m_newfile) {
append(buffer);
......@@ -406,7 +406,7 @@ class ImageNetpbmFile: public bob::io::File {
private: //representation
std::string m_filename;
bool m_newfile;
bob::core::array::typeinfo m_type;
bob::io::base::array::typeinfo m_type;
size_t m_length;