MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / PointUpdate

Method PointUpdate

src/Tracker/track.cpp:1290–1338  ·  view source on GitHub ↗

\brief PointUpdate \param pt \param dataCorrect

Source from the content-addressed store, hash-verified

1288/// \param dataCorrect
1289///
1290void CTrack::PointUpdate(const Point_t& pt,
1291 const cv::Size& newObjSize,
1292 float newAngle,
1293 bool dataCorrect,
1294 const cv::Size& frameSize)
1295{
1296 m_predictionPoint = m_kalman.Update(pt, dataCorrect);
1297
1298 if (dataCorrect)
1299 {
1300 const int a1 = 1;
1301 const int a2 = 9;
1302 m_predictionRect.size.width = (a1 * newObjSize.width + a2 * m_predictionRect.size.width) / (a1 + a2);
1303 m_predictionRect.size.height = (a1 * newObjSize.height + a2 * m_predictionRect.size.height) / (a1 + a2);
1304
1305 std::vector<std::pair<CircVal<UnsignedDegRange>, double>> angles;
1306
1307 angles.push_back(std::make_pair(static_cast<double>(m_predictionRect.angle), 0.1));
1308 angles.push_back(std::make_pair(static_cast<double>(newAngle), 0.9));
1309 auto vals = WeightedCircAverage(angles);
1310 //std::cout << "[" << m_predictionRect.angle << ", " << newAngle << "] -> ";
1311 //for (auto v : vals)
1312 //{
1313 // std::cout << v.operator double() << " ";
1314 //}
1315 //std::cout << std::endl;
1316 m_predictionRect.angle = static_cast<float>(vals.begin()->operator double());
1317 }
1318
1319 auto Clamp = [](track_t& v, int hi) -> bool
1320 {
1321 if (v < 0)
1322 {
1323 v = 0;
1324 return true;
1325 }
1326 else if (hi && v > hi - 1)
1327 {
1328 v = static_cast<track_t>(hi - 1);
1329 return true;
1330 }
1331 return false;
1332 };
1333 auto p = m_predictionPoint;
1334 m_outOfTheFrame = Clamp(p.x, frameSize.width) || Clamp(p.y, frameSize.height) || (m_predictionRect.size.width < 1) || (m_predictionRect.size.height < 1);
1335
1336 //std::cout << "CTrack::PointUpdate: m_predictionRect: " << m_predictionRect.center << ", " << m_predictionRect.angle << ", " << m_predictionRect.size << std::endl;
1337 //std::cout << GetID().ID2Str() << ": predictionRect = " << m_predictionRect.boundingRect() << ", outOfTheFrame = " << m_outOfTheFrame << ", predictionPoint = " << m_predictionPoint << ", newAngle = " << newAngle << std::endl;
1338}

Callers

nothing calls this directly

Calls 4

ClampFunction · 0.85
beginMethod · 0.80
UpdateMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected