Windows::Foundation::DateTime MultiFrameBuffer::GetTimestampForSensorPair()

in Shared/HoloLensForCV/MultiFrameBuffer.cpp [87:127]


    Windows::Foundation::DateTime MultiFrameBuffer::GetTimestampForSensorPair(
        SensorType a, 
        SensorType b,
        float toleranceInSeconds)
    {
        std::vector<Windows::Foundation::DateTime> vta;
        std::vector<Windows::Foundation::DateTime> vtb;

        {
            std::lock_guard<std::mutex> lock(_framesMutex);

            for (auto& f : _frames[a])
            {
                vta.push_back(f->Timestamp);
            }

            for (auto& f : _frames[b])
            {
                vtb.push_back(f->Timestamp);
            }
        }

        Windows::Foundation::DateTime best;
        best.UniversalTime = 0;

        for (auto ta : vta)
        {
            for (auto tb : vtb)
            {
                if (std::abs(TimeDeltaAMinusB(ta, tb)) < toleranceInSeconds)
                {
                    if (TimeDeltaAMinusB(ta, best) > 0)
                    {
                        best = ta;
                    }
                }
            }
        }

        return best;
    }