stereolabs / zed-tracking-viewer

[DEPRECATED] ZED SDK sample to show the tracking capability
MIT License
17 stars 10 forks source link

Callback for new position information? #2

Closed fake-name closed 7 years ago

fake-name commented 7 years ago

Is there any way I can be certain to receive every position update?

From the API structure, it seems I have to manually poll zed->getPosition() continuously. It seems like if there is another process on the computer that could preempt my application for a few tens or milliseconds, I could potentially lose position updates, which is non-ideal for my application.

obraun-sl commented 7 years ago

Hi,

The grab() function will be the master function to tell you if a new position if available (it returns 0 when a new frame has arrived and been processed). The way to avoid losing positions will be to put the loop in a thread running continously :

the thread function could be :

while(run_)
{ 
    if (zed->grab()==0)
       zed->getPosition();
   else
       usleep(10);
}

Best, /OB/

fake-name commented 7 years ago

I see. Good to know.

Thanks!