@@ -27,6 +27,10 @@ import kotlin.math.sin
2727
2828class MainFragment (activity : MainActivity ) : AppFragment(activity) {
2929 companion object {
30+ const val TITLE_ANALYSE = " Analyse"
31+ const val TITLE_STABILIZE = " Stabilize"
32+ const val TITLE_SAVE = " Save"
33+
3034 const val INTENT_OPEN_VIDEO = 2
3135 const val INTENT_OPEN_IMAGES = 3
3236 const val INTENT_OPEN_FOLDER = 4
@@ -246,13 +250,13 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
246250
247251
248252 private fun handleStabilize () {
249- runAsync(" Stabilize " ) {
253+ runAsync(TITLE_STABILIZE ) {
250254 stabApplyAsync()
251255 }
252256 }
253257
254258 private fun handleSave () {
255- runAsync(" Save " ) {
259+ runAsync(TITLE_SAVE ) {
256260 saveAsync()
257261 }
258262 }
@@ -335,12 +339,11 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
335339 var a = 0.0
336340
337341 framesInput.forEachFrame { index, size, readFrame ->
338- if (firstFrame.empty()) firstFrame = readFrame.clone()
339342 cvtColor(readFrame, frames[currentIndex], COLOR_BGR2GRAY )
340343 val scale = scaleForAnalyse(frames[currentIndex])
341344
342345 frameCounter++
343- BusyDialog .updateProgress( index, size)
346+ BusyDialog .show( TITLE_ANALYSE , index, size)
344347
345348 if (! frames[prevIndex].empty()) {
346349 // Detect features in previous frame
@@ -465,8 +468,6 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
465468 }
466469
467470 private fun stabApplyAsync () {
468- BusyDialog .show(" Smooth movements" )
469-
470471 val framesInput = this .framesInput ? : return
471472 val trajectory = videoTrajectory ? : return
472473
@@ -571,9 +572,8 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
571572 val frameStabilized = Mat ()
572573 val t = Mat (2 , 3 , CV_64F )
573574
574- BusyDialog .show(" Stabilize" )
575575 framesInput.forEachFrame { index, size, frame ->
576- BusyDialog .updateProgress( index, size)
576+ BusyDialog .show( TITLE_STABILIZE , index, size)
577577
578578 transforms.getTransform(index, t)
579579 warpAffine(frame, frameStabilized, t, frame.size())
@@ -633,6 +633,7 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
633633 }
634634
635635 firstFrame = framesInput.firstFrame()
636+ scaleForAnalyse(firstFrame)
636637 }
637638 }
638639
@@ -668,7 +669,7 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
668669
669670 private fun stabAnalyse () {
670671 videoTrajectory = null
671- runAsync(" Analyse " ) { stabAnalyzeAsync() }
672+ runAsync(TITLE_ANALYSE ) { stabAnalyzeAsync() }
672673 }
673674
674675 private fun updateView () {
0 commit comments