Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vinjn committed Jun 9, 2016
1 parent 3cbb983 commit 37e4f40
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/FaceOffApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,15 @@ void FaceOff::trackerThreadFn()
mOfflineTracker = ft::IFaceTracker::create();
mOnlineTracker = ft::IFaceTracker::create(option);

bool shouldInitFaceMesh = false;

while (!mShouldQuit)
{
// TODO: more robust with update_signal
if (!mCapture.checkNewFrame()) continue;
if (!mCapture.checkNewFrame())
{
continue;
}

if (mDoesCaptureNeedsInit)
{
Expand Down Expand Up @@ -221,17 +226,22 @@ void FaceOff::trackerThreadFn()
dispatchAsync(loadTexFn);
}

mFaceMesh.getBufferTexCoords0().clear();
shouldInitFaceMesh = true;
}

mOnlineTracker->update(mCapture.surface);

if (!mOnlineTracker->getFound())
{
continue;
}

int nPoints = mOnlineTracker->size();
if (mFaceMesh.getBufferTexCoords0().empty())
if (shouldInitFaceMesh)
{
shouldInitFaceMesh = false;
mFaceMesh.getBufferTexCoords0().clear();

auto imgSize = mOfflineTracker->getImageSize();
for (int i = 0; i < nPoints; i++)
{
Expand Down Expand Up @@ -372,7 +382,7 @@ void FaceOff::draw()
{
gl::clear(ColorA::black(), false);

if (!mOnlineTracker || !mCapture.isReady())
if (!mCapture.isReady())
return;

gl::setMatricesWindow(getWindowSize());
Expand Down Expand Up @@ -402,6 +412,12 @@ void FaceOff::draw()
APP_H * 0.5f + adaptiveCamH * 0.5f
};

if (!mOnlineTracker)
{
gl::draw(mCapture.texture, srcArea, dstRect);
return;
}

gl::Texture2dRef fullscreenTex;
if (VFX_VISIBLE && mOnlineTracker->getFound())
{
Expand Down

0 comments on commit 37e4f40

Please sign in to comment.