123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * @file LocalFeatureSift.h
- * @brief local feature with sift
- * @author Erik Rodner
- * @date 03/10/2012 (Eric Bach)
- * @note some notes to the use of siftGPU (added by Eric Bach)
- * - install cudaSift & siftGPU (see Makefile.config)
- * - add to libdepend.inc: $(call PKG_DEPEND_EXT, CUDASIFT) to specify: -DNICE_USELIB_CUDASIFT as compilerflag
- * - add to section [LFSiftPP] use_siftgpu=true (or 'false' to disable the gpu-support)
- *
- * If you use the gpu-support just one device is supported until now.
- * If your device do not support the siftGPU completly the class switch to "normal" sift.
- * It is possible to compile this class without siftGPU, but then you must not specify the flag: -DNICE_USELIB_CUDASIFT.
- */
- #ifndef LOCALFEATURESIFTINCLUDE
- #define LOCALFEATURESIFTINCLUDE
- // NICE includes
- #include <objrec/baselib/StringTools.h>
- #include <objrec/baselib/Config.h>
- #include "LocalFeature.h"
- #include "sift.h"
- // std includes
- #include <iostream>
- #include <string>
- #include <stdexcept>
- // SiftGPU & GL
- #ifdef NICE_USELIB_CUDASIFT
- #include <src/SiftGPU.h>
- #include <GL/gl.h>
- #endif
- namespace OBJREC {
- /** local feature with sift */
- class LocalFeatureSift : public LocalFeature
- {
- private:
- const Config* conf;
- protected:
- int octaves;
- int levels;
- bool normalizeFeature;
- int first_octave;
- double magnif;
- bool deletemode;
- bool integerValues;
- // for SiftGPU
- bool usegpu;
- float threshold;
- float edgeThreshold;
- void withPP( const NICE::Image & img, VVector & positions, VVector & descriptors ) const;
- #ifdef NICE_USELIB_CUDASIFT
- void withGPU( const NICE::Image & img, VVector & positions, VVector & descriptors ) const;
- #endif
- public:
- /** simple constructor */
- LocalFeatureSift ( const Config *conf );
- /** simple destructor */
- virtual ~LocalFeatureSift();
- /**
- * returns the size of each the SIFT-Feature
- * @return 128
- */
- int getDescSize() const {
- return 128;
- };
- //! returns true if gpu is used
- bool isGpuUsed() const {
- #ifdef NICE_USELIB_CUDASIFT
- return usegpu;
- #else
- return false;
- #endif
- };
- /**
- * get the descriptor
- * @param img input image
- * @param positions positions for the SIFT features
- * @param descriptors output
- * @return 0
- */
- virtual int getDescriptors ( const NICE::Image & img,
- VVector & positions,
- VVector & descriptors ) const;
- /**
- * computes the descriptor for a single image
- * @param img
- * @param positions
- * @param descriptors
- */
- void computeDesc( const NICE::Image & img, VVector & positions, VVector & descriptors ) const;
- /**
- * sort positions by scales for faster computing of the Keypoint orientation
- * @param positions
- */
- void sortPositions(VVector & positions) const;
- void visualizeFeatures ( NICE::Image & mark, const VVector & positions, size_t color ) const;
- };
- } // namespace
- #endif
|