Prechádzať zdrojové kódy

fixed videoInputProvider next/previous frame at start/end of movie

Alexander Hendrich 10 rokov pred
rodič
commit
5fe760f528

+ 1 - 1
bbiwarg/Constants.cs

@@ -18,7 +18,7 @@ namespace bbiwarg
     class Constants
     {
         // input
-        public static readonly InputType InputSource = InputType.Camera;
+        public static readonly InputType InputSource = InputType.Movie;
         public static readonly String InputMoviePath = "..\\..\\videos\\touch\\4.skv";
 
         // Logger

+ 4 - 2
bbiwarg/InputProviders/VideoInputProvider.cs

@@ -15,6 +15,7 @@ namespace bbiwarg.InputProviders
         public bool IsPaused { get { return (playStep.Value == 0); } }
 
         private IParameterHandle<int> currentMovieFrame;
+        private IParameterHandle<int> frameCount;
         private IParameterHandle<int> playStep;
 
         public VideoInputProvider(String moviePath)
@@ -35,6 +36,7 @@ namespace bbiwarg.InputProviders
 
             device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayMode").Value = 1; // 0=once, 1=loop, 2=pingPong
             currentMovieFrame = device.RegisterParameterHandle<int>("SOURCE.MOVIE.CurrentFrame");
+            frameCount = device.RegisterParameterHandle<int>("SOURCE.MOVIE.FrameCount");
             playStep = device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayStep");
         }
 
@@ -53,7 +55,7 @@ namespace bbiwarg.InputProviders
         public void nextFrame()
         {
             playStep.Value = 1;
-            int nextFrame = currentMovieFrame.Value + 1;
+            int nextFrame = Math.Min((currentMovieFrame.Value + 1), frameCount.Value - 1);
             while (currentMovieFrame.Value != nextFrame)
             {
                 device.UpdateFrame(true);
@@ -66,7 +68,7 @@ namespace bbiwarg.InputProviders
         public void previousFrame()
         {
             playStep.Value = -1;
-            int previousFrame = currentMovieFrame.Value - 1;
+            int previousFrame = Math.Max((currentMovieFrame.Value - 1), 0);
             while (currentMovieFrame.Value != previousFrame)
             {
                 device.UpdateFrame(true);