- patch_feat = get_features(input_rgb, input_gray, p_pose.cx, p_pose.cy, p_windows_size[0], p_windows_size[1], p_current_scale * p_scales[i]);
- ComplexMat zf = fft.forward_window(patch_feat);
- DEBUG_PRINTM(zf);
- cv::Mat response;
- if (m_use_linearkernel)
- response = fft.inverse((p_model_alphaf * zf).sum_over_channels());
- else {
- ComplexMat kzf = gaussian_correlation(zf, p_model_xf, p_kernel_sigma);
- DEBUG_PRINTM(p_model_alphaf);
- DEBUG_PRINTM(kzf);
- DEBUG_PRINTM(p_model_alphaf * kzf);
- response = fft.inverse(p_model_alphaf * kzf);
- }
- DEBUG_PRINTM(response);
-
- /* target location is at the maximum response. we must take into
- account the fact that, if the target doesn't move, the peak
- will appear at the top-left corner, not at the center (this is
- discussed in the paper). the responses wrap around cyclically. */
- double min_val, max_val;
- cv::Point2i min_loc, max_loc;
- cv::minMaxLoc(response, &min_val, &max_val, &min_loc, &max_loc);
- DEBUG_PRINT(max_loc);
-
- double weight = p_scales[i] < 1. ? p_scales[i] : 1./p_scales[i];
+ std::cout << "CURRENT SCALE: " << p_current_scale * p_scales[i] << std::endl;
+ for (size_t j = 0; j < p_angles.size(); ++j) {
+ patch_feat = get_features(input_rgb, input_gray, p_pose.cx, p_pose.cy, p_windows_size[0], p_windows_size[1], p_current_scale * p_scales[i], p_current_angle + p_angles[j]);
+ ComplexMat zf = fft.forward_window(patch_feat);
+ DEBUG_PRINTM(zf);
+ cv::Mat response;
+ if (m_use_linearkernel)
+ response = fft.inverse((p_model_alphaf * zf).sum_over_channels());
+ else {
+ ComplexMat kzf = gaussian_correlation(zf, p_model_xf, p_kernel_sigma);
+ DEBUG_PRINTM(p_model_alphaf);
+ DEBUG_PRINTM(kzf);
+ DEBUG_PRINTM(p_model_alphaf * kzf);
+ response = fft.inverse(p_model_alphaf * kzf);
+ }
+ if (m_debug) {
+ cv::Mat copy_response = response.clone();
+
+ // crop the spectrum, if it has an odd number of rows or columns
+ copy_response = copy_response(cv::Rect(0, 0, copy_response.cols & -2, copy_response.rows & -2));
+
+ // rearrange the quadrants of Fourier image so that the origin is at the image center
+ int cx = copy_response.cols/2;
+ int cy = copy_response.rows/2;
+
+ cv::Mat q0(copy_response, cv::Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
+ cv::Mat q1(copy_response, cv::Rect(cx, 0, cx, cy)); // Top-Right
+ cv::Mat q2(copy_response, cv::Rect(0, cy, cx, cy)); // Bottom-Left
+ cv::Mat q3(copy_response, cv::Rect(cx, cy, cx, cy)); // Bottom-Right
+
+ cv::Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
+ q0.copyTo(tmp);
+ q3.copyTo(q0);
+ tmp.copyTo(q3);
+
+ q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
+ q2.copyTo(q1);
+ tmp.copyTo(q2);
+
+ cv::namedWindow("Response map",cv::WINDOW_NORMAL);
+ cv::resizeWindow("Response map", 128, 128);
+ cv::imshow("Response map", copy_response);
+ cv::waitKey();
+ }
+ DEBUG_PRINTM(response);
+
+ /* target location is at the maximum response. we must take into
+ account the fact that, if the target doesn't move, the peak
+ will appear at the top-left corner, not at the center (this is
+ discussed in the paper). the responses wrap around cyclically. */
+ double min_val, max_val;
+ cv::Point2i min_loc, max_loc;
+ cv::minMaxLoc(response, &min_val, &max_val, &min_loc, &max_loc);
+ DEBUG_PRINT(max_loc);
+
+ double weight = p_scales[i] < 1. ? p_scales[i] : 1./p_scales[i];