![]() |
ETRI IVCL 1.0.0
Acceleration SW Platform for Ondevice
|
#include <iostream>#include <algorithm>#include "SIFT.hpp"#include "__SIFT.hpp"#include "ocl_SIFT.hpp"#include "ocl_MathU.h"Functions | |
| void | ocl_init () |
| void | ocl_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 | ocl_convertGrayAndNormalize (const Mat &input, Mat &output) |
| Mat | ocl_createInitImg (const Mat &img, double sigma) |
| void | ocl_gaussianBlur (const Mat &src, Mat &output, int kSize, float *_gKernel) |
| void | ocl_resizeHalf (const Mat &input, Mat &output, Size outSize) |
| void | ocl_buildGaussPyramid (const Mat &base, vector< Mat > &gaussian_pyramid, int octaves, int intervals, double sigma) |
| void | ocl_scaleSpaceExtrema2 (const vector< Mat > &dog_pyramid, vector< oclFeature > &feats, int octaves, int intervals, double contrast_thres, int curvature_thres) |
| void | ocl_scaleSpaceExtrema (const vector< Mat > &dog_pyramid, vector< oclFeature > &feats, int octaves, int intervals, double contrast_thres, int curvature_thres) |
| bool | ocl_isExtremum (float *prev_dog, float *dog, float *next_dog, int dog_width, int r, int c) |
| void | ocl_derivative (float *dog, int dog_width, int r, int c, float *dD) |
| void | ocl_hessian (float *prev_dog, float *dog, float *next_dog, int dog_width, int r, int c, float *H) |
| bool | ocl_interpExtremum (float *prev_dog, float *dog, float *next_dog, int dog_width, int dog_height, oclFeature &feat, int idx, int r, int c, int intervals, double contrast_thres, int curvature_thres) |
| void | ocl_calcFeatureScales (vector< oclFeature > &feats, double sigma, int intervals) |
| void | ocl_oriHist (float *gaussian, int width, int height, float *hist, int hist_size, int r, int c, int rad, double sigma) |
| void | ocl_constructGaussianPyrBuffer (vector< oclFeature > &feats, vector< Mat > &gaussian_pyramid, cl::Buffer &__feats, cl::Buffer &__gaussian_pyramid, cl::Buffer &__gauss_size_accum, cl::Buffer &__gauss_width, cl::Buffer &__gauss_height) |
| void | ocl_ReleaseGaussianPyrBuffer (cl::Buffer &__feats, cl::Buffer &__gaussian_pyramid, cl::Buffer &__gauss_size_accum, cl::Buffer &__gauss_width, cl::Buffer &__gauss_height) |
| void | ocl_calcFeatureOris2 (vector< oclFeature > &feats, vector< Mat > &gaussian_pyramid, int layer_per_octave, cl::Buffer &__feats, cl::Buffer &__gaussian_pyramid, cl::Buffer &__gauss_size_accum, cl::Buffer &__gauss_width, cl::Buffer &__gauss_height) |
| void | ocl_calcFeatureOris (vector< oclFeature > &feats, vector< Mat > &gaussian_pyramid, int layer_per_octave) |
| void | ocl_descriptorHist (Mat &gaussian, float *hist, int r, int c, float ori, float scl, int d, int n) |
| void | ocl_computeDescriptors (vector< oclFeature > &feats, vector< Mat > &gaussian_pyramid, int layer_per_octave, int d, int n) |
| void | ocl_normalizeDescriptor (float *descriptor, int cnt) |
| void | ocl_hist2Descriptor (float *hist, oclFeature &feat, int d, int n) |
| void | ocl_feats2KeyPoints (const vector< oclFeature > &feats, vector< KeyPoint > &keypoints) |
| void | ocl_featsVec2Mat (const vector< oclFeature > &feats, Mat &mat) |
| void | ocl_computeDescriptors2 (vector< oclFeature > &feats, vector< Mat > &gaussian_pyramid, int layer_per_octave, int d, int n, cl::Buffer &__feats, cl::Buffer &__gaussian_pyramid, cl::Buffer &__gauss_size_accum, cl::Buffer &__gauss_width, cl::Buffer &__gauss_height) |
Variables | |
| char | platformChooser |
| vector< cl::Platform > | platforms |
| cl::Context | context |
| cl::CommandQueue | commandQueue |
| cl::Program | program |
| cl::Kernel | cvtGrayNormKernel |
| cl::Kernel | resizeKernel |
| cl::Kernel | gaussianKernel |
| cl::Kernel | scaleSpaceExtremaKernel |
| cl::Kernel | calcFeatureOrisKernel |
| cl::Kernel | computeDescriptorKernel |
| vector< cl::Device > | devices |
| cl_int | errNum |
| float * | oclgKernel |
| void ocl_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 ocl_calcFeatureOris | ( | vector< oclFeature > & | feats, |
| vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave | ||
| ) |
Computes a canonical orientation for each image feature (Native)
| feats | feature vector |
| gaussian_pyramid | gaussian pyramid |
| layer_per_octave | number of layers per octave |
| void ocl_calcFeatureOris2 | ( | vector< oclFeature > & | feats, |
| vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave, | ||
| cl::Buffer & | __feats, | ||
| cl::Buffer & | __gaussian_pyramid, | ||
| cl::Buffer & | __gauss_size_accum, | ||
| cl::Buffer & | __gauss_width, | ||
| cl::Buffer & | __gauss_height | ||
| ) |
Computes a canonical orientation for each image feature (OpenCL)
| feats | feature vector |
| gaussian_pyramid | gaussian pyramid |
| layer_per_octave | number of layers per octave |
| __feats | feature OpenCL buffer |
| __gaussian_pyramid | gaussian pyramid OpenCL buffer |
| __gauss_size_accum | gaussian accumulated total size OpenCL buffer |
| __gauss_width | gaussian width OpenCL buffer |
| __gauss_height | gaussian height OpenCL buffer |
| void ocl_calcFeatureScales | ( | vector< oclFeature > & | feats, |
| double | sigma, | ||
| int | intervals | ||
| ) |
Calculates characteristic scale
| feats | feature vector |
| sigma | sigma for Gaussian smoothing |
| intervals | intervals per octave |
| void ocl_computeDescriptors | ( | vector< oclFeature > & | feats, |
| vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave, | ||
| int | d, | ||
| int | n | ||
| ) |
Computes feature descriptors (Native)
| 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 |
| void ocl_computeDescriptors2 | ( | vector< oclFeature > & | feats, |
| vector< Mat > & | gaussian_pyramid, | ||
| int | layer_per_octave, | ||
| int | d, | ||
| int | n, | ||
| cl::Buffer & | __feats, | ||
| cl::Buffer & | __gaussian_pyramid, | ||
| cl::Buffer & | __gauss_size_accum, | ||
| cl::Buffer & | __gauss_width, | ||
| cl::Buffer & | __gauss_height | ||
| ) |
Computes feature descriptors (OpenCL)
| 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 |
| __feats | feature OpenCL buffer |
| __gaussian_pyramid | gaussian pyramid OpenCL buffer |
| __gauss_size_accum | gaussian accumulated total size OpenCL buffer |
| __gauss_width | gaussian width OpenCL buffer |
| __gauss_height | gaussian height OpenCL buffer |
| void ocl_constructGaussianPyrBuffer | ( | vector< oclFeature > & | feats, |
| vector< Mat > & | gaussian_pyramid, | ||
| cl::Buffer & | __feats, | ||
| cl::Buffer & | __gaussian_pyramid, | ||
| cl::Buffer & | __gauss_size_accum, | ||
| cl::Buffer & | __gauss_width, | ||
| cl::Buffer & | __gauss_height | ||
| ) |
Initialize OpenCL buffer
| feats | calculated features |
| gaussian_pyramid | calculated gaussian pyramid |
| __feats | feature OpenCL buffer |
| __gaussian_pyramid | gaussian pyramid OpenCL buffer |
| __gauss_size_accum | gaussian accumulated total size OpenCL buffer |
| __gauss_width | gaussian width OpenCL buffer |
| __gauss_height | gaussian height OpenCL buffer |
| void ocl_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 |
| Mat ocl_createInitImg | ( | const Mat & | img, |
| double | sigma | ||
| ) |
Create the initial image for builing gaussian pyramid, optionally double the image size before smoothing]
| img | input image |
| sigma | sigma for gaussian smoothing |
| void ocl_derivative | ( | float * | dog, |
| int | dog_width, | ||
| int | r, | ||
| int | c, | ||
| float * | dD | ||
| ) |
| void ocl_descriptorHist | ( | Mat & | gaussian, |
| float * | hist, | ||
| int | r, | ||
| int | c, | ||
| float | ori, | ||
| float | scl, | ||
| int | d, | ||
| int | n | ||
| ) |
| void ocl_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 ocl_feats2KeyPoints | ( | const vector< oclFeature > & | feats, |
| vector< KeyPoint > & | keypoints | ||
| ) |
Convert features to keypoints
| feats | features in vector |
| keypoints | returned keypoint vector |
| void ocl_featsVec2Mat | ( | const vector< oclFeature > & | feats, |
| Mat & | mat | ||
| ) |
Convert features from vector to Mat
| feats | features in vector |
| mat | returned Mat |
| void ocl_gaussianBlur | ( | const Mat & | src, |
| Mat & | output, | ||
| int | kSize, | ||
| float * | _gKernel | ||
| ) |
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 |
| gKernel | Gaussian kernel |
| void ocl_hessian | ( | float * | prev_dog, |
| float * | dog, | ||
| float * | next_dog, | ||
| int | dog_width, | ||
| int | r, | ||
| int | c, | ||
| float * | H | ||
| ) |
| void ocl_hist2Descriptor | ( | float * | hist, |
| oclFeature & | 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 |
| void ocl_init | ( | ) |
Declare for OpenCL code execution
| bool ocl_interpExtremum | ( | float * | prev_dog, |
| float * | dog, | ||
| float * | next_dog, | ||
| int | dog_width, | ||
| int | dog_height, | ||
| oclFeature & | feat, | ||
| int | idx, | ||
| int | r, | ||
| int | c, | ||
| int | intervals, | ||
| double | contrast_thres, | ||
| int | curvature_thres | ||
| ) |
Interpolates a scale-space extremum's location
| prev_dog | previous Dog image |
| dog | current Dog image |
| next_dog | next Dog image |
| dog_width | width of current Dog image |
| dog_height | height of current Dog image |
| 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 |
| curvature_thres | threshold on feature curvature |
| bool ocl_isExtremum | ( | float * | prev_dog, |
| float * | dog, | ||
| float * | next_dog, | ||
| int | dog_width, | ||
| int | r, | ||
| int | c | ||
| ) |
Determines whether a pixel is a scale-space extremum
| prev_dog | previous Dog image |
| dog | current Dog image |
| next_dog | next Dog image |
| dog_width | width of current Dog image |
| r | pixel's image row |
| c | pixel's image col |
| void ocl_normalizeDescriptor | ( | float * | descriptor, |
| int | cnt | ||
| ) |
| void ocl_oriHist | ( | float * | gaussian, |
| int | width, | ||
| int | height, | ||
| float * | hist, | ||
| int | hist_size, | ||
| int | r, | ||
| int | c, | ||
| int | rad, | ||
| double | sigma | ||
| ) |
| void ocl_ReleaseGaussianPyrBuffer | ( | cl::Buffer & | __feats, |
| cl::Buffer & | __gaussian_pyramid, | ||
| cl::Buffer & | __gauss_size_accum, | ||
| cl::Buffer & | __gauss_width, | ||
| cl::Buffer & | __gauss_height | ||
| ) |
Release OpenCL buffer
| __feats | feature OpenCL buffer |
| __gaussian_pyramid | gaussian pyramid OpenCL buffer |
| __gauss_size_accum | gaussian accumulated total size OpenCL buffer |
| __gauss_width | gaussian width OpenCL buffer |
| __gauss_height | gaussian height OpenCL buffer |
| void ocl_resizeHalf | ( | const Mat & | input, |
| Mat & | output, | ||
| Size | outSize | ||
| ) |
Resize image using Nearest neighbor sampling. Reduce width and height in half.
| input | normalized grayscale input image |
| output | resized output image |
| outSize | output image size |
| void ocl_scaleSpaceExtrema | ( | const vector< Mat > & | dog_pyramid, |
| vector< oclFeature > & | feats, | ||
| int | octaves, | ||
| int | intervals, | ||
| double | contrast_thres, | ||
| int | curvature_thres | ||
| ) |
Detects features at extrema in DoG scale space (Native)
| 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 ocl_scaleSpaceExtrema2 | ( | const vector< Mat > & | dog_pyramid, |
| vector< oclFeature > & | feats, | ||
| int | octaves, | ||
| int | intervals, | ||
| double | contrast_thres, | ||
| int | curvature_thres | ||
| ) |
Detects features at extrema in DoG scale space (OpenCL)
| 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 |
| cl::Kernel calcFeatureOrisKernel |
| cl::CommandQueue commandQueue |
| cl::Kernel computeDescriptorKernel |
| cl::Context context |
| cl::Kernel cvtGrayNormKernel |
| vector<cl::Device> devices |
| cl_int errNum |
| cl::Kernel gaussianKernel |
| float* oclgKernel |
| char platformChooser |
Choose Platform
0 for desktop or laptop with non-optimus
1 for laptop with optimus
2 for embedded board (e.g. Odroid-XU4)
| vector<cl::Platform> platforms |
| cl::Program program |
| cl::Kernel resizeKernel |
| cl::Kernel scaleSpaceExtremaKernel |