void ColibriMainWindow::on_camButton_toggled(bool checked) { if(!checked) { if(m_timer.isActive()) m_timer.stop(); // Stop thread if(m_pColibriThread) { m_pColibriThread->stop(); m_pColibriThread->setCapture(NULL); } cvReleaseCapture(&capture); capture = NULL; return; } if(!capture) { int retry = 0; do { capture = cvCreateCameraCapture (retry); fprintf(stderr, "[Colibri] %s:%d : capture #%d =%p\n", __func__, __LINE__, retry, capture); retry++; } while(!capture && retry < 5); } if(!capture) { QMessageBox::critical(NULL, tr("No webcam"), tr("Unable to find webcam. Please try disconnect/reconnect.")); return ; } startBackgroundThread(); }
int XMonitor::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: showServerView(); break; case 1: showReportView(); break; case 2: startBackgroundThread(); break; case 3: stopBackgroundThread(); break; default: ; } _id -= 4; } return _id; }
void ColibriMainWindow::on_movieButton_toggled(bool checked) { if(!checked) { if(m_timer.isActive()) { m_timer.stop(); } // Stop thread if(m_pColibriThread) { m_pColibriThread->stop(); m_pColibriThread->setCapture(NULL); } cvReleaseCapture(&capture); capture = NULL; return; } if(!capture) { QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), mLastSettings.lastMoviesDir, tr("Movies (*.avi *.mp* *.mov)")); if(fileName.isEmpty()) return; QFileInfo fi(fileName); if(!fi.exists()) return; mLastSettings.lastMoviesDir = fi.absolutePath(); saveSettings(); capture = cvCaptureFromFile( fi.absoluteFilePath().toUtf8().data() ); fprintf(stderr, "%s:%d : capture=%p\n", __func__, __LINE__, capture); startBackgroundThread(); } }