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

Method IsIntersect

example/CarsCounting.h:297–353  ·  view source on GitHub ↗

\brief IsIntersect \param pt1 \param pt2 \return

Source from the content-addressed store, hash-verified

295 /// \return
296 ///
297 int IsIntersect(track_id_t objID, cv::Point2f pt1, cv::Point2f pt2)
298 {
299 int direction = 0;
300
301 if (m_lastIntersections.find(objID) != m_lastIntersections.end())
302 return direction;
303
304 bool isIntersect = CheckIntersection(pt1, pt2);
305
306 if (isIntersect)
307 {
308 m_lastIntersections.emplace(objID);
309
310 cv::Point2f pt;
311 if ((m_pt1.x <= m_pt2.x) && (m_pt1.y > m_pt2.y))
312 {
313 pt.x = (m_pt1.x + m_pt2.x) / 2.f - 0.01f;
314 pt.y = (m_pt1.y + m_pt1.y) / 2.f - 0.01f;
315 }
316 else
317 {
318 if ((m_pt1.x <= m_pt2.x) && (m_pt1.y <= m_pt2.y))
319 {
320 pt.x = (m_pt1.x + m_pt2.x) / 2.f + 0.01f;
321 pt.y = (m_pt1.y + m_pt1.y) / 2.f - 0.01f;
322 }
323 else
324 {
325 if ((m_pt1.x > m_pt2.x) && (m_pt1.y > m_pt2.y))
326 {
327 pt.x = (m_pt1.x + m_pt2.x) / 2.f - 0.01f;
328 pt.y = (m_pt1.y + m_pt1.y) / 2.f + 0.01f;
329 }
330 else
331 {
332 if ((m_pt1.x > m_pt2.x) && (m_pt1.y <= m_pt2.y))
333 {
334 pt.x = (m_pt1.x + m_pt2.x) / 2.f + 0.01f;
335 pt.y = (m_pt1.y + m_pt1.y) / 2.f + 0.01f;
336 }
337 }
338 }
339 }
340 if (CheckIntersection(pt1, pt))
341 {
342 direction = 1;
343 ++m_intersect1;
344 }
345 else
346 {
347 direction = 2;
348 ++m_intersect2;
349 }
350 }
351
352 return direction;
353 }
354

Callers 1

Calls 1

endMethod · 0.80

Tested by

no test coverage detected