renamed internal headers to avoid conflicts with system header files
This commit is contained in:
parent
87f6e500e1
commit
191f25ae7c
@ -6,10 +6,9 @@
|
||||
#define SVM_LATENTSVM
|
||||
|
||||
#include <stdio.h>
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
#include "_error.h"
|
||||
#include "_routine.h"
|
||||
#include "_lsvm_types.h"
|
||||
#include "_lsvm_error.h"
|
||||
#include "_lsvm_routine.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Building feature pyramid
|
||||
|
@ -1,140 +1,138 @@
|
||||
#ifndef DIST_TRANSFORM
|
||||
#define DIST_TRANSFORM
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
#include "_error.h"
|
||||
|
||||
|
||||
/*
|
||||
// Computation the point of intersection functions
|
||||
// (parabolas on the variable y)
|
||||
// a(y - q1) + b(q1 - y)(q1 - y) + f[q1]
|
||||
// a(y - q2) + b(q2 - y)(q2 - y) + f[q2]
|
||||
//
|
||||
// API
|
||||
// int GetPointOfIntersection(const F_type *f,
|
||||
const F_type a, const F_type b,
|
||||
int q1, int q2, F_type *point);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// a - coefficient of the function
|
||||
// b - coefficient of the function
|
||||
// q1 - parameter of the function
|
||||
// q2 - parameter of the function
|
||||
// OUTPUT
|
||||
// point - point of intersection
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int GetPointOfIntersection(const float *f,
|
||||
const float a, const float b,
|
||||
int q1, int q2, float *point);
|
||||
|
||||
/*
|
||||
// Decision of one dimensional problem generalized distance transform
|
||||
// on the regular grid at all points
|
||||
// min (a(y' - y) + b(y' - y)(y' - y) + f(y')) (on y')
|
||||
//
|
||||
// API
|
||||
// int DistanceTransformOneDimensionalProblem(const F_type *f, const int n,
|
||||
const F_type a, const F_type b,
|
||||
F_type *distanceTransform,
|
||||
int *points);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// n - grid dimension
|
||||
// a - coefficient of optimizable function
|
||||
// b - coefficient of optimizable function
|
||||
// OUTPUT
|
||||
// distanceTransform - values of generalized distance transform
|
||||
// points - arguments that corresponds to the optimal value of function
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int DistanceTransformOneDimensionalProblem(const float *f, const int n,
|
||||
const float a, const float b,
|
||||
float *distanceTransform,
|
||||
int *points);
|
||||
|
||||
/*
|
||||
// Computation next cycle element
|
||||
//
|
||||
// API
|
||||
// int GetNextCycleElement(int k, int n, int q);
|
||||
// INPUT
|
||||
// k - index of the previous cycle element
|
||||
// n - number of matrix rows
|
||||
// q - parameter that equal (number_of_rows * number_of_columns - 1)
|
||||
// OUTPUT
|
||||
// None
|
||||
// RESULT
|
||||
// Next cycle element
|
||||
*/
|
||||
int GetNextCycleElement(int k, int n, int q);
|
||||
|
||||
/*
|
||||
// Transposition of cycle elements
|
||||
//
|
||||
// API
|
||||
// void TransposeCycleElements(F_type *a, int *cycle, int cycle_len);
|
||||
// INPUT
|
||||
// a - initial matrix
|
||||
// cycle - cycle
|
||||
// cycle_len - cycle length
|
||||
// OUTPUT
|
||||
// a - matrix with transposed elements
|
||||
// RESULT
|
||||
// None
|
||||
*/
|
||||
void TransposeCycleElements(float *a, int *cycle, int cycle_len);
|
||||
|
||||
/*
|
||||
// Getting transposed matrix
|
||||
//
|
||||
// API
|
||||
// void Transpose(F_type *a, int n, int m);
|
||||
// INPUT
|
||||
// a - initial matrix
|
||||
// n - number of rows
|
||||
// m - number of columns
|
||||
// OUTPUT
|
||||
// a - transposed matrix
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
void Transpose(float *a, int n, int m);
|
||||
|
||||
/*
|
||||
// Decision of two dimensional problem generalized distance transform
|
||||
// on the regular grid at all points
|
||||
// min{d2(y' - y) + d4(y' - y)(y' - y) +
|
||||
min(d1(x' - x) + d3(x' - x)(x' - x) + f(x',y'))} (on x', y')
|
||||
//
|
||||
// API
|
||||
// int DistanceTransformTwoDimensionalProblem(const F_type *f,
|
||||
const int n, const int m,
|
||||
const F_type coeff[4],
|
||||
F_type *distanceTransform,
|
||||
int *pointsX, int *pointsY);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// n - number of rows
|
||||
// m - number of columns
|
||||
// coeff - coefficients of optimizable function
|
||||
coeff[0] = d1, coeff[1] = d2,
|
||||
coeff[2] = d3, coeff[3] = d4
|
||||
// OUTPUT
|
||||
// distanceTransform - values of generalized distance transform
|
||||
// pointsX - arguments x' that correspond to the optimal value
|
||||
// pointsY - arguments y' that correspond to the optimal value
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int DistanceTransformTwoDimensionalProblem(const float *f,
|
||||
const int n, const int m,
|
||||
const float coeff[4],
|
||||
float *distanceTransform,
|
||||
int *pointsX, int *pointsY);
|
||||
|
||||
#ifndef LSVM_DIST_TRANSFORM
|
||||
#define LSVM_DIST_TRANSFORM
|
||||
|
||||
#include "_lsvm_types.h"
|
||||
#include "_lsvm_error.h"
|
||||
|
||||
/*
|
||||
// Computation the point of intersection functions
|
||||
// (parabolas on the variable y)
|
||||
// a(y - q1) + b(q1 - y)(q1 - y) + f[q1]
|
||||
// a(y - q2) + b(q2 - y)(q2 - y) + f[q2]
|
||||
//
|
||||
// API
|
||||
// int GetPointOfIntersection(const F_type *f,
|
||||
const F_type a, const F_type b,
|
||||
int q1, int q2, F_type *point);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// a - coefficient of the function
|
||||
// b - coefficient of the function
|
||||
// q1 - parameter of the function
|
||||
// q2 - parameter of the function
|
||||
// OUTPUT
|
||||
// point - point of intersection
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int GetPointOfIntersection(const float *f,
|
||||
const float a, const float b,
|
||||
int q1, int q2, float *point);
|
||||
|
||||
/*
|
||||
// Decision of one dimensional problem generalized distance transform
|
||||
// on the regular grid at all points
|
||||
// min (a(y' - y) + b(y' - y)(y' - y) + f(y')) (on y')
|
||||
//
|
||||
// API
|
||||
// int DistanceTransformOneDimensionalProblem(const F_type *f, const int n,
|
||||
const F_type a, const F_type b,
|
||||
F_type *distanceTransform,
|
||||
int *points);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// n - grid dimension
|
||||
// a - coefficient of optimizable function
|
||||
// b - coefficient of optimizable function
|
||||
// OUTPUT
|
||||
// distanceTransform - values of generalized distance transform
|
||||
// points - arguments that corresponds to the optimal value of function
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int DistanceTransformOneDimensionalProblem(const float *f, const int n,
|
||||
const float a, const float b,
|
||||
float *distanceTransform,
|
||||
int *points);
|
||||
|
||||
/*
|
||||
// Computation next cycle element
|
||||
//
|
||||
// API
|
||||
// int GetNextCycleElement(int k, int n, int q);
|
||||
// INPUT
|
||||
// k - index of the previous cycle element
|
||||
// n - number of matrix rows
|
||||
// q - parameter that equal (number_of_rows * number_of_columns - 1)
|
||||
// OUTPUT
|
||||
// None
|
||||
// RESULT
|
||||
// Next cycle element
|
||||
*/
|
||||
int GetNextCycleElement(int k, int n, int q);
|
||||
|
||||
/*
|
||||
// Transposition of cycle elements
|
||||
//
|
||||
// API
|
||||
// void TransposeCycleElements(F_type *a, int *cycle, int cycle_len);
|
||||
// INPUT
|
||||
// a - initial matrix
|
||||
// cycle - cycle
|
||||
// cycle_len - cycle length
|
||||
// OUTPUT
|
||||
// a - matrix with transposed elements
|
||||
// RESULT
|
||||
// None
|
||||
*/
|
||||
void TransposeCycleElements(float *a, int *cycle, int cycle_len);
|
||||
|
||||
/*
|
||||
// Getting transposed matrix
|
||||
//
|
||||
// API
|
||||
// void Transpose(F_type *a, int n, int m);
|
||||
// INPUT
|
||||
// a - initial matrix
|
||||
// n - number of rows
|
||||
// m - number of columns
|
||||
// OUTPUT
|
||||
// a - transposed matrix
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
void Transpose(float *a, int n, int m);
|
||||
|
||||
/*
|
||||
// Decision of two dimensional problem generalized distance transform
|
||||
// on the regular grid at all points
|
||||
// min{d2(y' - y) + d4(y' - y)(y' - y) +
|
||||
min(d1(x' - x) + d3(x' - x)(x' - x) + f(x',y'))} (on x', y')
|
||||
//
|
||||
// API
|
||||
// int DistanceTransformTwoDimensionalProblem(const F_type *f,
|
||||
const int n, const int m,
|
||||
const F_type coeff[4],
|
||||
F_type *distanceTransform,
|
||||
int *pointsX, int *pointsY);
|
||||
// INPUT
|
||||
// f - function on the regular grid
|
||||
// n - number of rows
|
||||
// m - number of columns
|
||||
// coeff - coefficients of optimizable function
|
||||
coeff[0] = d1, coeff[1] = d2,
|
||||
coeff[2] = d3, coeff[3] = d4
|
||||
// OUTPUT
|
||||
// distanceTransform - values of generalized distance transform
|
||||
// pointsX - arguments x' that correspond to the optimal value
|
||||
// pointsY - arguments y' that correspond to the optimal value
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int DistanceTransformTwoDimensionalProblem(const float *f,
|
||||
const int n, const int m,
|
||||
const float coeff[4],
|
||||
float *distanceTransform,
|
||||
int *pointsX, int *pointsY);
|
||||
|
||||
#endif
|
@ -1,16 +1,16 @@
|
||||
#ifndef SVM_ERROR
|
||||
#define SVM_ERROR
|
||||
|
||||
#define LATENT_SVM_OK 0
|
||||
#define DISTANCE_TRANSFORM_OK 1
|
||||
#define DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR -1
|
||||
#define DISTANCE_TRANSFORM_ERROR -2
|
||||
#define DISTANCE_TRANSFORM_EQUAL_POINTS -3
|
||||
#define LATENT_SVM_GET_FEATURE_PYRAMID_FAILED -4
|
||||
#define LATENT_SVM_SEARCH_OBJECT_FAILED -5
|
||||
#define LATENT_SVM_FAILED_SUPERPOSITION -6
|
||||
#define FILTER_OUT_OF_BOUNDARIES -7
|
||||
#define FFT_OK 2
|
||||
#define FFT_ERROR -8
|
||||
|
||||
#ifndef SVM_ERROR
|
||||
#define SVM_ERROR
|
||||
|
||||
#define LATENT_SVM_OK 0
|
||||
#define DISTANCE_TRANSFORM_OK 1
|
||||
#define DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR -1
|
||||
#define DISTANCE_TRANSFORM_ERROR -2
|
||||
#define DISTANCE_TRANSFORM_EQUAL_POINTS -3
|
||||
#define LATENT_SVM_GET_FEATURE_PYRAMID_FAILED -4
|
||||
#define LATENT_SVM_SEARCH_OBJECT_FAILED -5
|
||||
#define LATENT_SVM_FAILED_SUPERPOSITION -6
|
||||
#define FILTER_OUT_OF_BOUNDARIES -7
|
||||
#define FFT_OK 2
|
||||
#define FFT_ERROR -8
|
||||
|
||||
#endif
|
@ -1,81 +1,79 @@
|
||||
#ifndef _FFT_H
|
||||
#define _FFT_H
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
#include "_error.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
// 1-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fft(float *x_in, float *x_out, int n, int shift);
|
||||
// INPUT
|
||||
// x_in - input signal
|
||||
// n - number of elements for searching Fourier image
|
||||
// shift - shift between input elements
|
||||
// OUTPUT
|
||||
// x_out - output signal (contains 2n elements in order
|
||||
Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fft(float *x_in, float *x_out, int n, int shift);
|
||||
|
||||
/*
|
||||
// Inverse 1-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fftInverse(float *x_in, float *x_out, int n, int shift);
|
||||
// INPUT
|
||||
// x_in - Fourier image of 1d input signal(contains 2n elements
|
||||
in order Re(x_in[0]), Im(x_in[0]),
|
||||
Re(x_in[1]), Im(x_in[1]) and etc.)
|
||||
// n - number of elements for searching counter FFT image
|
||||
// shift - shift between input elements
|
||||
// OUTPUT
|
||||
// x_in - input signal (contains n elements)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftInverse(float *x_in, float *x_out, int n, int shift);
|
||||
|
||||
/*
|
||||
// 2-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fft2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
// INPUT
|
||||
// x_in - input signal (matrix, launched by rows)
|
||||
// numRows - number of rows
|
||||
// numColls - number of collumns
|
||||
// OUTPUT
|
||||
// x_out - output signal (contains (2 * numRows * numColls) elements
|
||||
in order Re(x_in[0][0]), Im(x_in[0][0]),
|
||||
Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fft2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
|
||||
/*
|
||||
// Inverse 2-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
// INPUT
|
||||
// x_in - Fourier image of matrix (contains (2 * numRows * numColls)
|
||||
elements in order Re(x_in[0][0]), Im(x_in[0][0]),
|
||||
Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
|
||||
// numRows - number of rows
|
||||
// numColls - number of collumns
|
||||
// OUTPUT
|
||||
// x_out - initial signal (matrix, launched by rows)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
|
||||
#ifndef _LSVM_FFT_H
|
||||
#define _LSVM_FFT_H
|
||||
|
||||
#include "_lsvm_types.h"
|
||||
#include "_lsvm_error.h"
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
// 1-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fft(float *x_in, float *x_out, int n, int shift);
|
||||
// INPUT
|
||||
// x_in - input signal
|
||||
// n - number of elements for searching Fourier image
|
||||
// shift - shift between input elements
|
||||
// OUTPUT
|
||||
// x_out - output signal (contains 2n elements in order
|
||||
Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fft(float *x_in, float *x_out, int n, int shift);
|
||||
|
||||
/*
|
||||
// Inverse 1-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fftInverse(float *x_in, float *x_out, int n, int shift);
|
||||
// INPUT
|
||||
// x_in - Fourier image of 1d input signal(contains 2n elements
|
||||
in order Re(x_in[0]), Im(x_in[0]),
|
||||
Re(x_in[1]), Im(x_in[1]) and etc.)
|
||||
// n - number of elements for searching counter FFT image
|
||||
// shift - shift between input elements
|
||||
// OUTPUT
|
||||
// x_in - input signal (contains n elements)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftInverse(float *x_in, float *x_out, int n, int shift);
|
||||
|
||||
/*
|
||||
// 2-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fft2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
// INPUT
|
||||
// x_in - input signal (matrix, launched by rows)
|
||||
// numRows - number of rows
|
||||
// numColls - number of collumns
|
||||
// OUTPUT
|
||||
// x_out - output signal (contains (2 * numRows * numColls) elements
|
||||
in order Re(x_in[0][0]), Im(x_in[0][0]),
|
||||
Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fft2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
|
||||
/*
|
||||
// Inverse 2-dimensional FFT
|
||||
//
|
||||
// API
|
||||
// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
// INPUT
|
||||
// x_in - Fourier image of matrix (contains (2 * numRows * numColls)
|
||||
elements in order Re(x_in[0][0]), Im(x_in[0][0]),
|
||||
Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
|
||||
// numRows - number of rows
|
||||
// numColls - number of collumns
|
||||
// OUTPUT
|
||||
// x_out - initial signal (matrix, launched by rows)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
|
||||
|
||||
#endif
|
@ -1,396 +1,396 @@
|
||||
/*****************************************************************************/
|
||||
/* Matching procedure API */
|
||||
/*****************************************************************************/
|
||||
//
|
||||
#ifndef SVM_MATCHING
|
||||
#define SVM_MATCHING
|
||||
|
||||
#include "_latentsvm.h"
|
||||
#include "_error.h"
|
||||
#include "_distancetransform.h"
|
||||
#include "_fft.h"
|
||||
#include "_routine.h"
|
||||
|
||||
//extern "C" {
|
||||
/*
|
||||
// Function for convolution computation
|
||||
//
|
||||
// API
|
||||
// int convolution(const filterObject *Fi, const featureMap *map, float *f);
|
||||
// INPUT
|
||||
// Fi - filter object
|
||||
// map - feature map
|
||||
// OUTPUT
|
||||
// f - the convolution
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int convolution(const filterObject *Fi, const featureMap *map, float *f);
|
||||
|
||||
/*
|
||||
// Computation multiplication of FFT images
|
||||
//
|
||||
// API
|
||||
// int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
|
||||
float *multi);
|
||||
// INPUT
|
||||
// fftImage1 - first fft image
|
||||
// fftImage2 - second fft image
|
||||
// (numRows, numColls) - image dimesions
|
||||
// OUTPUT
|
||||
// multi - multiplication
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
|
||||
float *multi);
|
||||
|
||||
/*
|
||||
// Turnover filter matrix for the single feature
|
||||
//
|
||||
// API
|
||||
// int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
|
||||
int p, int shift);
|
||||
// INPUT
|
||||
// filter - filter weight matrix
|
||||
// (dimX, dimY) - dimension of filter matrix
|
||||
// p - number of features
|
||||
// shift - number of feature (or channel)
|
||||
// OUTPUT
|
||||
// rot2PIFilter - rotated matrix
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
|
||||
int p, int shift);
|
||||
|
||||
/*
|
||||
// Addition nullable bars to the dimension of feature map (single feature)
|
||||
//
|
||||
// API
|
||||
// int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
|
||||
float *newFilter, int newDimX, int newDimY);
|
||||
// INPUT
|
||||
// rot2PIFilter - filter matrix for the single feature that was rotated
|
||||
// (dimX, dimY) - dimension rot2PIFilter
|
||||
// (newDimX, newDimY)- dimension of feature map for the single feature
|
||||
// OUTPUT
|
||||
// newFilter - filter matrix with nullable bars
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
|
||||
float *newFilter, int newDimX, int newDimY);
|
||||
|
||||
/*
|
||||
// Computation FFT image for filter object
|
||||
//
|
||||
// API
|
||||
// int getFFTImageFilterObject(const filterObject *filter,
|
||||
int mapDimX, int mapDimY,
|
||||
fftImage **image);
|
||||
// INPUT
|
||||
// filter - filter object
|
||||
// (mapDimX, mapDimY)- dimension of feature map
|
||||
// OUTPUT
|
||||
// image - fft image
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int getFFTImageFilterObject(const filterObject *filter,
|
||||
int mapDimX, int mapDimY,
|
||||
fftImage **image);
|
||||
|
||||
/*
|
||||
// Computation FFT image for feature map
|
||||
//
|
||||
// API
|
||||
// int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
|
||||
// INPUT
|
||||
// OUTPUT
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
|
||||
|
||||
/*
|
||||
// Function for convolution computation using FFT
|
||||
//
|
||||
// API
|
||||
// int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
|
||||
int filterDimX, int filterDimY, float **conv);
|
||||
// INPUT
|
||||
// featMapImage - feature map image
|
||||
// filterImage - filter image
|
||||
// (filterDimX,filterDimY) - filter dimension
|
||||
// OUTPUT
|
||||
// conv - the convolution
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
|
||||
int filterDimX, int filterDimY, float **conv);
|
||||
|
||||
/*
|
||||
// Computation objective function D according the original paper
|
||||
//
|
||||
// API
|
||||
// int filterDispositionLevel(const filterObject *Fi, const featureMap *pyramid,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
// INPUT
|
||||
// Fi - filter object (weights and coefficients of penalty
|
||||
function that are used in this routine)
|
||||
// pyramid - feature map
|
||||
// OUTPUT
|
||||
// scoreFi - values of distance transform on the level at all positions
|
||||
// (pointsX, pointsY)- positions that correspond to the maximum value
|
||||
of distance transform at all grid nodes
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int filterDispositionLevel(const filterObject *Fi, const featureMap *pyramid,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
|
||||
/*
|
||||
// Computation objective function D according the original paper using FFT
|
||||
//
|
||||
// API
|
||||
// int filterDispositionLevelFFT(const filterObject *Fi, const fftImage *featMapImage,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
// INPUT
|
||||
// Fi - filter object (weights and coefficients of penalty
|
||||
function that are used in this routine)
|
||||
// featMapImage - FFT image of feature map
|
||||
// OUTPUT
|
||||
// scoreFi - values of distance transform on the level at all positions
|
||||
// (pointsX, pointsY)- positions that correspond to the maximum value
|
||||
of distance transform at all grid nodes
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int filterDispositionLevelFFT(const filterObject *Fi, const fftImage *featMapImage,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
|
||||
/*
|
||||
// Computation border size for feature map
|
||||
//
|
||||
// API
|
||||
// int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
|
||||
// INPUT
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// bx - border size (X-direction)
|
||||
// by - border size (Y-direction)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
|
||||
|
||||
/*
|
||||
// Addition nullable border to the feature map
|
||||
//
|
||||
// API
|
||||
// int addNullableBorder(featureMap *map, int bx, int by);
|
||||
// INPUT
|
||||
// map - feature map
|
||||
// bx - border size (X-direction)
|
||||
// by - border size (Y-direction)
|
||||
// OUTPUT
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int addNullableBorder(featureMap *map, int bx, int by);
|
||||
|
||||
/*
|
||||
// Computation the maximum of the score function at the level
|
||||
//
|
||||
// API
|
||||
// int maxFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// level - feature pyramid level for computation maximum score
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// score - the maximum of the score function at the level
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int maxFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation score function at the level that exceed threshold
|
||||
//
|
||||
// API
|
||||
// int thresholdFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// level - feature pyramid level for computation maximum score
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// scoreThreshold - score threshold
|
||||
// OUTPUT
|
||||
// score - score function at the level that exceed threshold
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int thresholdFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation the maximum of the score function
|
||||
//
|
||||
// API
|
||||
// int maxFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// score - the maximum of the score function
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int maxFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation score function that exceed threshold
|
||||
//
|
||||
// API
|
||||
// int thresholdFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// scoreThreshold - score threshold
|
||||
// OUTPUT
|
||||
// score - score function values that exceed threshold
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int thresholdFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
|
||||
/*
|
||||
// Perform non-maximum suppression algorithm (described in original paper)
|
||||
// to remove "similar" bounding boxes
|
||||
//
|
||||
// API
|
||||
// int nonMaximumSuppression(int numBoxes, const CvPoint *points,
|
||||
const CvPoint *oppositePoints, const float *score,
|
||||
float overlapThreshold,
|
||||
int *numBoxesout, CvPoint **pointsOut,
|
||||
CvPoint **oppositePointsOut, float **scoreOut);
|
||||
// INPUT
|
||||
// numBoxes - number of bounding boxes
|
||||
// points - array of left top corner coordinates
|
||||
// oppositePoints - array of right bottom corner coordinates
|
||||
// score - array of detection scores
|
||||
// overlapThreshold - threshold: bounding box is removed if overlap part
|
||||
is greater than passed value
|
||||
// OUTPUT
|
||||
// numBoxesOut - the number of bounding boxes algorithm returns
|
||||
// pointsOut - array of left top corner coordinates
|
||||
// oppositePointsOut - array of right bottom corner coordinates
|
||||
// scoreOut - array of detection scores
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int nonMaximumSuppression(int numBoxes, const CvPoint *points,
|
||||
const CvPoint *oppositePoints, const float *score,
|
||||
float overlapThreshold,
|
||||
int *numBoxesOut, CvPoint **pointsOut,
|
||||
CvPoint **oppositePointsOut, float **scoreOut);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int getMaxFilterDims(const filterObject **filters, int kComponents,
|
||||
const int *kPartFilters,
|
||||
unsigned int *maxXBorder, unsigned int *maxYBorder);
|
||||
//}
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
/* Matching procedure API */
|
||||
/*****************************************************************************/
|
||||
//
|
||||
#ifndef SVM_MATCHING
|
||||
#define SVM_MATCHING
|
||||
|
||||
#include "_latentsvm.h"
|
||||
#include "_lsvm_error.h"
|
||||
#include "_lsvm_distancetransform.h"
|
||||
#include "_lsvm_fft.h"
|
||||
#include "_lsvm_routine.h"
|
||||
|
||||
//extern "C" {
|
||||
/*
|
||||
// Function for convolution computation
|
||||
//
|
||||
// API
|
||||
// int convolution(const filterObject *Fi, const featureMap *map, float *f);
|
||||
// INPUT
|
||||
// Fi - filter object
|
||||
// map - feature map
|
||||
// OUTPUT
|
||||
// f - the convolution
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int convolution(const filterObject *Fi, const featureMap *map, float *f);
|
||||
|
||||
/*
|
||||
// Computation multiplication of FFT images
|
||||
//
|
||||
// API
|
||||
// int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
|
||||
float *multi);
|
||||
// INPUT
|
||||
// fftImage1 - first fft image
|
||||
// fftImage2 - second fft image
|
||||
// (numRows, numColls) - image dimesions
|
||||
// OUTPUT
|
||||
// multi - multiplication
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
|
||||
float *multi);
|
||||
|
||||
/*
|
||||
// Turnover filter matrix for the single feature
|
||||
//
|
||||
// API
|
||||
// int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
|
||||
int p, int shift);
|
||||
// INPUT
|
||||
// filter - filter weight matrix
|
||||
// (dimX, dimY) - dimension of filter matrix
|
||||
// p - number of features
|
||||
// shift - number of feature (or channel)
|
||||
// OUTPUT
|
||||
// rot2PIFilter - rotated matrix
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
|
||||
int p, int shift);
|
||||
|
||||
/*
|
||||
// Addition nullable bars to the dimension of feature map (single feature)
|
||||
//
|
||||
// API
|
||||
// int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
|
||||
float *newFilter, int newDimX, int newDimY);
|
||||
// INPUT
|
||||
// rot2PIFilter - filter matrix for the single feature that was rotated
|
||||
// (dimX, dimY) - dimension rot2PIFilter
|
||||
// (newDimX, newDimY)- dimension of feature map for the single feature
|
||||
// OUTPUT
|
||||
// newFilter - filter matrix with nullable bars
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
|
||||
float *newFilter, int newDimX, int newDimY);
|
||||
|
||||
/*
|
||||
// Computation FFT image for filter object
|
||||
//
|
||||
// API
|
||||
// int getFFTImageFilterObject(const filterObject *filter,
|
||||
int mapDimX, int mapDimY,
|
||||
fftImage **image);
|
||||
// INPUT
|
||||
// filter - filter object
|
||||
// (mapDimX, mapDimY)- dimension of feature map
|
||||
// OUTPUT
|
||||
// image - fft image
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int getFFTImageFilterObject(const filterObject *filter,
|
||||
int mapDimX, int mapDimY,
|
||||
fftImage **image);
|
||||
|
||||
/*
|
||||
// Computation FFT image for feature map
|
||||
//
|
||||
// API
|
||||
// int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
|
||||
// INPUT
|
||||
// OUTPUT
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
|
||||
|
||||
/*
|
||||
// Function for convolution computation using FFT
|
||||
//
|
||||
// API
|
||||
// int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
|
||||
int filterDimX, int filterDimY, float **conv);
|
||||
// INPUT
|
||||
// featMapImage - feature map image
|
||||
// filterImage - filter image
|
||||
// (filterDimX,filterDimY) - filter dimension
|
||||
// OUTPUT
|
||||
// conv - the convolution
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
|
||||
int filterDimX, int filterDimY, float **conv);
|
||||
|
||||
/*
|
||||
// Computation objective function D according the original paper
|
||||
//
|
||||
// API
|
||||
// int filterDispositionLevel(const filterObject *Fi, const featureMap *pyramid,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
// INPUT
|
||||
// Fi - filter object (weights and coefficients of penalty
|
||||
function that are used in this routine)
|
||||
// pyramid - feature map
|
||||
// OUTPUT
|
||||
// scoreFi - values of distance transform on the level at all positions
|
||||
// (pointsX, pointsY)- positions that correspond to the maximum value
|
||||
of distance transform at all grid nodes
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int filterDispositionLevel(const filterObject *Fi, const featureMap *pyramid,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
|
||||
/*
|
||||
// Computation objective function D according the original paper using FFT
|
||||
//
|
||||
// API
|
||||
// int filterDispositionLevelFFT(const filterObject *Fi, const fftImage *featMapImage,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
// INPUT
|
||||
// Fi - filter object (weights and coefficients of penalty
|
||||
function that are used in this routine)
|
||||
// featMapImage - FFT image of feature map
|
||||
// OUTPUT
|
||||
// scoreFi - values of distance transform on the level at all positions
|
||||
// (pointsX, pointsY)- positions that correspond to the maximum value
|
||||
of distance transform at all grid nodes
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int filterDispositionLevelFFT(const filterObject *Fi, const fftImage *featMapImage,
|
||||
float **scoreFi,
|
||||
int **pointsX, int **pointsY);
|
||||
|
||||
/*
|
||||
// Computation border size for feature map
|
||||
//
|
||||
// API
|
||||
// int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
|
||||
// INPUT
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// bx - border size (X-direction)
|
||||
// by - border size (Y-direction)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
|
||||
|
||||
/*
|
||||
// Addition nullable border to the feature map
|
||||
//
|
||||
// API
|
||||
// int addNullableBorder(featureMap *map, int bx, int by);
|
||||
// INPUT
|
||||
// map - feature map
|
||||
// bx - border size (X-direction)
|
||||
// by - border size (Y-direction)
|
||||
// OUTPUT
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int addNullableBorder(featureMap *map, int bx, int by);
|
||||
|
||||
/*
|
||||
// Computation the maximum of the score function at the level
|
||||
//
|
||||
// API
|
||||
// int maxFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// level - feature pyramid level for computation maximum score
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// score - the maximum of the score function at the level
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int maxFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation score function at the level that exceed threshold
|
||||
//
|
||||
// API
|
||||
// int thresholdFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// level - feature pyramid level for computation maximum score
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// scoreThreshold - score threshold
|
||||
// OUTPUT
|
||||
// score - score function at the level that exceed threshold
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int thresholdFunctionalScoreFixedLevel(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
int level, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score, CvPoint **points, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation the maximum of the score function
|
||||
//
|
||||
// API
|
||||
// int maxFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// OUTPUT
|
||||
// score - the maximum of the score function
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int maxFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H, float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float *score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
/*
|
||||
// Computation score function that exceed threshold
|
||||
//
|
||||
// API
|
||||
// int thresholdFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
// INPUT
|
||||
// all_F - the set of filters (the first element is root filter,
|
||||
the other - part filters)
|
||||
// n - the number of part filters
|
||||
// H - feature pyramid
|
||||
// b - linear term of the score function
|
||||
// maxXBorder - the largest root filter size (X-direction)
|
||||
// maxYBorder - the largest root filter size (Y-direction)
|
||||
// scoreThreshold - score threshold
|
||||
// OUTPUT
|
||||
// score - score function values that exceed threshold
|
||||
// points - the set of root filter positions (in the block space)
|
||||
// levels - the set of levels
|
||||
// kPoints - number of root filter positions
|
||||
// partsDisplacement - displacement of part filters (in the block space)
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
int thresholdFunctionalScore(const filterObject **all_F, int n,
|
||||
const featurePyramid *H,
|
||||
float b,
|
||||
int maxXBorder, int maxYBorder,
|
||||
float scoreThreshold,
|
||||
float **score,
|
||||
CvPoint **points, int **levels, int *kPoints,
|
||||
CvPoint ***partsDisplacement);
|
||||
|
||||
|
||||
/*
|
||||
// Perform non-maximum suppression algorithm (described in original paper)
|
||||
// to remove "similar" bounding boxes
|
||||
//
|
||||
// API
|
||||
// int nonMaximumSuppression(int numBoxes, const CvPoint *points,
|
||||
const CvPoint *oppositePoints, const float *score,
|
||||
float overlapThreshold,
|
||||
int *numBoxesout, CvPoint **pointsOut,
|
||||
CvPoint **oppositePointsOut, float **scoreOut);
|
||||
// INPUT
|
||||
// numBoxes - number of bounding boxes
|
||||
// points - array of left top corner coordinates
|
||||
// oppositePoints - array of right bottom corner coordinates
|
||||
// score - array of detection scores
|
||||
// overlapThreshold - threshold: bounding box is removed if overlap part
|
||||
is greater than passed value
|
||||
// OUTPUT
|
||||
// numBoxesOut - the number of bounding boxes algorithm returns
|
||||
// pointsOut - array of left top corner coordinates
|
||||
// oppositePointsOut - array of right bottom corner coordinates
|
||||
// scoreOut - array of detection scores
|
||||
// RESULT
|
||||
// Error status
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int nonMaximumSuppression(int numBoxes, const CvPoint *points,
|
||||
const CvPoint *oppositePoints, const float *score,
|
||||
float overlapThreshold,
|
||||
int *numBoxesOut, CvPoint **pointsOut,
|
||||
CvPoint **oppositePointsOut, float **scoreOut);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int getMaxFilterDims(const filterObject **filters, int kComponents,
|
||||
const int *kPartFilters,
|
||||
unsigned int *maxXBorder, unsigned int *maxYBorder);
|
||||
//}
|
||||
#endif
|
@ -1,11 +1,11 @@
|
||||
#ifndef RESIZEIMG
|
||||
#define RESIZEIMG
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
|
||||
IplImage * resize_opencv (IplImage * img, float scale);
|
||||
IplImage * resize_article_dp1(IplImage * img, float scale, const int k);
|
||||
IplImage * resize_article_dp(IplImage * img, float scale, const int k);
|
||||
|
||||
#ifndef RESIZEIMG
|
||||
#define RESIZEIMG
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
|
||||
IplImage * resize_opencv (IplImage * img, float scale);
|
||||
IplImage * resize_article_dp1(IplImage * img, float scale, const int k);
|
||||
IplImage * resize_article_dp(IplImage * img, float scale, const int k);
|
||||
|
||||
#endif
|
@ -1,36 +1,35 @@
|
||||
#ifndef _ROUTINE_H
|
||||
#define _ROUTINE_H
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
#include "_error.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Memory management routines
|
||||
// All paramaters names correspond to previous data structures description
|
||||
// All "alloc" functions return allocated memory for 1 object
|
||||
// with all fields including arrays
|
||||
// Error status is return value
|
||||
//////////////////////////////////////////////////////////////
|
||||
int allocFilterObject(filterObject **obj, const int sizeX, const int sizeY,
|
||||
const int p, const int xp);
|
||||
int freeFilterObject (filterObject **obj);
|
||||
|
||||
int allocFeatureMapObject(featureMap **obj, const int sizeX, const int sizeY,
|
||||
const int p, const int xp);
|
||||
int freeFeatureMapObject (featureMap **obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int allocFeaturePyramidObject(featurePyramid **obj,
|
||||
const int lambda, const int countLevel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int freeFeaturePyramidObject (featurePyramid **obj);
|
||||
int allocFFTImage(fftImage **image, int p, int dimX, int dimY);
|
||||
int freeFFTImage(fftImage **image);
|
||||
#ifndef _LSVM_ROUTINE_H
|
||||
#define _LSVM_ROUTINE_H
|
||||
|
||||
#include "_lsvm_types.h"
|
||||
#include "_lsvm_error.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Memory management routines
|
||||
// All paramaters names correspond to previous data structures description
|
||||
// All "alloc" functions return allocated memory for 1 object
|
||||
// with all fields including arrays
|
||||
// Error status is return value
|
||||
//////////////////////////////////////////////////////////////
|
||||
int allocFilterObject(filterObject **obj, const int sizeX, const int sizeY,
|
||||
const int p, const int xp);
|
||||
int freeFilterObject (filterObject **obj);
|
||||
|
||||
int allocFeatureMapObject(featureMap **obj, const int sizeX, const int sizeY,
|
||||
const int p, const int xp);
|
||||
int freeFeatureMapObject (featureMap **obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int allocFeaturePyramidObject(featurePyramid **obj,
|
||||
const int lambda, const int countLevel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int freeFeaturePyramidObject (featurePyramid **obj);
|
||||
int allocFFTImage(fftImage **image, int p, int dimX, int dimY);
|
||||
int freeFFTImage(fftImage **image);
|
||||
#endif
|
@ -1,93 +1,93 @@
|
||||
#ifndef SVM_TYPE
|
||||
#define SVM_TYPE
|
||||
|
||||
//#include "opencv2/core/core.hpp"
|
||||
//#include "opencv2/highgui/highgui.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
//#define FFT_CONV
|
||||
|
||||
// Çíà÷åíèå ÷èñëà PI
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
|
||||
// Òî÷íîñòü ñðàâíåíèÿ ïàðû âåùåñòâåííûõ ÷èñåë
|
||||
#define EPS 0.000001
|
||||
|
||||
// Ìèíèìàëüíîå è ìàêñèìàëüíîå çíà÷åíèå äëÿ âåùåñòâåííîãî òèïà äàííûõ
|
||||
#define F_MAX 3.402823466e+38
|
||||
#define F_MIN -3.402823465e+38
|
||||
|
||||
// The number of elements in bin
|
||||
// The number of sectors in gradient histogram building
|
||||
#define CNTPARTION 9
|
||||
|
||||
// The number of levels in image resize procedure
|
||||
// We need Lambda levels to resize image twice
|
||||
#define LAMBDA 10
|
||||
|
||||
// Block size. Used in feature pyramid building procedure
|
||||
#define SIDE_LENGTH 8
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// main data structures //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// DataType: STRUCT featureMap
|
||||
// FEATURE MAP DESCRIPTION
|
||||
// Rectangular map (sizeX x sizeY),
|
||||
// every cell stores feature vector (dimension = p)
|
||||
// H - matrix of feature vectors
|
||||
// to set and get feature vectors (i,j)
|
||||
// used formula Map[(j * sizeX + i) * p + k], where
|
||||
// k - component of feature vector in cell (i, j)
|
||||
// END OF FEATURE MAP DESCRIPTION
|
||||
// xp - auxillary parameter for internal use
|
||||
// size of row in feature vectors
|
||||
// (yp = (int) (p / xp); p = xp * yp)
|
||||
typedef struct{
|
||||
int sizeX;
|
||||
int sizeY;
|
||||
int p;
|
||||
int xp;
|
||||
float *Map;
|
||||
} featureMap;
|
||||
|
||||
// DataType: STRUCT featurePyramid
|
||||
//
|
||||
// countLevel - number of levels in the feature pyramid
|
||||
// lambda - resize scale coefficient
|
||||
// pyramid - array of pointers to feature map at different levels
|
||||
typedef struct{
|
||||
int countLevel;
|
||||
int lambda;
|
||||
featureMap **pyramid;
|
||||
} featurePyramid;
|
||||
|
||||
// DataType: STRUCT filterDisposition
|
||||
// The structure stores preliminary results in optimization process
|
||||
// with objective function D
|
||||
//
|
||||
// x - array with X coordinates of optimization problems solutions
|
||||
// y - array with Y coordinates of optimization problems solutions
|
||||
// score - array with optimal objective values
|
||||
typedef struct{
|
||||
float *score;
|
||||
int *x;
|
||||
int *y;
|
||||
} filterDisposition;
|
||||
|
||||
// DataType: STRUCT fftImage
|
||||
// The structure stores FFT image
|
||||
//
|
||||
// p - number of channels
|
||||
// x - array of FFT images for 2d signals
|
||||
// n - number of rows
|
||||
// m - number of collums
|
||||
typedef struct{
|
||||
unsigned int p;
|
||||
unsigned int dimX;
|
||||
unsigned int dimY;
|
||||
float **channels;
|
||||
} fftImage;
|
||||
|
||||
#endif
|
||||
#ifndef SVM_TYPE
|
||||
#define SVM_TYPE
|
||||
|
||||
//#include "opencv2/core/core.hpp"
|
||||
//#include "opencv2/highgui/highgui.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
//#define FFT_CONV
|
||||
|
||||
// Çíà÷åíèå ÷èñëà PI
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
|
||||
// Òî÷íîñòü ñðàâíåíèÿ ïàðû âåùåñòâåííûõ ÷èñåë
|
||||
#define EPS 0.000001
|
||||
|
||||
// Ìèíèìàëüíîå è ìàêñèìàëüíîå çíà÷åíèå äëÿ âåùåñòâåííîãî òèïà äàííûõ
|
||||
#define F_MAX 3.402823466e+38
|
||||
#define F_MIN -3.402823465e+38
|
||||
|
||||
// The number of elements in bin
|
||||
// The number of sectors in gradient histogram building
|
||||
#define CNTPARTION 9
|
||||
|
||||
// The number of levels in image resize procedure
|
||||
// We need Lambda levels to resize image twice
|
||||
#define LAMBDA 10
|
||||
|
||||
// Block size. Used in feature pyramid building procedure
|
||||
#define SIDE_LENGTH 8
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// main data structures //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// DataType: STRUCT featureMap
|
||||
// FEATURE MAP DESCRIPTION
|
||||
// Rectangular map (sizeX x sizeY),
|
||||
// every cell stores feature vector (dimension = p)
|
||||
// H - matrix of feature vectors
|
||||
// to set and get feature vectors (i,j)
|
||||
// used formula Map[(j * sizeX + i) * p + k], where
|
||||
// k - component of feature vector in cell (i, j)
|
||||
// END OF FEATURE MAP DESCRIPTION
|
||||
// xp - auxillary parameter for internal use
|
||||
// size of row in feature vectors
|
||||
// (yp = (int) (p / xp); p = xp * yp)
|
||||
typedef struct{
|
||||
int sizeX;
|
||||
int sizeY;
|
||||
int p;
|
||||
int xp;
|
||||
float *Map;
|
||||
} featureMap;
|
||||
|
||||
// DataType: STRUCT featurePyramid
|
||||
//
|
||||
// countLevel - number of levels in the feature pyramid
|
||||
// lambda - resize scale coefficient
|
||||
// pyramid - array of pointers to feature map at different levels
|
||||
typedef struct{
|
||||
int countLevel;
|
||||
int lambda;
|
||||
featureMap **pyramid;
|
||||
} featurePyramid;
|
||||
|
||||
// DataType: STRUCT filterDisposition
|
||||
// The structure stores preliminary results in optimization process
|
||||
// with objective function D
|
||||
//
|
||||
// x - array with X coordinates of optimization problems solutions
|
||||
// y - array with Y coordinates of optimization problems solutions
|
||||
// score - array with optimal objective values
|
||||
typedef struct{
|
||||
float *score;
|
||||
int *x;
|
||||
int *y;
|
||||
} filterDisposition;
|
||||
|
||||
// DataType: STRUCT fftImage
|
||||
// The structure stores FFT image
|
||||
//
|
||||
// p - number of channels
|
||||
// x - array of FFT images for 2d signals
|
||||
// n - number of rows
|
||||
// m - number of collums
|
||||
typedef struct{
|
||||
unsigned int p;
|
||||
unsigned int dimX;
|
||||
unsigned int dimY;
|
||||
float **channels;
|
||||
} fftImage;
|
||||
|
||||
#endif
|
@ -1,65 +0,0 @@
|
||||
#ifndef LSVM_PARSER
|
||||
#define LSVM_PARSER
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "_types.h"
|
||||
|
||||
#define MODEL 1
|
||||
#define P 2
|
||||
#define COMP 3
|
||||
#define SCORE 4
|
||||
#define RFILTER 100
|
||||
#define PFILTERs 101
|
||||
#define PFILTER 200
|
||||
#define SIZEX 150
|
||||
#define SIZEY 151
|
||||
#define WEIGHTS 152
|
||||
#define TAGV 300
|
||||
#define Vx 350
|
||||
#define Vy 351
|
||||
#define TAGD 400
|
||||
#define Dx 451
|
||||
#define Dy 452
|
||||
#define Dxx 453
|
||||
#define Dyy 454
|
||||
#define BTAG 500
|
||||
|
||||
#define STEP_END 1000
|
||||
|
||||
#define EMODEL (STEP_END + MODEL)
|
||||
#define EP (STEP_END + P)
|
||||
#define ECOMP (STEP_END + COMP)
|
||||
#define ESCORE (STEP_END + SCORE)
|
||||
#define ERFILTER (STEP_END + RFILTER)
|
||||
#define EPFILTERs (STEP_END + PFILTERs)
|
||||
#define EPFILTER (STEP_END + PFILTER)
|
||||
#define ESIZEX (STEP_END + SIZEX)
|
||||
#define ESIZEY (STEP_END + SIZEY)
|
||||
#define EWEIGHTS (STEP_END + WEIGHTS)
|
||||
#define ETAGV (STEP_END + TAGV)
|
||||
#define EVx (STEP_END + Vx)
|
||||
#define EVy (STEP_END + Vy)
|
||||
#define ETAGD (STEP_END + TAGD)
|
||||
#define EDx (STEP_END + Dx)
|
||||
#define EDy (STEP_END + Dy)
|
||||
#define EDxx (STEP_END + Dxx)
|
||||
#define EDyy (STEP_END + Dyy)
|
||||
#define EBTAG (STEP_END + BTAG)
|
||||
|
||||
//extern "C" {
|
||||
int LSVMparser(const char * filename, filterObject *** model, int *last, int *max, int **comp, float **b, int *count, float * score);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int loadModel(
|
||||
|
||||
const char *modelPath,
|
||||
|
||||
filterObject ***filters,
|
||||
int *kFilters,
|
||||
int *kComponents,
|
||||
int **kPartFilters,
|
||||
float **b,
|
||||
float *scoreThreshold);
|
||||
//};
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#include "_distancetransform.h"
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvm_distancetransform.h"
|
||||
|
||||
/*
|
||||
// Computation the point of intersection functions
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "precomp.hpp"
|
||||
#include "_latentsvm.h"
|
||||
#include "_resizeimg.h"
|
||||
#include "_lsvm_resizeimg.h"
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "_fft.h"
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvm_fft.h"
|
||||
|
||||
int getEntireRes(int number, int divisor, int *entire, int *res)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "precomp.hpp"
|
||||
#include "_latentsvm.h"
|
||||
#include "_matching.h"
|
||||
#include "_lsvm_matching.h"
|
||||
|
||||
/*
|
||||
// Transformation filter displacement from the block space
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvmparser.h"
|
||||
#include "_matching.h"
|
||||
#include "_lsvm_matching.h"
|
||||
|
||||
/*
|
||||
// load trained detector from a file
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "_matching.h"
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvm_matching.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef max
|
||||
|
@ -55,7 +55,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "_resizeimg.h"
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvm_resizeimg.h"
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
IplImage * resize_opencv (IplImage * img, float scale){
|
||||
IplImage * imgTmp;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "_routine.h"
|
||||
#include "precomp.hpp"
|
||||
#include "_lsvm_routine.h"
|
||||
|
||||
int allocFilterObject(filterObject **obj, const int sizeX, const int sizeY, const int p, const int xp){
|
||||
int i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user