void CaptureDialog::stop_camera(void) { if ( mCamera && mCamera->isLiveViewing() ) { mCamera->endLiveView(); } //disconnect display signal first disconnect(&_video_input, SIGNAL(new_image(cv::Mat)), this, SLOT(_on_new_camera_image(cv::Mat))); //clean up QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); //busy cursor QApplication::processEvents(); //process pending signals camera_image->clear(); camera_resolution_label->clear(); //stop the thread if (_video_input.isRunning()) { _video_input.stop(); _video_input.wait(); } //restore regular cursor QApplication::restoreOverrideCursor(); QApplication::processEvents(); }
void CaptureDialog::on_close_cancel_button_clicked(bool checked) { if (close_cancel_button->text()=="Close") { if ( mCamera && mCamera-> isLiveViewing() ) { mCamera->endLiveView(); } accept(); } else if (!_cancel) { _cancel = true; } }
void CaptureDialog::_on_new_camera_image(cv::Mat image) { // only show webcam resolution, not DSLR if ( mCamera == NULL ) { camera_resolution_label->setText(QString("[%1x%2]").arg(image.cols).arg(image.rows)); } if (_capture) { // take picture using DSLR if there is one if (mCamera) { if ( mCamera->isLiveViewing() ) mCamera->endLiveView(); takePicture(); } // take picture using webcam if there is no DSLR else { camera_image->setImage(image); cv::imwrite(QString("%1/cam_%2.png").arg(_session).arg(_projector.get_current_pattern() + 1, 2, 10, QLatin1Char('0')).toStdString(), image); } _capture = false; _projector.clear_updated(); } else { if ( mCamera ) { if( mCamera->isLiveViewing() == false ) mCamera->startLiveView(); QImage img; mCamera->requestDownloadEvfData( img ); cv::Mat mat = cv::Mat(img.height(), img.width(), CV_8UC3, img.bits(), img.bytesPerLine()); camera_image->setImage(mat); } else { camera_image->setImage(image); } } }