Ejemplo n.º 1
0
/**
 * @function redisplay
 * (Called at each openGL step)
 * - Processes the webcam frame to detect the eyes with OpenCV,
 * - Creates a 3D scene with OpenGL,
 * - Render the scene and the webcam image.
 */
void redisplay()
{
    if(frame.empty()) return;

    if(!bPause)
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // OPENCV
        //-- flip frame image
        cv::Mat tempimage;
        if(bInvertCam) cv::flip(frame, tempimage, 0);
        else cv::flip(frame, tempimage, 1);
        //-- detect eyes
        tempimage = detectEyes(tempimage);

        // OPENGL
        //-- scene
        setGlCamera();
        draw3dScene();
        //-- cam
        if(bDisplayCam) displayCam(tempimage);

        // RENDER
        glutSwapBuffers();
    }
    //-- post the next redisplay
    glutPostRedisplay();
}
Ejemplo n.º 2
0
void OrthRoot::setCameraForDraw(ci::Matrix44f& m){
	if(mCameraDirty) {
		setCinderCamera();
	}
	setGlCamera();

	// Account for src rect translation
	if(mSrcRect.x2 > mSrcRect.x1 && mSrcRect.y2 > mSrcRect.y1) {
		const float			sx = mDstRect.getWidth() / mSrcRect.getWidth(),
			sy = mDstRect.getHeight() / mSrcRect.getHeight();
		m.translate(ci::Vec3f(-mSrcRect.x1*sx, -mSrcRect.y1*sy, 0.0f));
		m.scale(ci::Vec3f(sx, sy, 1.0f));
	}
}
Ejemplo n.º 3
0
void PerspRoot::drawFunc(const std::function<void(void)>& fn) {
	// XXX This shouldn't be necessary - the OrthoRoot should be setting
	// all camera properties whenever it draws. But for some reason, without
	// this, no later ortho roots will draw (but then it's fine once you go
	// back to the first root). This inspite of the fact that the ortho
	// setGlCamera code calls everything this does.
	gl::SaveCamera		save_camera;

	if (mCameraDirty) {
		setCinderCamera();
	}
	setGlCamera();

	glClear(GL_DEPTH_BUFFER_BIT);

	fn();
}