Statistics
| Branch: | Revision:

root / rgbdslam / src / sift_gpu_feature_detector.h @ 9240aaa3

History | View | Annotate | Download (2.91 KB)

1
/* This file is part of RGBDSLAM.
2
 * 
3
 * RGBDSLAM is free software: you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation, either version 3 of the License, or
6
 * (at your option) any later version.
7
 * 
8
 * RGBDSLAM is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 * 
13
 * You should have received a copy of the GNU General Public License
14
 * along with RGBDSLAM.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16

    
17

    
18
#ifndef SIFT_GPU_FEATURE_DETECTOR_H
19
#define SIFT_GPU_FEATURE_DETECTOR_H
20

    
21
//#ifdef USE_SIFT_GPU
22
#include <opencv2/features2d/features2d.hpp>
23
#include <opencv/cv.h>
24
#include <SiftGPU/SiftGPU.h>
25

    
26
/*!
27
 * \brief Interface for SiftGPU
28
 * The class is used as an interface to SiftGPU.
29
 * It's a singleton class
30
 */
31
class SiftGPUFeatureDetector {
32
public:
33
    /*!
34
     * Destructor
35
     */
36
        virtual ~SiftGPUFeatureDetector();
37

    
38
        /*!
39
         * Main method, which is used for calculating the features and descriptors.
40
         * The first parameter is the image, the second one a reference to a keypoint vector
41
         * and the third parameter can be used for defining a mask
42
         *
43
         * \param  image        the image
44
         * \param  keypoints    a cv::vector of cv::Keypoints, which is used for storing the keypoints
45
         * \param  mask         a mask (see OpenCV)
46
         * \return a pointer to the descriptor values
47
         */
48
        float* detect( const cv::Mat& image, cv::vector<cv::KeyPoint>& keypoints, const cv::Mat& mask = cv::Mat()) const;
49

    
50
        /*!
51
         * Return instance of the singleton class
52
         */
53
        static SiftGPUFeatureDetector* GetInstance();
54
        static void DestroyInstance();
55

    
56
private:
57
        /*!
58
         * private constructor, because of singleton
59
         */
60
        SiftGPUFeatureDetector();
61

    
62
        /*!
63
         * Building a siftgpu compatible unsigned char pointer out of the image cv::Mat
64
         * (converts a cv matrix into an OpenGL texture array)
65
         *
66
         * \param  image        the image
67
         * \param  siftImage    the transformed image (output)
68
         */
69
        void CVMatToSiftGPU(const cv::Mat& image, unsigned char* siftImage) const;
70

    
71
        /*!
72
         * For testing purposes: write a .pgm file of the SiftGPU image
73
         *
74
         * \param   fp      a filepointer
75
         * \param   data    the imagedata (e.g. OpenGL texture)
76
         * \param   width   width
77
         * \param   height  height
78
         */
79
        void WritePGM(FILE *fp, unsigned char* data, int width, int height);
80

    
81
        static const int imageWidth = 640;          ///<width of the image constant for Kinect
82
        static const int imageHeight = 480;         ///<height of the image constant for Kinect
83

    
84
        static SiftGPUFeatureDetector* instance;    ///<singleton instance
85
        SiftGPU* siftgpu;                           ///<siftgpu instance
86
        bool error;                                 ///<error happened?
87
        unsigned char* data;                        ///<image as texture
88
};
89

    
90
#endif
91
//#endif