Exemple #1
0
        private static void Main(string[] args)
        {
            // application setup
            XmlConfigurator.Configure();
            ILog log    = LogManager.GetLogger("app");
            var  config = new Configuration();

            // the magic
            VideoProcessor videoProcessor = new VideoProcessor(log, config);

            TTPointsEngine engine = new TTPointsEngine();

            videoProcessor.BallDetected = (p) =>
            {
                engine.TryCoordinates(p);
            };


            var processingTask = Task.Run(() => { videoProcessor.Process(@"C:\hackathon\input\video4.mov"); });


            Console.ReadKey(true);

            videoProcessor.ShouldStop = true;

            Task.WaitAll(processingTask);
        }
Exemple #2
0
        public ActionResult Delete(int videoID)
        {
            var videoProcessor = new VideoProcessor(_repository);

            videoProcessor.DeleteVideo(videoID);
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public VideoConfig(string file, Settings.CoreSettings settings)
        {
            try
            {
                if (!settings.AcceptedVideoFiles.Contains(Path.GetExtension(file).TrimStart('.')))
                {
                    IsValid = false;
                }
                else
                {
                    MediaInfo fileInfo = VideoProcessor.GetVideoInfo(file);

                    FullPath         = file;
                    DurationTimeSpan = fileInfo.Duration;

                    if (string.IsNullOrEmpty(FileName) || string.IsNullOrEmpty(FilePath))
                    {
                        IsValid = false;
                    }
                    else
                    {
                        OutputDirectory = $"{Path.GetFileNameWithoutExtension(file)} {DateTime.Now:yyyyMMdd_HHmmss}";

                        FullOutputDirectory = Path.Combine(settings.OutputDirectory, OutputDirectory);

                        IsValid = true;
                    }
                }
            }
            catch (Exception)
            {
                IsValid = false;
            }
        }
Exemple #4
0
        public void Setup()
        {
            logMock    = new Mock <ILog>();
            configMock = new Mock <Configuration>();

            processor = new VideoProcessor(logMock.Object, configMock.Object);
        }
Exemple #5
0
        public void ReturnsFalseOngameplay()
        {
            // All the of the test frames in ./1080 should be from game stills so never black
            string[] filePaths  = Directory.GetFiles("./Test/testdata/frames/1080/gameplay", "*.png", SearchOption.TopDirectoryOnly);
            byte[]   data       = new byte[1080 * 1920 * 3];
            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            foreach (string fn in filePaths)
            {
                if (fn.Contains("clear_"))
                {
                    continue;
                }
                var testFrame = new Image <Bgr, byte>(fn);

                // Test frame MUST be 1920x1080 otherwise a black frame will be returned with no errors or warnings
                Assert.IsTrue(testFrame.Size.Width == 1920);
                Assert.IsTrue(testFrame.Size.Height == 1080);

                Mat currentFrame = new Mat(testFrame.Size, DepthType.Cv8U, 3, dataHandle.AddrOfPinnedObject(), testFrame.Width * 3);
                testFrame.Mat.CopyTo(currentFrame);
                var hues = VideoProcessor.getHues(data, testFrame.Size);
                Assert.IsFalse(VideoProcessor.isClearFrame(hues));
            }
        }
        private Point getLocation(Image <Bgr, byte> frame, Rectangle roi)
        {
            frame.ROI = roi;

            // Get hues of frame
            Dictionary <int, int> hues = VideoProcessor.getHues(frame.Mat.GetRawData(), frame.ROI.Size, 3);

            try
            {
                int colorCoverage;

                // Check for nearby hues from this.color
                for (int hue = this.color + 2; hue > 0 && hue >= this.color - 2; hue--)
                {
                    if (hues.TryGetValue(hue, out colorCoverage))
                    {
                        if (colorCoverage > (threshold * 100))
                        {
                            _size = new Size(roi.Size.Width, roi.Size.Height);
                            return(roi.Location);
                        }
                    }
                }

                return(Point.Empty);
            }
            finally
            {
                frame.ROI = Rectangle.Empty;
            }
        }
Exemple #7
0
        //exposed public method to process video on demand. Protocol is basic-HTTP. See system.serviceModel section of Config file for more details.
        public string ProcessVideo(string videoFilename, bool search = true, bool onDemand = true)
        {
            Syncre_LayerB_librabry.VideoProcessor vp = new VideoProcessor();            //uses Syncre_LayerAB_Service_Library

            vp.SetSearchServerEndpoint(ConfigurationManager.AppSettings.Get("SearchServerAddress"));
            return(vp.ProcessVideo(videoFilename, search, onDemand, true));  //keep frames
        }
Exemple #8
0
    // Start is called before the first frame update
    void Start()
    {
        _videoProcessor = new VideoProcessor();

        BindTextureToMaterial();
        InitOpenGL();
        DrawOpenGL(2);
    }
Exemple #9
0
        public MainWindowViewModel()
        {
            baseUrl     = "https://pt.potawe.com/api/video-promotion/v1/list";
            ApiHelper   = new ApiHelper(baseUrl);
            FileHandler = new FileHandler();
            IPGetter    = new IPGetter();
            DataToShow  = new ObservableCollection <Display>();
            var url = GetUrl();

            VideoProcessor = new VideoProcessor(ApiHelper, url);
        }
Exemple #10
0
        public ActionResult Upload(Video video, HttpPostedFileBase file)
        {
            video.FileName        = file.FileName;
            video.FileData        = file.InputStream;
            video.AddedOn         = DateTime.UtcNow;
            video.VideoStatusEnum = Shared.Enums.VideoStatus.Pending;

            var videoProcessor = new VideoProcessor(_repository);

            videoProcessor.SaveVideo(video);

            return(RedirectToAction("Index"));
        }
Exemple #11
0
        public void ReturnsTrueOnBlackFrame()
        {
            var testFrame = new Image <Bgr, byte>("./Test/testdata/frames/480/black.png");

            byte[]   data         = new byte[testFrame.Width * testFrame.Height * 3];
            GCHandle dataHandle   = GCHandle.Alloc(data, GCHandleType.Pinned);
            Mat      currentFrame = new Mat(testFrame.Size, DepthType.Cv8U, 3, dataHandle.AddrOfPinnedObject(), testFrame.Width * 3);

            testFrame.Mat.CopyTo(currentFrame);
            var hues = VideoProcessor.getHues(data, testFrame.Size);

            Assert.IsTrue(VideoProcessor.isBlackFrame(hues));
        }
Exemple #12
0
        public Actor(NodeSettings nodeSettings)
        {
            _processor = new VideoProcessor(nodeSettings.FfMpegPath, nodeSettings.TempDirectory);

            Receive <ProcessFileInfo>(file =>
            {
                var task = Task.Run(() =>
                {
                    ProcessFile(file);
                    StatusMessage message = new StatusMessage
                    {
                        TaskId  = file.TaskId,
                        Message = "Complete"
                    };
                    AddStatus(message);
                    Callback(message);
                }, _cancellationToken);

                task.Wait();
            });
        }
Exemple #13
0
        public async Task <object> Get(GetBifFile request)
        {
            var item        = _libraryManager.GetItemById(request.Id);
            var mediaSource =
                ((IHasMediaSources)item).GetMediaSources(false)
                .FirstOrDefault(i => string.Equals(i.Id, request.MediaSourceId));

            var path = VideoProcessor.GetExistingBifPath(item, mediaSource.Id, request.Width);

            if (path == null)
            {
                path = await new VideoProcessor(_logger, _mediaEncoder, _fileSystem, _appPaths, _libraryMonitor)
                       .GetEmptyBif().ConfigureAwait(false);
            }

            _logger.Info("Returning bif file: {0}", path);
            return(await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
            {
                ContentType = "application/octet-stream",
                Path = path
            }).ConfigureAwait(false));
        }
Exemple #14
0
        public async Task LoadVideo()
        {
            DataToShow.Clear();
            try
            {
                var videoModel = await VideoProcessor.LoadVideo();

                Pagination = videoModel.Data.Pagination;

                foreach (var video in videoModel.Data.Videos)
                {
                    var thumbnailLink = $"https:{video.PreviewImages[0]}";
                    var uriSource     = new Uri(thumbnailLink, UriKind.Absolute);
                    var data          = new Display(new BitmapImage(uriSource),
                                                    video.Title,
                                                    video.Duration,
                                                    video.Quality.ToUpper(),
                                                    video.Uploader,
                                                    video.Tags);
                    data.Tags.Sort();
                    DataToShow.Add(data);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                var uriSource  = new Uri("https://www.iconfinder.com/data/icons/image-1/64/Image-12-512.png", UriKind.Absolute);
                var substitute = new Display(new BitmapImage(uriSource),
                                             "No videos found, please check, if you're connected to the internet and provided the correct PSID and access key in Assets\\API.txt!",
                                             0, "", "", null);
                Pagination = new Pagination()
                {
                    CurrentPage = 1,
                    TotalPages  = 0
                };
                DataToShow.Add(substitute);
            }
        }
Exemple #15
0
        public void ReturnsTrueOnClearFrames()
        {
            string[] filePaths = Directory.GetFiles("./Test/testdata/frames/1080/", "clear_*.png", SearchOption.TopDirectoryOnly);

            byte[]   data       = new byte[1080 * 1920 * 3];
            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            foreach (string fn in filePaths)
            {
                var testFrame = new Image <Bgr, byte>(fn);

                // Test frame MUST be 1920x1080 otherwise a black frame will be returned with no errors or warnings
                Assert.IsTrue(testFrame.Size.Width == 1920);
                Assert.IsTrue(testFrame.Size.Height == 1080);

                Mat currentFrame = new Mat(testFrame.Size, DepthType.Cv8U, 3, dataHandle.AddrOfPinnedObject(), testFrame.Width * 3);
                testFrame.Mat.CopyTo(currentFrame);
                var hues = VideoProcessor.getHues(data, testFrame.Size);
                Assert.IsTrue(VideoProcessor.isClearFrame(hues));
            }

            dataHandle.Free();
        }
Exemple #16
0
        public static async Task Run(
            [QueueTrigger("media-service")] string message,
            [Inject] VideoProcessor videoProvider,
            IBinder binder,
            CancellationToken token)
        {
            dynamic json = JToken.Parse(message);

            foreach (var output in json.data.outputs)
            {
                string label     = output.label;
                string assetName = output.assetName;

                if (label == AssetType.Thumbnail.ToString())
                {
                    var id = long.Parse(RegEx.NumberExtractor.Match(assetName).Value);
                    await videoProvider.MoveImageAsync(id, binder, token);
                }

                if (label == AssetType.Short.ToString())
                {
                    var id = long.Parse(RegEx.NumberExtractor.Match(assetName).Value);
                    await videoProvider.CreateLocatorAsync(id, token);
                }

                if (label == AssetType.Long.ToString())
                {
                    var id = long.Parse(RegEx.NumberExtractor.Match(assetName).Value);
                    await videoProvider.UpdateDurationAsync(id, binder, token);
                }

                if (label == AssetType.StudyRoom.ToString())
                {
                    await videoProvider.MoveStudyRoomVideoAsync(assetName, binder, token);
                }
            }
        }
        /// <summary>
        /// Process recorded frames
        /// </summary>
        private async Task ProcessFrames()
        {
            Status.Content = "Starting video render...";

            // Render video locally
            string videoPath =
                await VideoProcessor.RenderVideoAsync(15, 1920, 1080, 100, TemporaryFolder.Text, _recordingID);

            // Save recording timestamp
            DateTime recordedStamp = DateTime.Now;

            Status.Content = "Done rendering video.";

            // Host video in Microsoft Azure
            string streamUrl = await HostVideoInAzure(videoPath);

            Status.Content = "Video is available on-demand.";

            // Send notifications to clients
            await SendNotification(streamUrl, recordedStamp);

            // Remove saved images & local video afterwards
            await RemoveLocalAssets();
        }
Exemple #18
0
 public string DisablePolledProcessing()
 {
     Syncre_LayerB_librabry.VideoProcessor vp = new VideoProcessor();
     return(vp.DisablePolledProcessing());
 }
 public VideoProductTest()
 {
     videoProcessor = new VideoProcessor(VideoType.LearningToSki);
 }
Exemple #20
0
 public void Init()
 {
     videoProcessor = new VideoProcessor();
 }
Exemple #21
0
        protected override IOrderProcessor GetOrderType()
        {
            IOrderProcessor order = new VideoProcessor();

            return(order);
        }
Exemple #22
0
 public string EnablePolledProcessing(int pollingInterval, string searchServerEndpoint)
 {
     Syncre_LayerB_librabry.VideoProcessor vp = new VideoProcessor();
     return(vp.EnablePolledProcessing(pollingInterval, searchServerEndpoint));
 }
Exemple #23
0
        public void TenMinuteGameplayTest()
        {
            // Unzip video
            FastZip fastZip   = new FastZip();
            string  zip       = @"Test\testdata\video\720\Dram_Video_Gameplay_1.zip";
            string  dir       = @"Test\testdata\video\720\";
            string  videoFile = dir + "Dram_Video_Gameplay_1.mp4";

            fastZip.ExtractZip(zip, dir, "");

            VideoCapture deathVideo = new VideoCapture(videoFile);

            // Read first frame, for some reason the Bitmap is null - so we don't want this going to the VideoProcessor
            deathVideo.Read(new Mat());

            // Create and start the video processor object
            int deathCount      = 0;
            int restartCount    = 0;
            int wrCount         = 0;
            int firstClearCount = 0;
            int exitCount       = 0;
            int clearCount      = 0;

            int unknownTemplateCount = 0;

            List <Level> levels = new List <Level>();

            List <string> expectedClearTimes = new List <string> {
                "00'09\"588", "00'42\"156", "00'21\"532", "00'38\"019"
            };
            List <string> actualClearTimes = new List <string>();

            HashSet <string> expectedlevelCodes = new HashSet <string> {
                "HXL-XFC-5NF", "P7N-9G1-KGF", "F0V-CCC-QGG", "NC4-N2G-3RF", "GMB-VS4-PFG", "KWC-KCH-HSG", "SL5-CY5-94G", "C38-TH8-CTG"
            };
            HashSet <string> actualLevelCodes = new HashSet <string>();

            VideoProcessor mockedVideoProcessor = new VideoProcessor(deathVideo);

            mockedVideoProcessor.ClearScreen += (d, g) =>
            {
                clearCount++;
                actualClearTimes.Add(g.clearTime);
            };

            mockedVideoProcessor.LevelScreen += (d, g) =>
            {
                actualLevelCodes.Add(g.levelInfo.code);
            };

            mockedVideoProcessor.TemplateMatch += (d, g) =>
            {
                switch (g.template.eventType)
                {
                case "death": deathCount++; break;

                case "restart": restartCount++; break;

                case "worldrecord": wrCount++; break;

                case "firstclear": firstClearCount++; break;

                case "exit": exitCount++; break;

                default: unknownTemplateCount++; break;
                }
            };

            mockedVideoProcessor.Start(true);

            Assert.AreEqual(4, deathCount, "Death Check");
            Assert.AreEqual(6, restartCount, "Restart Check");
            Assert.AreEqual(1, wrCount, "World Record Check");
            Assert.AreEqual(1, firstClearCount, "First Clear Check");
            Assert.AreEqual(5, exitCount, "Exit/Quit Check");
            Assert.AreEqual(4, clearCount, "Clear Check");

            for (int i = 0; i < clearCount; i++)
            {
                Assert.AreEqual(expectedClearTimes[i], actualClearTimes[i], "Clear Time Check");
            }

            Assert.AreEqual(expectedlevelCodes.Count, actualLevelCodes.Count, "Level Screen Count Check");
            for (int i = 0; i < expectedlevelCodes.Count; i++)
            {
                Assert.AreEqual(expectedlevelCodes.ToList()[i], actualLevelCodes.ToList()[i], "Level Code Check");
            }

            Console.WriteLine("Unknown Template Count: " + unknownTemplateCount);

            try
            {
                File.Delete(videoFile);
            }
            catch (Exception ex)
            {}
        }