julapy / ofxQCAR

openframeworks addon for Qualcomm AR.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sync with video frame

vheun opened this issue · comments

Is there some why to synchronize with a new video frame?

I am running an app with 60 fps but I assume the video only runs on 30fps.
This means that for every other frame the image gets drawn double.

I would like to perform something on the frame where new video content is loaded and do other things on the frame when the video content is just redrawn.

commented

hey @vheun,
the ofxiOSVideoPlayer has a method where you can check if a new frame is available.
im not sure if there is a way of preventing ofxQCAR from drawing a frame...
you might be able to prevent the frame buffer from being cleared?
maybe draw everything into a FBO and only update the FBO only when a new video frame is available..?

I solved it with a small hack. I assume that your hands never stand still and therefore every model view matrix contains entirely new values. Therefore when two matrices have identical values there is no new content. Just taking one number out of all the 16 is enough to test for that.

  if(QCAR.numOfMarkersFound()>0) {
            if(matrixOld == matrixTemp[0]._mat[0][0]) {
                updateDraw = false;
            }else{
                updateDraw = true;
            }
            matrixOld = matrixTemp[0]._mat[0][0];
        }else{
            updateDraw = true;

        }

        if(updateDraw) {
            renderContent();
        }