Exemple #1
0
	void WGLWindow::fullScreen(bool enable)
	{
		// No change
		if (enable == pFullScreen)
			return;

		pFullScreen = enable;
		if (enable)
		{
			if (!enableFullScreen())
				pFullScreen = false;
		}
		else
			disableFullScreen();
	}
SWViewerInterface::SWViewerInterface(QApplication *parent) : m_uiViewer(new Ui::SWUI_Viewer), m_bDesactiveUpdateParameters(false), m_bGLFullScreen(false)
{
    // set absolute path
        m_absolutePath = QDir::currentPath() + "/";

    // init main widget
    m_uiViewer->setupUi(this);
    this->setWindowTitle(QString("SWoOz : Viewer"));
    this->setWindowIcon(QIcon(m_absolutePath + "../data/images/logos/icon_swooz_viewer.png"));

    // middle container
        QHBoxLayout *l_pGLContainerLayout = new QHBoxLayout();
        m_pGLContainer = new QWidget();
        QGLFormat l_glFormat;
        l_glFormat.setVersion( 4, 3 );
        l_glFormat.setProfile(  QGLFormat::CompatibilityProfile);
        l_glFormat.setSampleBuffers( true );
        QGLContext *l_glContext = new QGLContext(l_glFormat);
        m_pGLMultiObject = new SWGLMultiObjectWidget(l_glContext, m_pGLContainer);
        l_pGLContainerLayout->addWidget(m_pGLMultiObject);
        l_pGLContainerLayout->layout()->setContentsMargins(0,0,0,0);
        m_pGLContainer->setLayout(l_pGLContainerLayout);
        m_uiViewer->glScene->addWidget(m_pGLContainer);

    // init worker
        m_pWViewer = new SWViewerWorker();

    // init connections
        // menu
            QObject::connect(m_uiViewer->actionExit, SIGNAL(triggered()), parent, SLOT(quit()));
            QObject::connect(m_uiViewer->actionOnline_documentation, SIGNAL(triggered()), this, SLOT(openOnlineDocumentation()));
            QObject::connect(m_uiViewer->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow()));
        QObject::connect(m_uiViewer->pbLoadCloud, SIGNAL(clicked()), this, SLOT(loadCloud()));
        QObject::connect(m_uiViewer->pbLoadMesh, SIGNAL(clicked()), this, SLOT(loadMesh()));
        QObject::connect(m_uiViewer->pbDeleteCloud, SIGNAL(clicked()), this, SLOT(deleteCloud()));
        QObject::connect(m_uiViewer->pbDeleteMesh, SIGNAL(clicked()), this, SLOT(deleteMesh()));
        QObject::connect(m_uiViewer->pbSetTexture, SIGNAL(clicked()), this, SLOT(setTexture()));

        QObject::connect(m_uiViewer->lwClouds, SIGNAL(currentRowChanged(int)), this, SLOT(updateCloudInterfaceParameters()));
        QObject::connect(m_uiViewer->lwMeshes, SIGNAL(currentRowChanged(int)), this, SLOT(updateMeshInterfaceParameters()));
        QObject::connect(m_uiViewer->lwClouds, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateCloudInterfaceParameters(QListWidgetItem*)));
        QObject::connect(m_uiViewer->lwMeshes, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateMeshInterfaceParameters(QListWidgetItem*)));

        QObject::connect(m_uiViewer->lwClouds, SIGNAL(currentRowChanged(int)), m_pWViewer, SLOT(updateCloudAnimationPath(int)));
        QObject::connect(m_uiViewer->lwMeshes, SIGNAL(currentRowChanged(int)), m_pWViewer, SLOT(updateMeshAnimationPath(int)));
        QObject::connect(this, SIGNAL(cloudCurrentRowChanged(int)), m_pWViewer, SLOT(updateCloudAnimationPath(int)));
        QObject::connect(this, SIGNAL(meshCurrentRowChanged(int)), m_pWViewer, SLOT(updateMeshAnimationPath(int)));
        QObject::connect(m_uiViewer->lwClouds, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateCloudAnimationPath(QListWidgetItem*)));
        QObject::connect(m_uiViewer->lwMeshes, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateMeshAnimationPath(QListWidgetItem*)));


        // update interface
            QObject::connect(m_uiViewer->dsbRX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbRY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbRZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbTrX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbTrY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbTrZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbScaling, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));

            QObject::connect(m_uiViewer->cbDisplayLines, SIGNAL(clicked()), this, SLOT(updateParameters()));
            QObject::connect(m_uiViewer->cbVisible, SIGNAL(clicked()), this, SLOT(updateParameters()));
            QObject::connect(m_uiViewer->rbDisplayOriginalColor, SIGNAL(clicked()), this, SLOT(updateParameters()));
            QObject::connect(m_uiViewer->rbDisplayTexture, SIGNAL(clicked()), this, SLOT(updateParameters()));
            QObject::connect(m_uiViewer->rbDisplayUnicolor, SIGNAL(clicked()), this, SLOT(updateParameters()));

            QObject::connect(m_uiViewer->sbColorB, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int)));
            QObject::connect(m_uiViewer->sbColorG, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int)));
            QObject::connect(m_uiViewer->sbColorR, SIGNAL(valueChanged(int)), this, SLOT(updateParameters(int)));

            QObject::connect(m_uiViewer->dsbLightX, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbLightY, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbLightZ, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));

            QObject::connect(m_uiViewer->leTexturePath, SIGNAL(textChanged(QString)), this, SLOT(updateParameters(QString)));

            QObject::connect(m_uiViewer->dsbAmbiantLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbAmbiantLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbAmbiantLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbDiffusLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbDiffusLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbDiffusLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbSpecularLight1, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbSpecularLight2, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbSpecularLight3, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbAmbiantK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbDiffusK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbSpecularK, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
            QObject::connect(m_uiViewer->dsbSpecularP, SIGNAL(valueChanged(double)), this, SLOT(updateParameters(double)));
        // push buttons
            QObject::connect(m_uiViewer->pbSetCamera, SIGNAL(clicked()), this, SLOT(setCameraToCurrentItem()));
            QObject::connect(m_uiViewer->pbResetCamera, SIGNAL(clicked()), m_pGLMultiObject, SLOT(resetCamera()));
            QObject::connect(m_uiViewer->pbLaunchAllAnim, SIGNAL(clicked()), m_pWViewer, SLOT(startLoop()));
            QObject::connect(m_uiViewer->pbSetModFile, SIGNAL(clicked()), this, SLOT(loadModFile()));
            QObject::connect(m_uiViewer->pbSetSeqFile, SIGNAL(clicked()), this, SLOT(loadSeqFile()));
            QObject::connect(m_uiViewer->pbSetMeshCorr, SIGNAL(clicked()), this, SLOT(loadMeshCorrFile()));

        // fullscreen
            QObject::connect(m_pGLMultiObject, SIGNAL(enableFullScreen()), this, SLOT(enableGLFullScreen()));                        
            QObject::connect(m_pGLMultiObject, SIGNAL(disableFullScreen()), this, SLOT(disableGLFullScreen()));

        // worker
            QObject::connect(this,  SIGNAL(stopLoop()), m_pWViewer, SLOT(stopLoop()));
            QObject::connect(this, SIGNAL(setModFilePath(bool,int,QString)), m_pWViewer, SLOT(setModFile(bool,int,QString)));
            QObject::connect(this, SIGNAL(setSeqFilePath(bool,int,QString)), m_pWViewer, SLOT(setSeqFile(bool,int,QString)));
            QObject::connect(this, SIGNAL(setCorrFilePath(bool,int,QString)), m_pWViewer, SLOT(setCorrFilePath(bool,int,QString)));
            QObject::connect(m_pWViewer, SIGNAL(sendAnimationPathFile(QString,QString,QString)), this, SLOT(updateAnimationPathFileDisplay(QString,QString,QString)));
            QObject::connect(this, SIGNAL(deleteAnimation(bool,int)), m_pWViewer, SLOT(deleteAnimation(bool,int)));
            QObject::connect(this, SIGNAL(addAnimation(bool)), m_pWViewer, SLOT(addAnimation(bool)));
            QObject::connect(m_pWViewer, SIGNAL(sendOffsetAnimation(SWAnimationSendDataPtr)),m_pGLMultiObject, SLOT(setAnimationOffset(SWAnimationSendDataPtr)),Qt::DirectConnection);
//            QObject::connect(m_pWViewer, SIGNAL(sendOffsetAnimation(SWAnimationSendDataPtr)),m_pGLMultiObject, SLOT(setAnimationOffset(SWAnimationSendDataPtr)));
            QObject::connect(m_pWViewer, SIGNAL(startAnimation(bool,int)), m_pGLMultiObject, SLOT(beginAnimation(bool,int)));

            QObject::connect(m_pWViewer, SIGNAL(drawSceneSignal()), m_pGLMultiObject, SLOT(updateGL()));


            setStyleSheet("QGroupBox { padding: 10 0px 0 0px; color: blue; border: 1px solid gray; border-radius: 5px; margin-top: 1ex; /* leave space at the top for the title */}");


    // init thread
        m_pWViewer->moveToThread(&m_TViewer);
        m_TViewer.start();
}
SWCreateAvatarInterface::SWCreateAvatarInterface(QApplication *parent) :  m_uiCreateAvatar(new Ui::SWUI_WCreateAvatar),
    m_oTimer(new QBasicTimer), m_bGLFullScreen(false)
{
    // set absolute path
        m_absolutePath = QDir::currentPath() + "/";

    m_bWorkStarted = false;
    m_bResetKinect = false;

    // init rects
        m_oFaceRect.width = 0;
        m_oNoseRect.width = 0;

	// init main widget
    m_uiCreateAvatar->setupUi(this);
	this->setWindowTitle(QString("SWoOz : Create avatar"));
    this->setWindowIcon(QIcon(m_absolutePath + "../data/images/logos/icon_swooz_avatar.png"));

	// init opengl context
    QHBoxLayout *l_pGLContainerLayout = new QHBoxLayout();
    l_pGLContainerLayout->layout()->setContentsMargins(0,0,0,0);
    m_pGLContainer = new QWidget();
    QGLFormat l_glFormat;
    l_glFormat.setVersion( 4, 3 );
    l_glFormat.setProfile(QGLFormat::CompatibilityProfile);
    l_glFormat.setSampleBuffers(true);
    QGLContext *l_glContext1 = new QGLContext(l_glFormat);
    QGLContext *l_glContext2 = new QGLContext(l_glFormat);
		
	// add widgets
	//	display widgets
    //      rgb
    m_WRGBDisplay =  new SWDisplayImageWidget(this);
    m_uiCreateAvatar->hlRGB->addWidget(m_WRGBDisplay);
    //      radial proj
    m_WRadialProjDisplay =  new SWDisplayImageWidget(this, false, true);
    m_uiCreateAvatar->hlRadial->addWidget(m_WRadialProjDisplay);
    //      face texture
    m_WFaceTextureDisplay =  new SWDisplayImageWidget(this);
    m_uiCreateAvatar->hlFaceTexture->addWidget(m_WFaceTextureDisplay);

    //	cloud gl widget
    m_WCloudGL = new SWGLCloudWidget(l_glContext1, this);
    m_WCloudGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA);
//    m_WCloudGL->setMaximumSize(640,480);
    m_uiCreateAvatar->hlCloud->addWidget(m_WCloudGL);
    // mesh gl widget
    m_WMeshGL = new SWGLMeshWidget(l_glContext2, this, m_absolutePath + "../data/shaders/createAvatarMesh.vert", m_absolutePath + "../data/shaders/createAvatarMesh.frag");
    m_WMeshGL->setCameraMode(SWQtCamera::TRACKBALL_CAMERA);


    m_pGLContainer->setLayout(l_pGLContainerLayout);
    l_pGLContainerLayout->addWidget(m_WMeshGL);
    m_uiCreateAvatar->hlMesh->addWidget(m_pGLContainer);

	// init workers
    m_WCreateAvatar = new SWCreateAvatarWorker(&m_oKinectThread);

    // set connections
    //      menu
        QObject::connect(m_uiCreateAvatar->actionExit, SIGNAL(triggered()), parent, SLOT(quit()));
        QObject::connect(m_uiCreateAvatar->actionOnline_documentation, SIGNAL(triggered()), this, SLOT(openOnlineDocumentation()));
        QObject::connect(m_uiCreateAvatar->actionSave_result, SIGNAL(triggered()), this, SLOT(saveMeshFile()));
        QObject::connect(m_uiCreateAvatar->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutWindow()));
    //      start work
        QObject::connect(m_uiCreateAvatar->pbStart, SIGNAL(clicked()), this, SLOT(startWork()));
        QObject::connect(this, SIGNAL(startWorkSignal()), m_WCreateAvatar, SLOT(doWork()));

    //      stop work
        QObject::connect(m_uiCreateAvatar->pbStop, SIGNAL(clicked()), m_WCreateAvatar, SLOT(stopWork()));
        QObject::connect(this, SIGNAL(leaveProgram()), m_WCreateAvatar, SLOT(stopWork()));
        QObject::connect(m_WCreateAvatar, SIGNAL(stopWorkSignal()), SLOT(switchDetect()));

    //      reconstruct
        QObject::connect(m_uiCreateAvatar->pbReconstruct, SIGNAL(clicked()), m_WCreateAvatar, SLOT(reconstruct()));

    //      reset selected contours
        QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WCreateAvatar,      SLOT(resetDeletedPointsRadialProj()));
        QObject::connect(m_uiCreateAvatar->pbResetSelectedContours, SIGNAL(clicked()), m_WRadialProjDisplay, SLOT(resetSelectedPoints()));

    //      rectangles
        QObject::connect(m_WCreateAvatar, SIGNAL(sendFaceRect(cv::Rect*)), this, SLOT(updateFaceRectangle(cv::Rect*)));
        QObject::connect(m_WCreateAvatar, SIGNAL(sendNoseRect(cv::Rect*)), this, SLOT(updateNoseRectangle(cv::Rect*)));

    //      stasmm points
        QObject::connect(m_WCreateAvatar, SIGNAL(sendStasmPoints(std::vector<cv::Point2i>)), this, SLOT(updateStasmPoints(std::vector<cv::Point2i>)));

    //      cloud
        QObject::connect(m_WCreateAvatar, SIGNAL(sendCloud(swCloud::SWCloud*, bool)), m_WCloudGL, SLOT(setCloud(swCloud::SWCloud*, bool)));

    //      mesh
        QObject::connect(m_WCreateAvatar, SIGNAL(sendMesh(swMesh::SWMesh*,bool)), m_WMeshGL, SLOT(setMesh(swMesh::SWMesh*,bool)));
        QObject::connect(m_uiCreateAvatar->pbSaveAvatar, SIGNAL(clicked()), this,   SLOT(saveMeshFile()));
        QObject::connect(this,  SIGNAL(saveMeshFileSignal(QString)),  m_WCreateAvatar, SLOT(saveMeshFile(QString)));

    //      ui
        QObject::connect(m_WCreateAvatar, SIGNAL(switchTab(int)),m_uiCreateAvatar->tw3D,   SLOT(setCurrentIndex(int)));
        QObject::connect(m_WCreateAvatar, SIGNAL(enableInterfaceSignal()), this,   SLOT(enableInterface()));

    //      display
        QObject::connect(m_WCreateAvatar, SIGNAL(sendMat(cv::Mat*)),     this,  SLOT(updateRadialProjDisplay(cv::Mat*)));
        QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this,  SLOT(udpdateTexture3DDisplay(cv::Mat*)));        
        QObject::connect(m_WCreateAvatar, SIGNAL(sendTexture(cv::Mat*)), this,  SLOT(updateFaceTextureDisplay(cv::Mat*)));

    //      parameters
    //          projection
        QObject::connect(m_uiCreateAvatar->sbWidth,     SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setRadialWidth(const int)));
        QObject::connect(m_uiCreateAvatar->sbHeight,    SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setRadialHeight(const int)));
//        QObject::connect(m_uiCreateAvatar->dsbRadius,   SIGNAL(valueChanged(double)),m_WCreateAvatar, SLOT(setCylinderRadius(double)));
        QObject::connect(m_uiCreateAvatar->sbErode,     SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setErode(int)));
        QObject::connect(m_uiCreateAvatar->sbDilate,    SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setDilate(int)));
        QObject::connect(m_uiCreateAvatar->sbExpandValue,SIGNAL(valueChanged(int)), m_WCreateAvatar,  SLOT(setExpandValue(int)));
        QObject::connect(m_uiCreateAvatar->sbExpandConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar,  SLOT(setExpandConnex(int)));
        QObject::connect(m_uiCreateAvatar->sbEraseValue,SIGNAL(valueChanged(int)), m_WCreateAvatar,  SLOT(setEraseValue(int)));
        QObject::connect(m_uiCreateAvatar->sbEraseConnex,SIGNAL(valueChanged(int)), m_WCreateAvatar,  SLOT(setEraseConnex(int)));
    //          filter
        QObject::connect(m_uiCreateAvatar->sbColor,     SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setBilateralColor(const int)));
        QObject::connect(m_uiCreateAvatar->sbSpace,     SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setBilateralSpace(const int)));
//        QObject::connect(m_uiCreateAvatar->sbDiameter,  SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setBilateralDiameter(const int)));
        QObject::connect(m_uiCreateAvatar->sbClouds,    SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setCloudNumberValue(const int)));
        QObject::connect(m_uiCreateAvatar->cbBilateralFilter,SIGNAL(toggled(bool)) ,m_WCreateAvatar,  SLOT(setUseBilateralFilter(bool)));
    //          rgbd device
        QObject::connect(m_uiCreateAvatar->sbXOffset,   SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setCalibrationXValue(const int)));
        QObject::connect(m_uiCreateAvatar->sbYOffset,   SIGNAL(valueChanged(int)),  m_WCreateAvatar,  SLOT(setCalibrationYValue(const int)));
        QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)),  m_WCloudGL,      SLOT(setDepthRect(const double)));
        QObject::connect(m_uiCreateAvatar->dsbFaceDepth,SIGNAL(valueChanged(double)),  m_WCreateAvatar, SLOT(setDepthCloud(const double)));
    //          misc
        QObject::connect(m_uiCreateAvatar->cbSTASM,     SIGNAL(toggled(bool))      ,m_WCreateAvatar,  SLOT(setUseStasm(bool)));
    //          display
        QObject::connect(m_uiCreateAvatar->cbDisplayLines,   SIGNAL(toggled(bool)), m_WMeshGL,        SLOT(setMeshLinesRender(const bool)));
        QObject::connect(m_uiCreateAvatar->cbApplyTexture,   SIGNAL(toggled(bool)), m_WMeshGL,        SLOT(applyTexture(bool)));
//        QObject::connect(m_uiCreateAvatar->dsbFOV,      SIGNAL(valueChanged(double)),m_WMeshGL,       SLOT(setFOV(const double)));
//        QObject::connect(m_uiCreateAvatar->dsbFOV,      SIGNAL(valueChanged(double)),m_WCloudGL,      SLOT(setFOV(const double)));
        QObject::connect(m_WCreateAvatar,               SIGNAL(sendNumCloud(int)),  this,             SLOT(setNumCloud(const int)));

    //      reset kinect
        QObject::connect(m_uiCreateAvatar->sbDeviceMode,SIGNAL(valueChanged(int)),  this,             SLOT(resetKinect(int)));
        QObject::connect(m_WCreateAvatar,   SIGNAL(endResetKinect()),   this,       SLOT(releaseKinectMutex()));

    //      others
        QObject::connect(m_WRadialProjDisplay, SIGNAL(clickPoint(QPoint, QSize, bool)), m_WCreateAvatar,   SLOT(addPointToDeleteRadialProj(QPoint, QSize, bool)));

        // fullscreen
        QObject::connect(m_WMeshGL, SIGNAL(enableFullScreen()), this, SLOT(enableGLFullScreen()));
        QObject::connect(m_WMeshGL, SIGNAL(disableFullScreen()), this, SLOT(disableGLFullScreen()));

    // init worker parameters values
        // radial projection width / height
            m_WCreateAvatar->setRadialWidth(m_uiCreateAvatar->sbWidth->value());
            m_WCreateAvatar->setRadialHeight(m_uiCreateAvatar->sbHeight->value());
        // spatial filter
            m_WCreateAvatar->setBilateralColor(m_uiCreateAvatar->sbColor->value());
            m_WCreateAvatar->setBilateralSpace(m_uiCreateAvatar->sbSpace->value());
            m_WCreateAvatar->setBilateralDiameter(-1);
        // temporal filter
            m_WCreateAvatar->setCloudNumberValue(m_uiCreateAvatar->sbClouds->value());
        // calibration
            m_WCreateAvatar->setCalibrationXValue(m_uiCreateAvatar->sbXOffset->value());
            m_WCreateAvatar->setCalibrationYValue(m_uiCreateAvatar->sbYOffset->value());
        // expand / erase
            m_WCreateAvatar->setExpandValue(m_uiCreateAvatar->sbExpandValue->value());
            m_WCreateAvatar->setExpandConnex(m_uiCreateAvatar->sbExpandConnex->value());
            m_WCreateAvatar->setEraseValue(m_uiCreateAvatar->sbEraseValue->value());
            m_WCreateAvatar->setEraseConnex(m_uiCreateAvatar->sbEraseConnex->value());
        // dilate / erode
            m_WCreateAvatar->setDilate(m_uiCreateAvatar->sbDilate->value());
            m_WCreateAvatar->setErode(m_uiCreateAvatar->sbErode->value());
        // stasm
            m_WCreateAvatar->setUseStasm(m_uiCreateAvatar->cbSTASM->isChecked());

        // cloud
            m_WCloudGL->setDepthRect(m_uiCreateAvatar->dsbFaceDepth->value());
            m_WCreateAvatar->setDepthCloud(m_uiCreateAvatar->dsbFaceDepth->value());

    // desactive debug interface components
//            m_uiCreateAvatar->laPixelDiameter->setVisible(false);
//            m_uiCreateAvatar->sbDiameter->setVisible(false);
//            m_uiCreateAvatar->laCynlinderRadius->setVisible(false);
//            m_uiCreateAvatar->dsbRadius->setVisible(false);
//            m_uiCreateAvatar->laFOV->setVisible(false);
//            m_uiCreateAvatar->dsbFOV->setVisible(false);
    setStyleSheet("QGroupBox { padding: 10 0px 0 0px; color: blue; border: 1px solid gray; border-radius: 5px; margin-top: 1ex; /* leave space at the top for the title */}");


    // init and start create avatar thread
        m_WCreateAvatar->moveToThread(&m_TCreateAvatar);
        m_TCreateAvatar.start();

    // init face detection
        m_CFaceDetectPtr = SWFaceDetectionPtr(new swDetect::SWFaceDetection(cv::Size(80,80)));
        m_oLastRectFace.width = 0;

    // launch timer for updating the display widget
        m_oTimer->start(1000/30, this);
}
Exemple #4
0
	bool WGLWindow::initWindow()
	{
		DWORD dwStyle = WS_OVERLAPPEDWINDOW;
		DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;

		// Adjust window to true requested size
		RECT windowRect;
		windowRect.left = pLeft;
		windowRect.right = (long)pWidth;
		windowRect.top = pTop;
		windowRect.bottom = (long)pHeight;
		::AdjustWindowRectEx(&windowRect, dwStyle, false, dwExStyle);

		// Create the window
		if (!(pHWnd = ::CreateWindowEx(
			dwExStyle, L"OpenGL", WString{pTitle}.c_str(),
			dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
			pLeft, pTop, // Position
			windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, // Dimensions
			nullptr, nullptr, pHInstance, nullptr)))
		{
			std::cerr << "Window init error : Window creation failed !" << std::endl;
			std::cerr << "Error : \"" << GetLastError() << "\"" << std::endl;
			kill();
			return false;
		}

		RegisterWindow(pHWnd, this);


		// Get the Device Context
		if (!(pHDC = ::GetDC(pHWnd)))
		{
			std::cerr << "Window init error : Can't create a Device Context !" << std::endl;
			kill();
			return false;
		}

		const ::PIXELFORMATDESCRIPTOR pfd =
			{
				// Size
				(WORD)sizeof (::PIXELFORMATDESCRIPTOR),
				// Version
				1,
				// Flags
				PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED,
				// Pixel Type
				PFD_TYPE_RGBA,
				// Color depth
				(BYTE)pBitDepth,
				// Color bits ignored
				0, 0, 0, 0, 0, 0,
				// No alpha buffer
				0,
				// Shift bit ignored
				0,
				// No accumulation buffer
				0,
				// Accumulation bits ignored
				0, 0, 0, 0,
				// 24-bit Z-buffer (Depth Buffer)
				24,
				// 8-bit stencil buffer
				8,
				// No auxiliary buffer
				0,
				// Main drawing layer
				PFD_MAIN_PLANE,
				// Reserved
				0,
				// Layer masks ignored
				0, 0, 0
			};

		// Try MSAA init
		if (pHasMSAASupport && pMultiSampling != MultiSampling::msNone)
		{
			if (!initMultisamplePixelFormat(pfd, true))
			{
				// If MSAA init failed, set the requested multisampling to none
				pMultiSampling = MultiSampling::msNone;
				initDefaultPixelFormat(pfd); // Should work, since it worked once before
			}
		}
		else
		{
			// Dummy format to create a GL context
			if (!initDefaultPixelFormat(pfd))
			{
				std::cerr << "Window init error : Can't set pixel format !" << std::endl;
				kill();
				return false;
			}
		}

		// Create a Rendering Context if necessary
		if (!(pHRC = ::wglCreateContext(pHDC)))
		{
			std::cerr << "Window init error : Can't create a GL rendering context !" << std::endl;
			kill();
			return false;
		}

		// Activate the Rendering Context
		if (!::wglMakeCurrent(pHDC, pHRC))
		{
			std::cerr << "Window init error : Can't activate the GL rendering context !" << std::endl;
			kill();
			return false;
		}

		// Initialize our newly created GL window
		if (!GLWindow::initialize())
		{
			std::cerr << "OpenGL Initialization Failed !" << std::endl;
			kill();
			return false;
		}

		if (!pHasMSAASupport && pMultiSampling != MultiSampling::msNone &&
			initMultisamplePixelFormat(pfd, false))
		{
			pHasMSAASupport = true;
			closeWindowForReinit();
			::wglDeleteContext(pHRC);
			initWindow();
		}

		// On success, enable multisampling
		if (pHasMSAASupport && pMultiSampling != MultiSampling::msNone)
			::glEnable(GL_MULTISAMPLE);
		else
			::glDisable(GL_MULTISAMPLE);

		// Show the window
		::ShowWindow(pHWnd,SW_SHOW);
		// Slightly higher priority
		::SetForegroundWindow(pHWnd);
		// Sets keyboard focus to the window
		::SetFocus(pHWnd);

		// Set up our perspective GL screen
		internalResize(pWidth, pHeight);

		TRACKMOUSEEVENT tme;
		tme.cbSize = (DWORD)sizeof(TRACKMOUSEEVENT);
		tme.dwFlags = TME_LEAVE | TME_HOVER;
		tme.hwndTrack = pHWnd;
		tme.dwHoverTime = HOVER_DEFAULT;
		::TrackMouseEvent(&tme);

		if (pFullScreen)
		{
			if (!enableFullScreen())
				pFullScreen = false;
		}

		return true;
	}