HarrisSIFTFeatureCalculator.cpp
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: HarrisSIFTFeatureCalculator.cpp
37 // Author: Pedram Azad
38 // Date: 20.11.2007
39 // ****************************************************************************
40 
41 // ******************************************************************************************************
42 // Implementation of the paper:
43 // P. Azad, T. Asfour, R. Dillmann,
44 // "Combining Harris Interest Points and the SIFT Descriptor for Fast Scale-Invariant Object Recognition"
45 // IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS),
46 // St. Louis, USA, pp. 4275-4280, 2009.
47 // ******************************************************************************************************
48 
50 
51 #include "Image/ImageProcessor.h"
52 #include "Image/ByteImage.h"
53 #include "Math/FloatMatrix.h"
54 
58 
59 #include <math.h>
60 
61 
62 
63 static const float scale_factor = 0.75f;
64 
65 
66 
67 // ****************************************************************************
68 // Constructor / Destructor
69 // ****************************************************************************
70 
71 CHarrisSIFTFeatureCalculator::CHarrisSIFTFeatureCalculator(float fThreshold, int nLevels, int nMaxInterestPoints)
72 {
74 
75  m_nMaxInterestPoints = nMaxInterestPoints;
76  m_nLevels = nLevels;
77  m_fThreshold = fThreshold;
78  m_fMinDistance = 5.0f;
79 
81 
84 
85  m_pResultList = 0;
87  m_bTemplateList = true;
88  m_bManageMemory = true;
89 
90  m_pImage = 0;
91 }
92 
94 {
95  delete [] m_pInterestPoints;
96 }
97 
98 
99 // ****************************************************************************
100 // Methods
101 // ****************************************************************************
102 
104 {
105  return new CSIFTFeatureEntry(*((CSIFTFeatureEntry *) pFeatureEntry));
106 }
107 
108 int CHarrisSIFTFeatureCalculator::CalculateFeatures(const CByteImage *pImage, CDynamicArray *pResultList, bool bManageMemory)
109 {
110  if (pImage->type != CByteImage::eGrayScale)
111  {
112  printf("error: input image is not a grayscale image\n");
113  return -1;
114  }
115 
116  m_bTemplateList = false;
117  m_bManageMemory = bManageMemory;
118 
119  m_pResultList = pResultList;
120  m_pImage = pImage;
121 
122  FindInterestPoints(pImage, 1, m_nLevels);
123 
124  return pResultList->GetSize();
125 }
126 
128 {
129  if (pImage->type != CByteImage::eGrayScale)
130  {
131  printf("error: input image is not a grayscale image\n");
132  return -1;
133  }
134 
135  m_bTemplateList = true;
136 
137  m_pResultListTemplate = &resultList;
138  m_pImage = pImage;
139 
140  FindInterestPoints(pImage, 1, m_nLevels);
141 
142  return resultList.GetSize();
143 }
144 
146 {
147  // calculate feature points
149 
150  if (m_bTemplateList)
151  {
152  for (int i = 0; i < m_nInterestPoints; i++)
154  }
155  else
156  {
157  for (int i = 0; i < m_nInterestPoints; i++)
159  }
160 
161  if (nLevel > 1)
162  {
163  // recursive call
164  CByteImage scaled_image(int(m_pImage->width * powf(scale_factor, float(m_nLevels - nLevel + 1)) + 0.5f), int(m_pImage->height * powf(scale_factor, float(m_nLevels - nLevel + 1.0f)) + 0.5f), CByteImage::eGrayScale);
165  ImageProcessor::Resize(m_pImage, &scaled_image);
166  FindInterestPoints(&scaled_image, scale * scale_factor, nLevel - 1);
167  }
168 }
static void CreateSIFTDescriptors(const CFloatMatrix *pImage, CDynamicArray *pResultList, float x, float y, float scale, float sigma, const float *pOrientationWeights, bool bManageMemory=true, bool bPerform80PercentCheck=true)
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:5308
int width
The width of the image in pixels.
Definition: ByteImage.h:257
static const float scale_factor
Base class for the representation of local features.
Definition: FeatureEntry.h:72
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
int CalculateFeatures(const CByteImage *pImage, CDynamicArray *pResultList, bool bManageMemory=true)
Data structure for the representation of SIFT features.
GLenum GLint x
Definition: glext.h:3125
void FindInterestPoints(const CByteImage *pImage, float scale, int nLevel)
CFeatureEntry * CreateCopy(const CFeatureEntry *pFeatureEntry)
int height
The height of the image in pixels.
Definition: ByteImage.h:264
int GetSize() const
Definition: DynamicArray.h:102
CDynamicArrayTemplatePointer< CFeatureEntry > * m_pResultListTemplate
ImageType type
The type of the image.
Definition: ByteImage.h:292
int CalculateHarrisInterestPoints(const CByteImage *pInputImage, Vec2d *pInterestPoints, int nMaxPoints, float fQualityLevel=0.01f, float fMinDistance=5.0f)
Computes interest points within a CByteImage by applying the Harris corner detector.
GLenum GLint GLint y
Definition: glext.h:3125
Data structure for the representation of a 2D vector.
Definition: Math2d.h:82
bool Resize(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bInterpolation=true)
Resizes a CByteImage and writes the result to a CByteImage.
CHarrisSIFTFeatureCalculator(float fThreshold=0.01f, int nLayers=3, int nMaxInterestPoints=500)


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:28