1 #ifndef MTF_IMAGE_BASE_H 2 #define MTF_IMAGE_BASE_H 4 #define mc_not_implemeted(func_name, n_channels) \ 5 throw mtf::utils::FunctonNotImplemented(cv::format("%s :: %d channel images are not supported yet", #func_name,n_channels)) 7 #define WARPED_GRAD_EPS 1e-8 10 #define UCHAR_INPUT false 16 #include "mtf/Macros/common.h" 17 #include "mtf/Utilities/excpUtils.h" 29 double _grad_eps = GRAD_EPS,
30 double _hess_eps = HESS_EPS,
31 bool _uchar_input = UCHAR_INPUT);
39 bool pix_vals, pix_grad, pix_hess;
44 pix_vals = pix_grad = pix_hess =
true;
47 pix_vals = pix_grad = pix_hess =
false;
56 MTF_32FC1 = CV_32FC1, MTF_32FC3 = CV_32FC3,
57 MTF_8UC1 = CV_8UC1, MTF_8UC3 = CV_8UC3
63 const int _n_channels = 1);
68 virtual int inputType()
const {
return static_cast<int>(input_type); }
73 virtual const cv::Mat&
getCurrImg()
const{
return curr_img_cv; }
74 virtual unsigned int getImgHeight()
const{
return img_height; }
75 virtual unsigned int getImgWidth()
const{
return img_width; }
76 virtual unsigned int getResX()
const{
return resx; }
77 virtual unsigned int getResY()
const{
return resy; }
78 virtual unsigned int getNPix()
const{
return n_pix; }
79 virtual unsigned int getNChannels()
const{
return n_channels; }
80 virtual unsigned int getPatchSize()
const{
return patch_size; }
81 virtual double getGradOffset()
const{
return grad_eps; }
82 virtual double getHessOffset()
const{
return hess_eps; }
83 virtual const PixValT& getInitPixVals()
const{
return I0; }
84 virtual const PixGradT& getInitPixGrad()
const{
return dI0_dx; }
85 virtual const PixHessT& getInitPixHess()
const{
return d2I0_dx2; }
87 virtual const PixValT& getCurrPixVals()
const{
return It; }
88 virtual const PixGradT& getCurrPixGrad()
const{
return dIt_dx; }
89 virtual const PixHessT& getCurrPixHess()
const{
return d2It_dx2; }
92 virtual void setCurrImg(
const cv::Mat &cv_img);
93 virtual void setInitPixVals(
const PixValT &pix_vals){ I0 = pix_vals; }
94 virtual void setInitPixGrad(
const PixGradT &pix_grad){ dI0_dx = pix_grad; }
95 virtual void setInitPixHess(
const PixHessT &pix_hess){ d2I0_dx2 = pix_hess; }
97 virtual void setCurrPixVals(
const PixValT &pix_vals){ It = pix_vals; }
98 virtual void setCurrPixGrad(
const PixGradT &pix_grad){ dIt_dx = pix_grad; }
99 virtual void setCurrPixHess(
const PixHessT &pix_hess){ d2It_dx2 = pix_hess; }
102 virtual void initializePixVals(
const PtsT& init_pts);
107 virtual void initializePixGrad(
const GradPtsT &warped_offset_pts);
109 virtual void initializePixGrad(
const PtsT &init_pts);
112 virtual void initializePixHess(
const PtsT& init_pts,
const HessPtsT &warped_offset_pts);
114 virtual void initializePixHess(
const PtsT &init_pts);
117 virtual void updatePixVals(
const PtsT& curr_pts);
119 virtual void updatePixGrad(
const GradPtsT &warped_offset_pts);
120 virtual void updatePixGrad(
const PtsT &curr_pts);
122 virtual void updatePixHess(
const PtsT &curr_pts);
123 virtual void updatePixHess(
const PtsT& curr_pts,
const HessPtsT &warped_offset_pts);
127 virtual void extractPatch(VectorXd &pix_vals,
const PtsT& curr_pts);
129 virtual VectorXd getPatch(
const PtsT& curr_pts);
133 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
173 bool uchar_input = img_params ? img_params->uchar_input : UCHAR_INPUT;
175 n_channels == 1 ? InputType::MTF_8UC1 : InputType::MTF_8UC3 :
176 n_channels == 1 ? InputType::MTF_32FC1 : InputType::MTF_32FC3;
178 unsigned int getResX(
const ImgParams *img_params){
179 return img_params ?
static_cast<unsigned int>(img_params->
resx) : MTF_RES;
181 unsigned int getResY(
const ImgParams *img_params){
182 return img_params ?
static_cast<unsigned int>(img_params->resy) : MTF_RES;
184 double getGradEps(
const ImgParams *img_params){
185 return img_params ? img_params->
grad_eps : GRAD_EPS;
187 double getHessEps(
const ImgParams *img_params){
188 return img_params ? img_params->hess_eps : HESS_EPS;
cv::Mat curr_img_cv
OpenCV image used by default with multi channel inputs.
Definition: ImageBase.h:152
EigImgT ImageT
convenience type if floating point grayscale image is used as input by the AM
Definition: ImageBase.h:60
int resx
horizontal and vertical sampling resolutions
Definition: ImageBase.h:23
double grad_eps
numerical increment/decrement used for computing image hessian and gradient using the method of finit...
Definition: ImageBase.h:26
unsigned int img_height
height and width of the input images
Definition: ImageBase.h:155
const unsigned int resx
horizontal and vertical sampling resolutions for the object patch
Definition: ImageBase.h:137
const unsigned int n_channels
no.
Definition: ImageBase.h:142
EigImgT curr_img
Eigen structure shaing memory with the OpenCV image used by default with grayscale inputs...
Definition: ImageBase.h:150
double pix_norm_add
additive and multiplicative factors for normalizing pixel values
Definition: ImageBase.h:167
PixGradT dI0_dx
(N*C) x 2 jacobian of pixel values in the warped image w.r.t.
Definition: ImageBase.h:162
virtual int inputType() const
return the type of OpenCV Mat image the AM requires as input; typically either CV_32FC3 or CV_32FC1 ...
Definition: ImageBase.h:68
const unsigned int n_pix
no. of pixels in the sampled image patch to be tracked
Definition: ImageBase.h:139
unsigned int frame_count
incremented once during initialization and thereafter everytime the template is updated ...
Definition: ImageBase.h:169
PixHessT d2I0_dx2
4 x (N*C) Hessian of pixel values in the warped image w.r.t.
Definition: ImageBase.h:165
Definition: ImageBase.h:51
Definition: ImageBase.h:21
PixValT I0
let N = n_pix = no.
Definition: ImageBase.h:159
InputType
supported input image types
Definition: ImageBase.h:55
virtual const cv::Mat & getCurrImg() const
accessor methods; these are not defined as 'const' since an appearance model may like to make some la...
Definition: ImageBase.h:73
Definition: ImageBase.h:38
const unsigned int patch_size
size of the vector that represents the object patch in the image, typically n_pix*n_channels ...
Definition: ImageBase.h:144
const double grad_eps
offsets to use for computing the numerical image gradient and hessian
Definition: ImageBase.h:146