![]() |
ETRI IVCL 1.0.0
Acceleration SW Platform for Ondevice
|
#include <iostream>#include <algorithm>#include "SIFT.hpp"#include "__SIFT.hpp"#include "MathU.h"Macros | |
| #define | R_PORT 0.2126f |
| #define | G_PORT 0.7152f |
| #define | B_PORT 0.0722f |
| #define | MY_GAUSS true |
| #define | MY_RESIZE true |
Functions | |
| void | start_time (system_clock::time_point &startTime) |
| void | end_time (system_clock::time_point &startTime, system_clock::time_point &endTime, const char *step_name) |
| void | extractSiftFeatures (const Mat &img, vector< KeyPoint > &keypoints, Mat &descriptor, int intervals, double sigma, double contrast_thres, int curvature_thres, bool img_dbl, int descr_width, int descr_hist_bins) |
| void | convertGrayAndNormalize (const Mat &input, Mat &output) |
| void | __feats2KeyPoints (const vector< Feature > &feats, vector< KeyPoint > &keypoints) |
| void | __featsVec2Mat (const vector< Feature > &feats, Mat &mat) |
| void | filterCreation (double **GKernel, int kSize, double sigma) |
| void | filterCreation1D (float *GKernel, int kSize, double sigma) |
| void | gaussianBlur (const Mat &src, Mat &output, int kSize, double **kernel) |
| void | resizeHalf (const Mat &input, Mat &output, Size outSize) |
| Mat | __createInitImg (const Mat &img, bool img_dbl, double sigma) |
| void | __buildGaussPyramid (const Mat &base, vector< Mat > &gaussian_pyramid, int octaves, int intervals, double sigma) |
| void | __buildDogPyramid (const vector< Mat > &gaussian_pyramid, vector< Mat > &dog_pyramid, int octaves, int intervals) |
| void | __scaleSpaceExtrema (const vector< Mat > &dog_pyramid, vector< Feature > &feats, int octaves, int intervals, double contrast_thres, int curvature_thres) |
| bool | __isExtremum (const vector< Mat > &dog_pyramid, int idx, int r, int c) |
| bool | __interpExtremum (const vector< Mat > &dog_pyramid, Feature &feat, int idx, int r, int c, int intervals, double contrast_thres) |
| void | __interpStep (const vector< Mat > &dog_pyramid, int idx, int r, int c, double &xi, double &xr, double &xc) |
| void | _derivative () |
| Mat | __derivative (const vector< Mat > &dog_pyramid, int idx, int r, int c) |
| Mat | __hessian (const vector< Mat > &dog_pyramid, int idx, int r, int c) |
| double | __interpContrast (const vector< Mat > &dog_pyramid, int idx, int r, int c, double xi, double xr, double xc) |
| bool | __isTooEdgeLike (const Mat &dog, int r, int c, int curvature_thres) |
| void | __calcFeatureScales (vector< Feature > &feats, double sigma, int intervals) |
| void | __adjustForImgDbl (vector< Feature > &feats) |
| void | __calcFeatureOris (vector< Feature > &feats, const vector< Mat > &gaussian_pyramid, int layer_per_octave) |
| void | __oriHist (const Mat &gaussian, vector< double > &hist, int r, int c, int rad, double sigma) |
| bool | __calcGradMagOri (const Mat &gaussian, int r, int c, double &mag, double &ori) |
| void | __smoothOriHist (vector< double > &hist) |
| void | __addGoodOriFeatures (queue< Feature > &feat_queue, const vector< double > &hist, double mag_thres, const Feature &feat) |
| void | __computeDescriptors (vector< Feature > &feats, const vector< Mat > &gaussian_pyramid, int layer_per_octave, int d, int n) |
| void | __descriptorHist (const Mat &gaussian, vector< double > &hist, int r, int c, double ori, double scl, int d, int n) |
| void | __interpHistEntry (vector< double > &hist, double rbin, double cbin, double obin, double mag, int d, int n) |
| void | __hist2Descriptor (const vector< double > &hist, Feature &feat, int d, int n) |
| void | __normalizeDescriptor (vector< double > &descriptor) |
Variables | |
| double ** | gKernel |
| int | kSize = 9 |
| volatile int | p_cnt = 0 |
| #define B_PORT 0.0722f |
| #define G_PORT 0.7152f |
| #define MY_GAUSS true |
| #define MY_RESIZE true |
| #define R_PORT 0.2126f |
| void __addGoodOriFeatures | ( | queue< Feature > & | feat_queue, |
| const vector< double > & | hist, | ||
| double | mag_thres, | ||
| const Feature & | feat | ||
| ) |
[add features with orientation greater than mag_thres]
| feat_queue | [queue for features] |
| hist | [orientation histogram] |
| mag_thres | [magnitude threshold] |
| feat | [template feat] |
| void __adjustForImgDbl | ( | vector< Feature > & | feats | ) |
[Halves feature coordinates and scale]
| feats | [feature vector] |
| void __buildDogPyramid | ( | const vector< Mat > & | gaussian_pyramid, |
| vector< Mat > & | dog_pyramid, | ||
| int | octaves, | ||
| int | intervals | ||
| ) |
[Build Difference of Gaussian Pyramid]
| gaussian_pyramid | [gaussian pyramid] |
| dog_pyramid | [returned dog pyramid, size : octaves x (intervals + 2)] |
| octaves | [number of octaves] |
| intervals | [number of intervals per octave] |
| void __buildGaussPyramid | ( | const Mat & | base, |
| vector< Mat > & | gaussian_pyramid, | ||
| int | octaves, | ||
| int | intervals, | ||
| double | sigma | ||
| ) |
[Build Gaussian pyramid]
| base | [base image for the pyramid] |
| gaussian_pyramid | [returned gaussian pyramid, size : octaves x (intervals + 3)] |
| octaves | [number of octaves] |
| intervals | [number of intervals per octave] |
| sigma | [sigma for gaussian smoothing] |
| void __calcFeatureOris | ( | vector< Feature > & | feats, |
| const vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave | ||
| ) |
[Computes a canonical orientation for each image feature]
| feats | [feature vector] |
| gaussian_pyramid | [gaussian pyramid] |
| layer_per_octave | [number of layers per octave] |
| void __calcFeatureScales | ( | vector< Feature > & | feats, |
| double | sigma, | ||
| int | intervals | ||
| ) |
[Calculates characteristic scale]
| feats | [feature vector] |
| sigma | [sigma for Gaussian smoothing] |
| intervals | [intervals per octave] |
| bool __calcGradMagOri | ( | const Mat & | gaussian, |
| int | r, | ||
| int | c, | ||
| double & | mag, | ||
| double & | ori | ||
| ) |
[Calculates the gradient magnitude and orientation]
| gaussian | [Gaussian image] |
| r | [row] |
| c | [col] |
| mag | [returned gradient magnitude] |
| ori | [returned gradient orientation] |
| void __computeDescriptors | ( | vector< Feature > & | feats, |
| const vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave, | ||
| int | d, | ||
| int | n | ||
| ) |
[Computes feature descriptors]
| feats | [feature vector] |
| gaussian_pyramid | [Gaussian pyramid] |
| layer_per_octave | [number of layers per octave in Gaussian pyramid] |
| d | [width of 2d hist] |
| n | [number of bins for descriptor] |
| Mat __createInitImg | ( | const Mat & | img, |
| bool | img_dbl, | ||
| double | sigma | ||
| ) |
[Create the initial image for builing gaussian pyramid, optionally double the image size before smoothing]
| img | [input image] |
| img_dbl | [double size before smoothing?] |
| sigma | [sigma for gaussian smoothing] |
| Mat __derivative | ( | const vector< Mat > & | dog_pyramid, |
| int | idx, | ||
| int | r, | ||
| int | c | ||
| ) |
[partial derivatives in x, y, interval]
| dog_pyramid | [Dog pyramid] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| void __descriptorHist | ( | const Mat & | gaussian, |
| vector< double > & | hist, | ||
| int | r, | ||
| int | c, | ||
| double | ori, | ||
| double | scl, | ||
| int | d, | ||
| int | n | ||
| ) |
[Computes the 2D array of orientation histograms]
| gaussian | [gaussian image] |
| hist | [returned dxdxn hist vector] |
| r | [row] |
| c | [col] |
| ori | [orientation] |
| scl | [scl scale relative to image] |
| d | [width of 2d hist] |
| n | [number of bins for descriptor] |
| void __feats2KeyPoints | ( | const vector< Feature > & | feats, |
| vector< KeyPoint > & | keypoints | ||
| ) |
[convert features to keypoints]
| feats | [features in vector] |
| keypoints | [returned keypoint vector] |
| void __featsVec2Mat | ( | const vector< Feature > & | feats, |
| Mat & | mat | ||
| ) |
[convert features from vector to Mat]
| feats | [features in vector] |
| mat | [returned Mat] |
| Mat __hessian | ( | const vector< Mat > & | dog_pyramid, |
| int | idx, | ||
| int | r, | ||
| int | c | ||
| ) |
[3D Hessian matrix in x, y, interval]
| dog_pyramid | [Dog pyramid] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| void __hist2Descriptor | ( | const vector< double > & | hist, |
| Feature & | feat, | ||
| int | d, | ||
| int | n | ||
| ) |
[converts 2d hist into 1d descriptor]
| hist | [2d histogram] |
| feat | [feature point] |
| d | [width of 2d hist] |
| n | [number of bins for descriptor] |
| double __interpContrast | ( | const vector< Mat > & | dog_pyramid, |
| int | idx, | ||
| int | r, | ||
| int | c, | ||
| double | xi, | ||
| double | xr, | ||
| double | xc | ||
| ) |
[Calculates interpolated pixel contrast]
| dog_pyramid | [Dog pyramid] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| xi | [interpolated subpixel increment to interval] |
| xr | [interpolated subpixel increment to row] |
| xc | [interpolated subpixel increment to col] |
| bool __interpExtremum | ( | const vector< Mat > & | dog_pyramid, |
| Feature & | feat, | ||
| int | idx, | ||
| int | r, | ||
| int | c, | ||
| int | intervals, | ||
| double | contrast_thres | ||
| ) |
[Interpolates a scale-space extremum's location]
| dog_pyramid | [Dog pyramid] |
| feat | [returned feature] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| intervals | [number of intervals per octave] |
| contrast_thres | [low threshold on feature contrast] |
| void __interpHistEntry | ( | vector< double > & | hist, |
| double | rbin, | ||
| double | cbin, | ||
| double | obin, | ||
| double | mag, | ||
| int | d, | ||
| int | n | ||
| ) |
[Interpolates an entry into the array of orientation histograms]
| hist | [2d histogram] |
| rbin | [row] |
| cbin | [col] |
| obin | [orientation] |
| mag | [size] |
| d | [width of 2d hist] |
| n | [number of bins for descriptor] |
| void __interpStep | ( | const vector< Mat > & | dog_pyramid, |
| int | idx, | ||
| int | r, | ||
| int | c, | ||
| double & | xi, | ||
| double & | xr, | ||
| double & | xc | ||
| ) |
[one step of extremum interpolation]
| dog_pyramid | [Dog pyramid] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| xi | [interpolated subpixel increment to interval] |
| xr | [interpolated subpixel increment to row] |
| xc | [interpolated subpixel increment to col] |
| bool __isExtremum | ( | const vector< Mat > & | dog_pyramid, |
| int | idx, | ||
| int | r, | ||
| int | c | ||
| ) |
[Determines whether a pixel is a scale-space extremum]
| dog_pyramid | [Dog pyramid] |
| idx | [index of intervals] |
| r | [pixel's image row] |
| c | [pixel's image col] |
| bool __isTooEdgeLike | ( | const Mat & | dog, |
| int | r, | ||
| int | c, | ||
| int | curvature_thres | ||
| ) |
[Is a feature too edge like?]
| dog | [Dog layer] |
| r | [row] |
| c | [col] |
| curvature_thres | [high threshold on ratio of principal curvatures] |
| void __normalizeDescriptor | ( | vector< double > & | descriptor | ) |
[normalize descriptor to length 1]
| descriptor | [descriptor vector] |
| void __oriHist | ( | const Mat & | gaussian, |
| vector< double > & | hist, | ||
| int | r, | ||
| int | c, | ||
| int | rad, | ||
| double | sigma | ||
| ) |
[Compute gradient orientation histogram]
| gaussian | [gaussian image] |
| hist | [returned hist] |
| r | [row] |
| c | [col] |
| n | [number of bins] |
| rad | [radius of selected region] |
| sigma | [sigma for gaussian smoothing] |
| void __scaleSpaceExtrema | ( | const vector< Mat > & | dog_pyramid, |
| vector< Feature > & | feats, | ||
| int | octaves, | ||
| int | intervals, | ||
| double | contrast_thres, | ||
| int | curvature_thres | ||
| ) |
[Detects features at extrema in DoG scale space]
| dog_pyramid | [Dog pyramid] |
| feats | [Detected features with scales, origentations and descriptors to be determined] |
| octaves | [number of octaves] |
| intervals | [number of intervals per octave] |
| contrast_thres | [low threshold on feature contrast] |
| curvature_thres | [high threshold on feature ratio of principal curvatures] |
| void __smoothOriHist | ( | vector< double > & | hist | ) |
[Gaussian smooths an orientation histogram.]
| hist | [orientation histogram] |
| void _derivative | ( | ) |
| void convertGrayAndNormalize | ( | const Mat & | input, |
| Mat & | output | ||
| ) |
Change 3Channel RGB image to normalized gray image.
| input | 3Channel RGB input image |
| output | normalized grayscale output image with pixel values in 0.0f~1.0f |
| void end_time | ( | system_clock::time_point & | startTime, |
| system_clock::time_point & | endTime, | ||
| const char * | step_name | ||
| ) |
| void extractSiftFeatures | ( | const Mat & | img, |
| vector< KeyPoint > & | keypoints, | ||
| Mat & | descriptor, | ||
| int | intervals = SIFT_INTERVALS, |
||
| double | sigma = SIFT_SIGMA, |
||
| double | contrast_thres = SIFT_CONTRAST_THRES, |
||
| int | curvature_thres = SIFT_CURVATURE_THRES, |
||
| bool | img_dbl = SIFT_IMG_DBL, |
||
| int | descr_width = SIFT_DESCR_WIDTH, |
||
| int | descr_hist_bins = SIFT_DESCR_HIST_BINS |
||
| ) |
[Detect & extract sift features for an image]
| img | [source image for extract sift features : grayscale image with pixel values in 0.0f~1.0f] |
| keypoints | [vector for store sift feature point] |
| descriptor | [Mat for store sift descriptor, each row for a keypoint] |
| intervals | [the number of sampled intervals per octave] |
| sigma | [sigma for initial gaussian smoothing] |
| contrast_thres | [threshold on keypoint contrast] |
| curvature_thres | [threshold on keypoint ratio of principle curvatures] |
| img_dbl | [double image size before pyramid construction?] |
| descr_width | [width of descriptor histogram array] |
| descr_hist_bins | [number of bins per histogram in descriptor array] |
| void filterCreation | ( | double ** | GKernel, |
| int | kSize, | ||
| double | sigma | ||
| ) |
Create 2D gaussian filter
| GKernel | output 2D gaussian filter |
| kSize | gaussian kernel size |
| sigma | gaussian sigma |
| void filterCreation1D | ( | float * | GKernel, |
| int | kSize, | ||
| double | sigma | ||
| ) |
Create 1D gaussian filter
| GKernel | output 1D gaussian filter |
| kSize | gaussian kernel size |
| sigma | gaussian sigma |
| void gaussianBlur | ( | const Mat & | src, |
| Mat & | output, | ||
| int | kSize, | ||
| double ** | kernel | ||
| ) |
Blurs an image using a Gaussian filter using padding
Assume that dst already copy the data of src
| src | input image; Normalized grayscale input image |
| output | output image of the same size and type as src. |
| kSize | width of the input image |
| kernel | Gaussian 2D kernel |
| void resizeHalf | ( | const Mat & | input, |
| Mat & | output, | ||
| Size | outSize | ||
| ) |
Resize image using Nearest neighbor sampling. Reduce width and height in half. (Native)
| input | normalized grayscale input image |
| output | resized output image |
| outSize | output image size |
| void start_time | ( | system_clock::time_point & | startTime | ) |
| double** gKernel |
| int kSize = 9 |
| volatile int p_cnt = 0 |