Exemplo n.º 1
0
        public void TestSideCamera90()
        {
            ObsTransform results = TestImageHelper.ProcessImage("SideCamera90");

            Assert.AreEqual(90, results.Rotation, 3);
            Assert.AreEqual(23, results.Origin.X, 3);
            Assert.AreEqual(85, results.Origin.Y, 3);
            Assert.AreEqual(0.9, results.Opacity, OpacityTolerance);
            Assert.AreEqual(0.9 / 4, results.Scale, 0.9 * ScaleTolerance);
            Assert.AreEqual(false, results.Flipped);
            Assert.AreEqual(1, results.Camera);
        }
Exemplo n.º 2
0
        public void Test500pxMargins()
        {
            ObsTransform results = TestImageHelper.ProcessImage("CodingGorilla");

            Assert.AreEqual(0, results.Rotation, RotationTolerance);
            Assert.AreEqual(1, results.Opacity, OpacityTolerance);
            Assert.AreEqual(1, results.Scale, 0.45 * ScaleTolerance);
            Assert.AreEqual(960, results.Origin.X, 1102);
            Assert.AreEqual(540, results.Origin.Y, 1058);
            Assert.AreEqual(false, results.Flipped);
            Assert.AreEqual(0, results.Camera);
        }
Exemplo n.º 3
0
        public void Test53Flipped()
        {
            ObsTransform results = TestImageHelper.ProcessImage("53Flipped");

            Assert.AreEqual(-53, results.Rotation, 3);
            Assert.AreEqual(61, results.Origin.X, 3);
            Assert.AreEqual(54, results.Origin.Y, 3);
            Assert.AreEqual(0.53, results.Opacity, OpacityTolerance);
            Assert.AreEqual(0.53 / 4, results.Scale, 0.53 * ScaleTolerance);
            Assert.AreEqual(true, results.Flipped);
            Assert.AreEqual(0, results.Camera);
        }
Exemplo n.º 4
0
        public void TestScreenTrackerOrigin()
        {
            ObsTransform results = TestImageHelper.ProcessImage("ScreenTrackerOrigin");

            Assert.AreEqual(0, results.Rotation, RotationTolerance);
            Assert.AreEqual(1, results.Opacity, OpacityTolerance);
            Assert.AreEqual(1, results.Scale, 0.45 * ScaleTolerance);
            Assert.AreEqual(960, results.Origin.X, 2);
            Assert.AreEqual(540, results.Origin.Y, 2);
            Assert.AreEqual(false, results.Flipped);
            Assert.AreEqual(0, results.Camera);
        }
Exemplo n.º 5
0
        public void TestCamera3_270()
        {
            ObsTransform results = TestImageHelper.ProcessImage("Camera3-270");

            Assert.AreEqual(-90, results.Rotation);
            Assert.AreEqual(1, results.Opacity);
            Assert.AreEqual(1, results.Scale);
            Assert.AreEqual(1136, results.Origin.X, 0.15);
            Assert.AreEqual(364, results.Origin.Y, 0.15);
            Assert.AreEqual(false, results.Flipped);
            Assert.AreEqual(3, results.Camera);
        }
Exemplo n.º 6
0
        public void TestCamera2_180()
        {
            ObsTransform results = TestImageHelper.ProcessImage("Camera2-180");

            Assert.AreEqual(180, results.Rotation);
            Assert.AreEqual(1, results.Opacity);
            Assert.AreEqual(1, results.Scale);
            Assert.AreEqual(960, results.Origin.X, 0.15);
            Assert.AreEqual(188, results.Origin.Y, 0.15);
            Assert.AreEqual(false, results.Flipped);
            Assert.AreEqual(2, results.Camera);
        }
Exemplo n.º 7
0
        private void RenderFrame(out double duration, out bool shouldStop)
        {
            shouldStop = false;
            ObsTransform liveFeedFrame = LiveFeedSequences[FrameAnimator.FrameIndex];

            if (liveFeedFrame == null)
            {
                FrameAnimator.Stop();
                shouldStop = true;
            }
            RenderActiveFrame(liveFeedFrame);
            duration = liveFeedFrame.Duration;
        }
Exemplo n.º 8
0
        private void SaveFrames(string movementFileName)
        {
            LiveFeedAnimator liveFeedAnimator = GetLiveFeedAnimator(movementFileName);

            liveFeedAnimator.LiveFeedSequences.Clear();

            bool firstTime = true;

            ObsTransform lastLiveFeedSequence = null;

            foreach (ObsTransformEdit liveFeedEdit in allFrames)
            {
                ObsTransform liveFeedSequence = new ObsTransform()
                {
                    Camera   = liveFeedEdit.Camera,
                    Rotation = liveFeedEdit.GetRotation(),
                    Scale    = liveFeedEdit.GetScale(),
                    Opacity  = liveFeedEdit.GetOpacity(),
                    Origin   = new CommonCore.Point2d(liveFeedEdit.GetX(), liveFeedEdit.GetY()),
                    Flipped  = liveFeedEdit.Flipped,
                    Duration = secondsPerFrame
                };
                if (firstTime)
                {
                    firstTime = false;
                }
                else
                {
                    if (lastLiveFeedSequence.Matches(liveFeedSequence))                      // Compress movement...
                    {
                        lastLiveFeedSequence.Duration += secondsPerFrame;
                        continue;
                    }
                }
                liveFeedAnimator.LiveFeedSequences.Add(liveFeedSequence);

                lastLiveFeedSequence = liveFeedSequence;
            }

            // Only saves for the active movement file. So if I make changes to two different movement files in
            // the same edit session, I need to save twice - use the radio buttons to decide what I'm saving.
            string fullPathToMovementFile = VideoAnimationManager.GetFullPathToMovementFile(movementFileName);
            string serializedTransforms   = Newtonsoft.Json.JsonConvert.SerializeObject(liveFeedAnimator.LiveFeedSequences, Newtonsoft.Json.Formatting.Indented);

            System.IO.File.WriteAllText(fullPathToMovementFile, serializedTransforms);
        }
        private void btnConvertToMovementFile_Click(object sender, EventArgs e)
        {
            prgConvertingFiles.Visible = true;
            if (filesToProcess == null)
            {
                MessageBox.Show("Select files first!");
                return;
            }

            List <ObsTransform> results   = new List <ObsTransform>();
            const double        frameRate = 30;       // 30 frames per second
            const double        intervalBetweenFramesSeconds = 1 /* frame */ / frameRate;

            ObsTransform lastProcessImageResults = null;
            int          frameIndex          = 0;
            int          totalFilesToProcess = filesToProcess.Count;

            foreach (string file in filesToProcess)
            {
                ObsTransform processImageResults = TestImageHelper.ProcessImage(file);
                processImageResults.FrameIndex = frameIndex;
                frameIndex++;
                ShowProgress(100 * frameIndex / totalFilesToProcess);

                if (processImageResults.Matches(lastProcessImageResults))
                {
                    lastProcessImageResults.Duration += intervalBetweenFramesSeconds;
                    lastProcessImageResults.FrameCount++;
                }
                else
                {
                    processImageResults.Duration = intervalBetweenFramesSeconds;
                    results.Add(processImageResults);
                    lastProcessImageResults = processImageResults;
                }
            }

            // TODO: Do we delete all *.pngs?

            // Save the movement data...
            string serializedObject = JsonConvert.SerializeObject(results, Formatting.Indented);

            System.IO.File.WriteAllText(movementFileName, serializedObject);
            prgConvertingFiles.Visible = false;
        }
Exemplo n.º 10
0
        public void TestRotation(string imageName, double expectedRotation)
        {
            ObsTransform results = TestImageHelper.ProcessImage(imageName);

            Assert.AreEqual(expectedRotation, results.Rotation, RotationTolerance);
        }