microsoft / HoloLens2ForCV

Sample code and documentation for using the Microsoft HoloLens 2 for Computer Vision research.
MIT License
479 stars 144 forks source link

How to get the QPC ticks from sensor timestamps? #92

Open abdullahthabit opened 3 years ago

abdullahthabit commented 3 years ago

Hi,

I want to convert the timestamps that I get from the frames of the gray-scale camera to the ticks/counts in QPC system-relative time domain, but I cannot seem to understand how and when the timestamping of the frames happen. For the depth sensor, this seems to do the conversion correctly:
qpcTicks = ((timeStamp.HostTicks / c_ticksPerSecond) qpf.QuadPart) + ((timeStamp.HostTicks % c_ticksPerSecond) qpf.QuadPart / c_ticksPerSecond); where c_ticksPerSecond = 10,000,000

However, for the gray-scale camera sensors, the resulted QPC ticks appears to be shifted a few hundred milliseconds before the actual call for getting the frame-buffer: m_pLFSensor->GetNextBuffer(&pSensorFrame);

And this shift tends to increase if the camera update thread is delayed (by other threads for example). So my question, how can I correctly convert the frames' timestamps to QPC ticks?

Thank you in advance!