void PS3EyeStereoDepthApp::updateCameraRef(ps3eye::PS3EYECam::PS3EYERef ref, int index)
{
    std::lock_guard<std::mutex> lock(frameMemMutex);
    auto frame = cameraSurfaces[index];
    uint8 *frameMemPtr = camPair.framePtrAt(index);
    yuv422_to_rgba(ref->getLastFramePointer(), ref->getRowBytes(), frameMemPtr, frame.getWidth(), frame.getHeight());
    displayTextures[index] = gl::Texture(frame);
}
void PS3EyeSlowMoApp::update()
{
    if(eye)
    {
        bool isNewFrame = eye->isNewFrame();
        if(isNewFrame)
        {
            yuv422_to_rgba(eye->getLastFramePointer(), eye->getRowBytes(), frame_bgra, mFrame.getWidth(), mFrame.getHeight());
            
            //Surface source = mFrame.clone();
            
            OStreamMemRef os = OStreamMem::create();
            
            DataTargetRef target = DataTargetStream::createRef( os );
            
            writeImage( target, mFrame, ImageTarget::Options(), "jpeg" );

            const void *data = os->getBuffer();
            
            size_t dataSize = os->tell();

            BufferRef buf = Buffer::create(dataSize );
            memcpy(buf->getData(), data, dataSize);
            surfaceVector.push_back(Surface( loadImage( DataSourceBuffer::create(buf)), SurfaceConstraintsDefault(), false ));
        }
        mCamFrameCount += isNewFrame ? 1 : 0;
        double now = mTimer.getSeconds();
        if( now > mCamFpsLastSampleTime + 1 ) {
            uint32_t framesPassed = mCamFrameCount - mCamFpsLastSampleFrame;
            mCamFps = (float)(framesPassed / (now - mCamFpsLastSampleTime));
            
            mCamFpsLastSampleTime = now;
            mCamFpsLastSampleFrame = mCamFrameCount;
        }
        mFrameRate = eye->getFrameRate();
    }
    
    mQueueSize = surfaceVector.size();
    currentFrame++;
}