MCPcopy Create free account
hub / github.com/RoboMaster/RoboRTS / detect

Method detect

roborts_tracking/KCFcpp/src/kcftracker.cpp:230–258  ·  view source on GitHub ↗

Detect object in the current frame.

Source from the content-addressed store, hash-verified

228
229// Detect object in the current frame.
230cv::Point2f KCFTracker::detect(cv::Mat z, cv::Mat x, float &peak_value)
231{
232 using namespace FFTTools;
233
234 cv::Mat k = gaussianCorrelation(x, z);
235 cv::Mat res = (real(fftd(complexMultiplication(_alphaf, fftd(k)), true)));
236
237 //minMaxLoc only accepts doubles for the peak, and integer points for the coordinates
238 cv::Point2i pi;
239 double pv;
240 cv::minMaxLoc(res, NULL, &pv, NULL, &pi);
241 peak_value = (float) pv;
242
243 //subpixel peak estimation, coordinates will be non-integer
244 cv::Point2f p((float)pi.x, (float)pi.y);
245
246 if (pi.x > 0 && pi.x < res.cols-1) {
247 p.x += subPixelPeak(res.at<float>(pi.y, pi.x-1), peak_value, res.at<float>(pi.y, pi.x+1));
248 }
249
250 if (pi.y > 0 && pi.y < res.rows-1) {
251 p.y += subPixelPeak(res.at<float>(pi.y-1, pi.x), peak_value, res.at<float>(pi.y+1, pi.x));
252 }
253
254 p.x -= (res.cols) / 2;
255 p.y -= (res.rows) / 2;
256
257 return p;
258}
259
260// train tracker with a single image
261void KCFTracker::train(cv::Mat x, float train_interp_factor)

Callers

nothing calls this directly

Calls 3

realFunction · 0.85
fftdFunction · 0.85
complexMultiplicationFunction · 0.85

Tested by

no test coverage detected