// obtain a sub-window for training
// TODO: Move Mats outside from here
MatScaleFeats patch_feats(1, p_num_of_feats, feature_size);
- DEBUG_PRINT(patch_feats);
MatScaleFeats temp(1, p_num_of_feats, feature_size);
get_features(input_rgb, input_gray, p_current_center.x, p_current_center.y,
p_windows_size.width, p_windows_size.height,
p_current_scale).copyTo(patch_feats.scale(0));
DEBUG_PRINT(patch_feats);
- fft.forward_window(patch_feats, p_xf, temp);
- DEBUG_PRINTM(p_xf);
- p_model_xf = p_model_xf * (1. - interp_factor) + p_xf * interp_factor;
- DEBUG_PRINTM(p_model_xf);
-
- ComplexMat alphaf_num, alphaf_den;
+ fft.forward_window(patch_feats, model->xf, temp);
+ DEBUG_PRINTM(model->xf);
+ model->model_xf = model->model_xf * (1. - interp_factor) + model->xf * interp_factor;
+ DEBUG_PRINTM(model->model_xf);
if (m_use_linearkernel) {
- ComplexMat xfconj = p_xf.conj();
- alphaf_num = xfconj.mul(p_yf);
- alphaf_den = (p_xf * xfconj);
+ ComplexMat xfconj = model->xf.conj();
+ model->model_alphaf_num = xfconj.mul(model->yf);
+ model->model_alphaf_den = (model->xf * xfconj);
} else {
// Kernel Ridge Regression, calculate alphas (in Fourier domain)
cv::Size sz(Fft::freq_size(feature_size));
ComplexMat kf(sz.height, sz.width, 1);
- (*gaussian_correlation)(kf, p_model_xf, p_model_xf, p_kernel_sigma, true, *this);
+ (*gaussian_correlation)(kf, model->model_xf, model->model_xf, p_kernel_sigma, true, *this);
DEBUG_PRINTM(kf);
- p_model_alphaf_num = p_yf * kf;
- p_model_alphaf_den = kf * (kf + p_lambda);
+ model->model_alphaf_num = model->yf * kf;
+ model->model_alphaf_den = kf * (kf + p_lambda);
}
- p_model_alphaf = p_model_alphaf_num / p_model_alphaf_den;
- DEBUG_PRINTM(p_model_alphaf);
+ model->model_alphaf = model->model_alphaf_num / model->model_alphaf_den;
+ DEBUG_PRINTM(model->model_alphaf);
// p_model_alphaf = p_yf / (kf + p_lambda); //equation for fast training
}
p_scales.push_back(std::pow(p_scale_step, i));
#ifdef CUFFT
- if (Fft::freq_size(feature_size).area() > 1024) {
- std::cerr << "Window after forward FFT is too big for CUDA kernels. Plese use -f to set "
- "the window dimensions so its size is less or equal to "
- << 1024 * p_cell_size * p_cell_size * 2 + 1
- << " pixels. Currently the size of the window is: " << fit_size
- << " which is " << fit_size.area() << " pixels. " << std::endl;
- std::exit(EXIT_FAILURE);
- }
-
if (m_use_linearkernel) {
std::cerr << "cuFFT supports only Gaussian kernel." << std::endl;
std::exit(EXIT_FAILURE);
}
#endif
- cv::Size csz = Fft::freq_size(feature_size);
- p_model_xf.create(csz.height, csz.width, p_num_of_feats);
- p_yf.create(csz.height, csz.width, 1);
- p_xf.create(csz.height, csz.width, p_num_of_feats);
+ model.reset(new Model(Fft::freq_size(feature_size), p_num_of_feats));
#ifndef BIG_BATCH
for (auto scale: p_scales)
d.threadctxs.emplace_back(feature_size, p_num_of_feats, p_num_scales);
#endif
- gaussian_correlation.reset(new GaussianCorrelation(1, feature_size));
+ gaussian_correlation.reset(new GaussianCorrelation(1, p_num_of_feats, feature_size));
p_current_center = p_init_pose.center();
p_current_scale = 1.;
// window weights, i.e. labels
MatScales gsl(1, feature_size);
gaussian_shaped_labels(p_output_sigma, feature_size.width, feature_size.height).copyTo(gsl.plane(0));
- fft.forward(gsl, p_yf);
- DEBUG_PRINTM(p_yf);
+ fft.forward(gsl, model->yf);
+ DEBUG_PRINTM(model->yf);
// train initial model
train(input_rgb, input_gray, 1.0);
DEBUG_PRINTM(zf);
if (kcf.m_use_linearkernel) {
- kzf = zf.mul(kcf.p_model_alphaf).sum_over_channels();
+ kzf = zf.mul(kcf.model->model_alphaf).sum_over_channels();
} else {
- gaussian_correlation(kzf, zf, kcf.p_model_xf, kcf.p_kernel_sigma, false, kcf);
+ gaussian_correlation(kzf, zf, kcf.model->model_xf, kcf.p_kernel_sigma, false, kcf);
DEBUG_PRINTM(kzf);
- kzf = kzf.mul(kcf.p_model_alphaf);
+ kzf = kzf.mul(kcf.model->model_alphaf);
}
kcf.fft.inverse(kzf, response);
{
TRACE("");
xf.sqr_norm(xf_sqr_norm);
+ DEBUG_PRINTM(xf_sqr_norm[0]);
if (auto_correlation) {
yf_sqr_norm = xf_sqr_norm;
} else {
yf.sqr_norm(yf_sqr_norm);
}
+ DEBUG_PRINTM(yf_sqr_norm[0]);
xyf = auto_correlation ? xf.sqr_mag() : xf * yf.conj(); // xf.muln(yf.conj());
DEBUG_PRINTM(xyf);
DEBUG_PRINTM(xyf_sum);
kcf.fft.inverse(xyf_sum, ifft_res);
DEBUG_PRINTM(ifft_res);
-#ifdef CUFFT
+#if 0 && defined(CUFFT)
// FIXME
cuda_gaussian_correlation(ifft_res.deviceMem(), k.deviceMem(), xf_sqr_norm.deviceMem(),
auto_correlation ? xf_sqr_norm.deviceMem() : yf_sqr_norm.deviceMem(), sigma,