CaptureDialog::CaptureDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CaptureDialog),
    imgPhase1(0),
    imgPhase2(0),
    imgPhase3(0),
    m_capture(0),
    m_frame(0),
    m_state(Empty),
    m_width(640),
    m_height(480),
    m_aspect(0.75f),
    m_timer(0)

{
    ui->setupUi(this);


    // disable Ok button
    ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);

    // connect slots
    connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(reset()));
    connect(ui->grabButton, SIGNAL(clicked()), this, SLOT(grabImage()));

    // initialize capture
    m_capture = cvCreateCameraCapture(1);
    if(m_capture) {
        // grab first frame to
        m_frame = cvQueryFrame(m_capture);
    }

    if(m_frame) {
        int w = m_frame->width;
        int h = m_frame->height;

        // aspect ratio heigh/width
        m_aspect = h/(float)w;
        m_width  = w <= m_width? w : m_width;
        m_height = (int) m_width*m_aspect;

        updateLayout();
        cout << "Update Layout" << endl;
    }

    // periodically update frame
    m_timer = new QTimer(this);
    connect(m_timer,SIGNAL(timeout()),this,SLOT(refreshFrame()));
    m_timer->start(50);

}
Example #2
0
void LocalsTree::refresh(){
	if( !envron || !frames.size() ) return;

	HTREEITEM item=GetChildItem( TVI_ROOT );

	int n=0;
	for( n=0;n<frames.size();++n ){
		if( !item || item!=frames[n].item ) break;
		item=GetNextSiblingItem( item );
	}

	while( item ){
		HTREEITEM next=GetNextSiblingItem( item );
		DeleteItem( item );
		item=next;
	}

	for( ;n<frames.size();++n ){
		item=frames[n].item=InsertItem( frames[n].func,TVI_ROOT,TVI_LAST );
		if( n<frames.size()-1 ) refreshFrame( frames[n] );
	}

	refreshFrame( frames.back() );
}
Example #3
0
int FaceDetectApp::mainLoop(int argc, char* argv[])
{
    QApplication app(argc, argv);
    desktop = QApplication::desktop();
//    myClient = new Client();
    //myClient->setFixedSize(desktop->width() / 3, desktop->height() / 3);
    mainWindow = new QMainWindow();
    timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(refreshFrame()));
    buildMenuBar();

    resultPrinter.insert(std::pair<const char*, MyQtGui*>(WEBCAM_RAW_WINDOW_TITLE, new MyQtGui(timer)));
    resultPrinter.insert(std::pair<const char*, MyQtGui*>(WEBCAM_DETECT_WINDOW, new MyQtGui(timer)));
    resultPrinter.insert(std::pair<const char*, MyQtGui*>(WEBCAM_MVT_WINDOW, new MyQtGui(timer)));
    resultPrinter.insert(std::pair<const char*, MyQtGui*>(WEBCAM_COLOR_WINDOW, new MyQtGui(timer)));
    resultPrinter.insert(std::pair<const char*, MyQtGui*>(WEBCAM_CONTOUR_WINDOW, new MyQtGui(timer)));

    widget = new QWidget();
    layout = new QGridLayout();

    layout->addWidget(resultPrinter[WEBCAM_RAW_WINDOW_TITLE], 0, 0);
    layout->addWidget(resultPrinter[WEBCAM_DETECT_WINDOW], 0, 1);
    layout->addWidget(resultPrinter[WEBCAM_MVT_WINDOW], 1, 0);
    layout->addWidget(resultPrinter[WEBCAM_COLOR_WINDOW], 1, 1);
    layout->addWidget(resultPrinter[WEBCAM_CONTOUR_WINDOW], 1, 2);
//    layout->addWidget(myClient, 0, 2);

    widget->setLayout(layout);
    mainWindow->setCentralWidget(widget);
    mainWindow->show();

    timer->start(WAITING_TIME_IN_MS);
    myServer = new WebSocketServer(8082, QtWebsocket::Tcp);
//    client.show();
    return app.exec();
}