MCPcopy Create free account
hub / github.com/Unsigned-Long/iKalibr / TrackingUsingNormFlow

Method TrackingUsingNormFlow

src/core/event_preprocessing.cpp:623–803  ·  view source on GitHub ↗

* EventLineTracking */

Source from the content-addressed store, hash-verified

621 * EventLineTracking
622 */
623void EventLineTracking::TrackingUsingNormFlow(const EventNormFlow::NormFlowPack::Ptr &nfPack) {
624 // sort norm flow data
625 std::list<NormFlow::Ptr> nfs = nfPack->TemporallySortedNormFlows();
626
627#define SHOW_DETAILS 0
628
629 std::set<EventLine::Ptr> linesCandidates;
630 std::map<EventLine::Ptr, std::list<NormFlow::Ptr>> lineWithNFs;
631 // std::map<EventLine::Ptr, LineParamUpdate::Ptr> lineParamUpdate;
632 auto MergeLine1ToLine2 = [&linesCandidates, &lineWithNFs](const EventLine::Ptr &line1,
633 const EventLine::Ptr &line2) {
634 const auto &nfsOfLine1 = lineWithNFs[line1];
635 auto &nfsOfLine2 = lineWithNFs[line2];
636 nfsOfLine2.insert(nfsOfLine2.end(), nfsOfLine1.begin(), nfsOfLine1.end());
637 linesCandidates.erase(line1);
638 lineWithNFs.erase(line1);
639 };
640
641 double lastTime = nfs.front()->timestamp;
642 for (const auto &nf : nfs) {
643 // compute the delta time, update last time stamp
644 double dt = nf->timestamp - lastTime;
645 const double decay = std::exp(-nf->nfNorm * dt);
646 lastTime = nf->timestamp;
647
648 // spdlog::info("p: ({}, {}), t: {:.5f} (sec), dt: {:.3f}, nf: ({:.3f}, {:.3f})", nf->p(0),
649 // nf->p(1), nf->timestamp, dt, nf->nf(0), nf->nf(1));
650
651 EventLine::Ptr ml = nullptr;
652 for (auto &el : linesCandidates) {
653 // apply the decay
654 el->activity *= decay;
655 el->timestamp = nf->timestamp;
656
657 // association
658 const double dist = std::abs(el->PointToLine(nf->p.cast<double>()));
659 const double dirDiffCos = el->DirectionDifferenceCos(nf->nfDir);
660 // too far
661 if (dist > P2L_DISTANCE_THD) {
662#if SHOW_DETAILS
663 spdlog::warn("distance too far!!! Jump it!!!");
664#endif
665 continue;
666 }
667 // not same direction
668 if (dirDiffCos < P2L_ORIENTATION_THD) {
669#if SHOW_DETAILS
670 spdlog::warn("orientation difference too large!!! Jump it!!!");
671#endif
672 continue;
673 }
674 // find the line whose activity is the largest, i.e., matched (associated) line
675 if (ml == nullptr) {
676 ml = el;
677 } else {
678 if (ml->activity < el->activity) {
679 ml = el;
680 }

Callers

nothing calls this directly

Calls 5

DrawKeypointOnCVMatFunction · 0.85
PointToLineMethod · 0.80
CreateFunction · 0.50

Tested by

no test coverage detected