diff --git a/toonz/sources/stopmotion/stopmotion.cpp b/toonz/sources/stopmotion/stopmotion.cpp index 798566c3..e8ba0ff0 100644 --- a/toonz/sources/stopmotion/stopmotion.cpp +++ b/toonz/sources/stopmotion/stopmotion.cpp @@ -224,13 +224,15 @@ StopMotion::StopMotion() { m_timer = new QTimer(this); m_reviewTimer = new QTimer(this); m_reviewTimer->setSingleShot(true); - m_intervalTimer = new QTimer(this); - m_countdownTimer = new QTimer(this); + m_intervalTimer = new QTimer(this); + m_countdownTimer = new QTimer(this); + m_webcamOverlayTimer = new QTimer(this); // Make the interval timer single-shot. When the capture finished, restart // timer for next frame. // This is because capturing and saving the image needs some time. m_intervalTimer->setSingleShot(true); + m_webcamOverlayTimer->setSingleShot(true); TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet(); TSceneHandle *sceneHandle = TApp::instance()->getCurrentScene(); @@ -249,6 +251,8 @@ StopMotion::StopMotion() { SLOT(onPlaybackChanged())); ret = ret && connect(m_intervalTimer, SIGNAL(timeout()), this, SLOT(onIntervalCaptureTimerTimeout())); + ret = ret && connect(m_webcamOverlayTimer, SIGNAL(timeout()), this, + SLOT(captureWebcamOnTimeout())); ret = ret && connect(m_canon, SIGNAL(newCanonImageReady()), this, SLOT(importImage())); assert(ret); @@ -1345,8 +1349,6 @@ void StopMotion::onReviewTimeout() { //----------------------------------------------------------------------------- bool StopMotion::importImage() { - m_light->hideOverlays(); - TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TXsheet *xsh = scene->getXsheet(); @@ -1361,6 +1363,9 @@ bool StopMotion::importImage() { if (m_usingWebcam) { m_newImage = m_liveViewImage; } + + m_light->hideOverlays(); + int frameNumber = m_frameNumber; /* create parent directory if it does not exist */ @@ -1672,15 +1677,21 @@ void StopMotion::captureImage() { DVGui::warning(tr("Please start live view before capturing an image.")); return; } + if (m_usingWebcam) { - if (!m_hasLiveViewImage || m_liveViewStatus != LiveViewOpen) { - DVGui::warning( - tr("Cannot capture webcam image unless live view is active.")); - return; - } + captureWebcamImage(); + } else { + captureDslrImage(); + } +} +//----------------------------------------------------------------------------- + +void StopMotion::captureWebcamImage() { + if (m_light->useOverlays()) { m_light->showOverlays(); - + m_webcamOverlayTimer->start(500); + } else { if (getReviewTime() > 0 && !m_isTimeLapse) { m_timer->stop(); if (m_liveViewStatus > LiveViewClosed) { @@ -1693,6 +1704,26 @@ void StopMotion::captureImage() { importImage(); return; } +} + +//----------------------------------------------------------------------------- +void StopMotion::captureWebcamOnTimeout() { + if (getReviewTime() > 0 && !m_isTimeLapse) { + m_timer->stop(); + if (m_liveViewStatus > LiveViewClosed) { + // m_liveViewStatus = LiveViewPaused; + } + } + m_lineUpImage = m_liveViewImage; + m_hasLineUpImage = true; + emit(newLiveViewImageReady()); + importImage(); + return; +} + +//----------------------------------------------------------------------------- + +void StopMotion::captureDslrImage() { m_light->showOverlays(); if (getReviewTime() > 0 && !m_isTimeLapse) { diff --git a/toonz/sources/stopmotion/stopmotion.h b/toonz/sources/stopmotion/stopmotion.h index 0ac64c10..b1b5d805 100644 --- a/toonz/sources/stopmotion/stopmotion.h +++ b/toonz/sources/stopmotion/stopmotion.h @@ -91,7 +91,7 @@ public: QTimer* m_timer; int m_intervalTime = 10; bool m_intervalStarted = false; - QTimer *m_intervalTimer, *m_countdownTimer; + QTimer *m_intervalTimer, *m_countdownTimer, *m_webcamOverlayTimer; // live view and images int m_liveViewStatus = LiveViewClosed; @@ -145,6 +145,8 @@ public: bool loadLineUpImage(); void setLiveViewImage(); void captureImage(); + void captureWebcamImage(); + void captureDslrImage(); void postImportProcess(); // time lapse @@ -185,7 +187,7 @@ public slots: void onTimeout(); void onReviewTimeout(); void onIntervalCaptureTimerTimeout(); - + void captureWebcamOnTimeout(); void update(); bool importImage(); void onSceneSwitched(); diff --git a/toonz/sources/stopmotion/stopmotionlight.cpp b/toonz/sources/stopmotion/stopmotionlight.cpp index 8c36d233..e933a878 100644 --- a/toonz/sources/stopmotion/stopmotionlight.cpp +++ b/toonz/sources/stopmotion/stopmotionlight.cpp @@ -139,6 +139,7 @@ void StopMotionLight::showOverlays() { // taking a photo qApp->processEvents(QEventLoop::AllEvents, 1500); } + m_overlaysReady = true; } //----------------------------------------------------------------- @@ -153,4 +154,12 @@ void StopMotionLight::hideOverlays() { if (m_screenCount > 2 && (getBlackCapture() || m_useScreen3Overlay)) { m_fullScreen3->hide(); } + m_overlaysReady = false; +} + +//----------------------------------------------------------------- + +bool StopMotionLight::useOverlays() { + return m_blackCapture || m_useScreen1Overlay || m_useScreen2Overlay || + m_useScreen3Overlay; } diff --git a/toonz/sources/stopmotion/stopmotionlight.h b/toonz/sources/stopmotion/stopmotionlight.h index d25fc9c7..3bd06a80 100644 --- a/toonz/sources/stopmotion/stopmotionlight.h +++ b/toonz/sources/stopmotion/stopmotionlight.h @@ -25,6 +25,7 @@ public: bool m_useScreen2Overlay = false; bool m_useScreen3Overlay = false; bool m_blackCapture = true; + bool m_overlaysReady = false; int m_screenCount = 1; TPixel32 m_screen1Color, m_screen2Color, m_screen3Color = TPixel32(0, 0, 0, 255); @@ -39,6 +40,7 @@ public: void setScreen3UseOverlay(bool on); void showOverlays(); void hideOverlays(); + bool useOverlays(); signals: void blackCaptureSignal(bool);