diff --git a/.cproject b/.cproject deleted file mode 100644 index 2c3a1fde..00000000 --- a/.cproject +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 6f925d95..00000000 --- a/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -config.dep_progs -config.dep_testprogs -config.dep_tmp -config.have_bits -config.status -Makefile -libcvd_debug.a -libcvd.a -.sourcefiles -.deps -debug diff --git a/.project b/.project deleted file mode 100644 index 0b3d2fe1..00000000 --- a/.project +++ /dev/null @@ -1,79 +0,0 @@ - - - libcvd - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/cvd/config.h b/cvd/config.h deleted file mode 100644 index a3384165..00000000 --- a/cvd/config.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef CVD_CONFIG_H -#define CVD_CONFIG_H -#define CVD_ARCH_LITTLE_ENDIAN 1 -#ifndef CVD_DISABLE_CPU_i386 - #define CVD_HAVE_CPU_i386 1 -#endif -#ifndef CVD_DISABLE_GLOB - #define CVD_HAVE_GLOB 1 -#endif -#ifndef CVD_DISABLE_INLINE_ASM - #define CVD_HAVE_INLINE_ASM 1 -#endif -#ifndef CVD_DISABLE_LAPACK - #define CVD_HAVE_LAPACK 1 -#endif -#ifndef CVD_DISABLE_MEMALIGN - #define CVD_HAVE_MEMALIGN 1 -#endif -#ifndef CVD_DISABLE_MMX - #define CVD_HAVE_MMX 1 -#endif -#ifndef CVD_DISABLE_MMXEXT - #define CVD_HAVE_MMXEXT 1 -#endif -#ifndef CVD_DISABLE_PNG - #define CVD_HAVE_PNG 1 -#endif -#ifndef CVD_DISABLE_PTHREAD - #define CVD_HAVE_PTHREAD 1 -#endif -#ifndef CVD_DISABLE_PTHREAD_YIELD_NP - #define CVD_HAVE_PTHREAD_YIELD_NP 1 -#endif -#ifndef CVD_DISABLE_SSE - #define CVD_HAVE_SSE 1 -#endif -#ifndef CVD_DISABLE_SSE2 - #define CVD_HAVE_SSE2 1 -#endif -#ifndef CVD_DISABLE_SSE3 - #define CVD_HAVE_SSE3 1 -#endif -#ifndef CVD_DISABLE_TOON - #define CVD_HAVE_TOON 1 -#endif -#ifndef CVD_DISABLE_TR1_SHARED_PTR - #define CVD_HAVE_TR1_SHARED_PTR 1 -#endif -#ifndef CVD_DISABLE_VIDEODISPLAY - #define CVD_HAVE_VIDEODISPLAY 1 -#endif -#ifndef CVD_DISABLE_HALFSAMPLE_SSE16 - #define CVD_INTERNAL_HAVE_HALFSAMPLE_SSE16 1 -#endif -#ifndef CVD_DISABLE_YV402P_MMX - #define CVD_INTERNAL_HAVE_YV402P_MMX 1 -#endif -#define CVD_MAJOR_VERSION 0 -#define CVD_MINOR_VERSION 8 -#endif diff --git a/cvd/convolution.h b/cvd/convolution.h index b946c337..83b04038 100644 --- a/cvd/convolution.h +++ b/cvd/convolution.h @@ -520,7 +520,7 @@ template void convolveGaussian(const BasicImage& I, BasicImage& void compute_van_vliet_b(double sigma, double b[]); void compute_triggs_M(const double b[], double M[][3]); -void van_vliet_blur(const double b[], const BasicImage in, BasicImage out); +void van_vliet_blur(const double b[], const SubImage in, SubImage out); void convolveGaussian(const BasicImage& I, BasicImage& out, double sigma, double sigmas=3.0); void convolveGaussian_fir(const BasicImage& I, BasicImage& out, double sigma, double sigmas=3.0); diff --git a/cvd/draw.h b/cvd/draw.h index a1cffd08..4d930384 100644 --- a/cvd/draw.h +++ b/cvd/draw.h @@ -124,7 +124,7 @@ template struct color { /// @param c color of the line /// @ingroup gGraphics template -void drawLine(BasicImage& im, double x1, double y1, double x2, double y2, const T& c) +void drawLine(SubImage& im, double x1, double y1, double x2, double y2, const T& c) { double dx = x2-x1; double dy = y2-y1; @@ -146,7 +146,7 @@ void drawLine(BasicImage& im, double x1, double y1, double x2, double y2, con /// @param c color of the line /// @ingroup gGraphics template -void drawLine(BasicImage& im, const ImageRef& p1, const ImageRef& p2, const T& c) +void drawLine(SubImage& im, const ImageRef& p1, const ImageRef& p2, const T& c) { drawLine(im, double(p1.x), double(p1.y), double(p2.x), double(p2.y), c); } @@ -159,7 +159,7 @@ void drawLine(BasicImage& im, const ImageRef& p1, const ImageRef& p2, const T /// @param c color of the line /// @ingroup gGraphics template -void drawLine(BasicImage& im, const TooN::Vector<2>& p1, const TooN::Vector<2>& p2, const T& c) +void drawLine(SubImage& im, const TooN::Vector<2>& p1, const TooN::Vector<2>& p2, const T& c) { drawLine(im, p1[0], p1[1], p2[0], p2[1], c); } @@ -175,7 +175,7 @@ void drawLine(BasicImage& im, const TooN::Vector<2>& p1, const TooN::Vector<2 /// @param c color of the line /// @ingroup gGraphics template -void drawShape(BasicImage& im, const ImageRef& offset, const std::vector& points, const T& c) +void drawShape(SubImage& im, const ImageRef& offset, const std::vector& points, const T& c) { for (unsigned int i=0; i& im, const ImageRef& offset, /// @param c color of the box /// @ingroup gGraphics template -void drawBox(BasicImage &im, const ImageRef & upperleft, const ImageRef & lowerright, const T& c) +void drawBox(SubImage &im, const ImageRef & upperleft, const ImageRef & lowerright, const T& c) { drawLine(im, upperleft.x, upperleft.y, upperleft.x, lowerright.y, c); drawLine(im, upperleft.x, upperleft.y, lowerright.x, upperleft.y, c); @@ -228,7 +228,7 @@ void drawBox(BasicImage &im, const ImageRef & upperleft, const ImageRef & low /// @param c color of the box /// @ingroup gGraphics template -void drawCross(BasicImage& im, const ImageRef& p, double len, const T& c) +void drawCross(SubImage& im, const ImageRef& p, double len, const T& c) { drawLine(im, p.x-len, p.y, p.x+len, p.y, c); drawLine(im, p.x, p.y-len, p.x, p.y+len, c); diff --git a/cvd/fast_corner.h b/cvd/fast_corner.h index 99606441..3dbbe343 100644 --- a/cvd/fast_corner.h +++ b/cvd/fast_corner.h @@ -60,7 +60,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_7(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_7(const SubImage& i, const std::vector& corners, int b, std::vector& scores); /// Perform tree based 8 point FAST feature detection. This is more like an edge detector. @@ -80,7 +80,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_8(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_8(const SubImage& i, const std::vector& corners, int b, std::vector& scores); /** Perform tree based 9 point FAST feature detection as described in: @@ -113,7 +113,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_9(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_9(const SubImage& i, const std::vector& corners, int b, std::vector& scores); ///Perform FAST-9 corner detection (see @ref fast_corner_detect_9), with nonmaximal @@ -142,7 +142,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_10(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_10(const SubImage& i, const std::vector& corners, int b, std::vector& scores); /// Perform tree based 11 point FAST feature detection /// If you use this, please cite the paper given in @ref fast_corner_detect_9 @@ -161,7 +161,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_11(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_11(const SubImage& i, const std::vector& corners, int b, std::vector& scores); /// Perform tree based 12 point FAST feature detection /// If you use this, please cite the paper given in @ref fast_corner_detect_9 @@ -180,7 +180,7 @@ namespace CVD /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the /// quickest results, but any lower value (e.g. 0) will produce correct results. /// @ingroup gVision - void fast_corner_score_12(const BasicImage& i, const std::vector& corners, int b, std::vector& scores); + void fast_corner_score_12(const SubImage& i, const std::vector& corners, int b, std::vector& scores); diff --git a/cvd/gl_helpers.h b/cvd/gl_helpers.h index d0a1f795..c59d8025 100644 --- a/cvd/gl_helpers.h +++ b/cvd/gl_helpers.h @@ -527,7 +527,7 @@ namespace CVD /// Use glRasterPos to set the current raster position /// @param i The image to draw ///@ingroup gGL - template inline void glDrawPixels(const BasicImage& i) + template inline void glDrawPixels(const SubImage& i) { ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.row_stride()); @@ -559,7 +559,7 @@ namespace CVD /// note the reordering of the various parameters to make better use of default parameters /// @param i the image to set as texture /// @ingroup gGL - template inline void glTexBasicImage2D( const BasicImage &i, GLint xoffset = 0, GLint yoffset = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0) + template inline void glTexSubImage2D( const SubImage &i, GLint xoffset = 0, GLint yoffset = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0) { ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.row_stride()); @@ -571,7 +571,7 @@ namespace CVD /// note the reordering of the various parameters to make better use of default parameters /// @param i the image to set as texture /// @ingroup gGL - template inline void glTexImage2D( const BasicImage &i, GLint border = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0) + template inline void glTexImage2D( const SubImage &i, GLint border = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0) { ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.row_stride()); diff --git a/cvd/image.h b/cvd/image.h index 339f7e94..5bd524f2 100644 --- a/cvd/image.h +++ b/cvd/image.h @@ -125,13 +125,13 @@ namespace ImageUtil } } -template class BasicImage; +template class SubImage; -template class ConstBasicImageIterator +template class ConstSubImageIterator { public: - const ConstBasicImageIterator& operator++() + const ConstSubImageIterator& operator++() { ptr++; if(ptr == row_end) @@ -149,11 +149,11 @@ template class ConstBasicImageIterator { operator++(); } - + const T* operator->() const { return ptr; } const T& operator*() const { return *ptr;} - bool operator<(const ConstBasicImageIterator& s) const + bool operator<(const ConstSubImageIterator& s) const { //It's illegal to iterate _past_ end(), so < is equivalent to != //for end iterators. @@ -167,12 +167,12 @@ template class ConstBasicImageIterator return ptr < s.ptr; } - bool operator==(const ConstBasicImageIterator& s) const + bool operator==(const ConstSubImageIterator& s) const { return !((*this)!=s); } - bool operator!=(const ConstBasicImageIterator& s) const + bool operator!=(const ConstSubImageIterator& s) const { if(is_end && s.is_end) return 0; @@ -194,10 +194,10 @@ template class ConstBasicImageIterator - ConstBasicImageIterator() + ConstSubImageIterator() {} - ConstBasicImageIterator(const T* start, int image_width, int row_stride, const T* off_end) + ConstSubImageIterator(const T* start, int image_width, int row_stride, const T* off_end) :ptr(const_cast(start)), row_end(start + image_width), end(off_end), @@ -207,7 +207,7 @@ template class ConstBasicImageIterator { } //Prevent automatic conversion from a pointer (ie Image::iterator) - explicit ConstBasicImageIterator(const T* end) + explicit ConstSubImageIterator(const T* end) :ptr(const_cast(end)),is_end(1),row_increment(0),total_width(0) { } @@ -218,25 +218,25 @@ template class ConstBasicImageIterator int row_increment, total_width; }; -template class BasicImageIterator: public ConstBasicImageIterator +template class SubImageIterator: public ConstSubImageIterator { public: - BasicImageIterator(T* start, int image_width, int row_stride, const T* off_end) - :ConstBasicImageIterator(start, image_width, row_stride, off_end) + SubImageIterator(T* start, int image_width, int row_stride, const T* off_end) + :ConstSubImageIterator(start, image_width, row_stride, off_end) {} - explicit BasicImageIterator(T* end) - :ConstBasicImageIterator(end) + explicit SubImageIterator(T* end) + :ConstSubImageIterator(end) { } - BasicImageIterator() + SubImageIterator() {} typedef T* pointer; typedef T& reference; - T* operator->() { return ConstBasicImageIterator::ptr; } - T& operator*() { return *ConstBasicImageIterator::ptr;} + T* operator->() { return ConstSubImageIterator::ptr; } + T& operator*() { return *ConstSubImageIterator::ptr;} }; /// A generic image class to manage a block of arbitrarily padded data as an image. Provides @@ -249,14 +249,14 @@ template class BasicImageIterator: public ConstBasicImageIterator /// arbitrary externally-managed block of data as though it were an image. Use /// the derived Image class if you want an image which also has its own data. /// @ingroup gImage -template class BasicImage +template class SubImage { public: /// Construct an image from a block of data. /// @param data The image data in horizontal scanline order /// @param size The size of the image /// @param stride The row stride (or width, including the padding) - BasicImage(T* data, const ImageRef& size, int stride = size.x) + SubImage(T* data, const ImageRef& size, int stride) :my_data(data),my_size(size),my_stride(stride) { } @@ -278,7 +278,7 @@ template class BasicImage } /// The image data is not destroyed when a BasicImage is destroyed. - ~BasicImage() + ~SubImage() {} /// Access a pixel from the image. Bounds checking is only performed if the library is compiled @@ -338,8 +338,8 @@ template class BasicImage return my_data; } - typedef BasicImageIterator iterator; - typedef ConstBasicImageIterator const_iterator; + typedef SubImageIterator iterator; + typedef ConstSubImageIterator const_iterator; /// The data type of the pixels in the image. typedef T value_type; @@ -347,28 +347,28 @@ template class BasicImage /// Returns an iterator referencing the first (top-left) pixel in the image inline iterator begin() { - return iterator(data(), size().x, my_stride, end_ptr()); + return SubImageIterator(data(), size().x, my_stride, end_ptr()); } /// Returns a const iterator referencing the first (top-left) pixel in the image inline const_iterator begin() const { - return const_iterator(data(), size().x, my_stride, end_ptr()); + return ConstSubImageIterator(data(), size().x, my_stride, end_ptr()); } /// Returns an iterator pointing to one past the end of the image inline iterator end() { //Operator [] would always throw here! - return iterator(end_ptr()); + return SubImageIterator(end_ptr()); } /// Returns a const iterator pointing to one past the end of the image inline const_iterator end() const { //Operator [] would always throw here! - return const_iterator(end_ptr()); + return ConstSubImageIterator(end_ptr()); } - inline void copy_from( const BasicImage & other ){ + inline void copy_from( const SubImage & other ){ CVD_IMAGE_ASSERT(other.size() == this->size(), Exceptions::Image::IncompatibleImageSizes); std::copy(other.begin(), other.end(), this->begin()); } @@ -407,7 +407,7 @@ template class BasicImage /// Copy constructor /// @param copyof The image to copy - BasicImage(const BasicImage& copyof) + SubImage(const SubImage& copyof) { my_size = copyof.my_size; my_data = copyof.my_data; @@ -418,29 +418,27 @@ template class BasicImage /// Return a sub image /// @param start Top left pixel of the sub image /// @param size width and height of the sub image - BasicImage sub_image(const ImageRef& start, const ImageRef& size) + SubImage sub_image(const ImageRef& start, const ImageRef& size) { CVD_IMAGE_ASSERT(in_image(start), ImageError::AccessOutsideImage); CVD_IMAGE_ASSERT(in_image(start + size - ImageRef(1,1)), ImageError::AccessOutsideImage); - - T* ptr = my_data + start.y * my_stride + start.x; - return BasicImage(ptr, size, my_stride); + return SubImage( &operator[](start), size, my_stride); } /// Return const a sub image /// @param start Top left pixel of the sub image /// @param size width and height of the sub image - const BasicImage sub_image(const ImageRef& start, const ImageRef& size) const + const SubImage sub_image(const ImageRef& start, const ImageRef& size) const { CVD_IMAGE_ASSERT(in_image(start), ImageError::AccessOutsideImage); CVD_IMAGE_ASSERT(in_image(start + size - ImageRef(1,1)), ImageError::AccessOutsideImage); - T* ptr = my_data + start.y * my_stride + start.x; - return BasicImage(ptr, size, my_stride); + T*ptr = my_data + start.y * my_stride + start.x; + return SubImage(ptr, size, my_stride); } /// Return a reference to a SubImage. Useful for passing anonymous SubImages to functions. - BasicImage& ref() + SubImage& ref() { return *this; } @@ -456,14 +454,12 @@ template class BasicImage ///Return an off-the-end pointer without ever throwing AccessOutsideImage const T* end_ptr() const { return my_data+my_size.y*my_stride; } - BasicImage() + SubImage() {} }; -#if 0 - /// A generic image class to manage a block of data as an image. Provides /// basic image access such as accessing a particular pixel co-ordinate. /// @param T The pixel type for this image. Typically either @@ -535,6 +531,7 @@ template class BasicImage: public SubImage iterator end() { return SubImage::my_data+SubImage::totalsize(); } + protected: /// The default constructor does nothing BasicImage() @@ -542,7 +539,6 @@ template class BasicImage: public SubImage private: }; -#endif /** An input iterator which just returns N copies of the same value over and over again. This can be used for construction @@ -679,6 +675,19 @@ class Image: public BasicImage std::copy(copy.begin(), copy.end(), this->begin()); } + + + + ///Make a (new) copy of the image, also making a copy of the data + ///@param copy The image to copy + void copy_from(const SubImage& copy) + { + Image tmp(copy.size()); + *this = tmp; + + std::copy(copy.begin(), copy.end(), this->begin()); + } + ///Make this image independent of any copies (i.e. force a copy of the image data). void make_unique() { diff --git a/cvd/image_convert.h b/cvd/image_convert.h index 9d851bbb..13138da7 100644 --- a/cvd/image_convert.h +++ b/cvd/image_convert.h @@ -32,7 +32,7 @@ namespace CVD // The most general case: one row at a time template ::type, int both_pod=Internal::is_POD::is_pod && Internal::is_POD::is_pod> struct ConvertImage { - static void convert(const BasicImage& from, BasicImage& to) { + static void convert(const SubImage& from, SubImage& to) { for (int r=0; r::convert(from[r], to[r], from.size().x); }; @@ -40,29 +40,36 @@ namespace CVD // The blat case: memcpy all data at once template struct ConvertImage,1> { - static void convert(const BasicImage& from, BasicImage& to) { + static void convert(const SubImage& from, SubImage& to) { memcpy(to.data(), from.data(), from.totalsize() * sizeof(T)); }; }; template <> struct ConvertImage, byte, Pixel::CIE, byte>, 1> { - static void convert(const BasicImage >& from, BasicImage& to); + static void convert(const SubImage >& from, SubImage& to); }; - template void convert_image(const BasicImage& from, BasicImage& to) + template void convert_image(const SubImage& from, SubImage& to) { if (from.size() != to.size()) throw Exceptions::Image::IncompatibleImageSizes(__FUNCTION__); ConvertImage::convert(from, to); } - template