Exemplo n.º 1
0
        private void Start_Click(object sender, EventArgs e)
        {
            if (urlTxtBox.Text.Any())
            {
                jpegStream        = new MJPEGStream(urlTxtBox.Text);
                asyncVS           = new AsyncVideoSource(jpegStream);
                asyncVS.NewFrame += Device_NewFrameAsync;
                asyncVS.Start();
            }

            else if (DeviceDropBox.Text.Equals("Video File"))
            {
                videoSource = new FileVideoSource(filePath);
                // set NewFrame event handler
                videoSource.NewFrame         += Device_NewFrameAsync;
                videoSource.VideoSourceError += new VideoSourceErrorEventHandler(videoSource_Error);
                // start the video source
                videoSource.Start();
            }

            else
            {
                //VideoCaptureDevice vcd = new VideoCaptureDevice(stream.Source);
                var selected = DeviceDropBox.SelectedIndex;
                device           = new VideoCaptureDevice(videoDevices[selected].MonikerString);
                device.NewFrame += Device_NewFrameAsync;

                device.Start();
            }
        }
Exemplo n.º 2
0
        //ładowanie filmu
        public void loadVideo_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.CheckFileExists  = true;
                openFileDialog.CheckPathExists  = true;
                openFileDialog.DefaultExt       = "avi";
                openFileDialog.Filter           = "avi files (*.avi)|*.avi";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    videoSource = new FileVideoSource(openFileDialog.FileName);
                    videoSource.Start();
                    videoSourcePlayer1.VideoSource = videoSource;
                    pos2Y = videoSourcePlayer1.Height / 2;
                }
            }
            catch (FileLoadException)
            {
                MessageBox.Show("Nie załadowano filmu.");
            }
        }
        private void Stop()
        {
            if (videoPlayer.VideoSource != null)
            {
                videoPlayer.SignalToStop();

                // wait 3 seconds
                for (int i = 0; i < 50; i++)
                {
                    if (!videoPlayer.IsRunning)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(100);
                }

                if (videoPlayer.IsRunning)
                {
                    videoPlayer.Stop();
                }

                buttonPlay.Image = Resources.if_StepForwardDisabled_22933;

                videoPlayer.VideoSource = null;
                _fileVideoSource        = null;
            }
        }
Exemplo n.º 4
0
        public void LoadFile()
        {
            if (_fileName == null || _fileName.Equals(""))
            {
                return;
            }

            try
            {
                _doneEvent = new AutoResetEvent(false);

                _video                  = new FileVideoSource(_fileName);
                _video.NewFrame        += new Accord.Video.NewFrameEventHandler(Video_NewFrame);
                _video.PlayingFinished += Video_PlayingFinished;

                _video.Start();

                _firstFrameFlag = true;

                _doneEvent.WaitOne();

                _firstFrameFlag = false;
            }
            catch { }
        }
    private IEnumerator CreateVideo()
    {
        imageSource.gameObject.SetActive(false);
        videoSource.gameObject.SetActive(true);

        FileVideoSource textureSource = videoSource.GetComponent <FileVideoSource>();

        textureSource.videoClip = fieldItem.videoClip;
        yield return(StartCoroutine(textureSource.LoadTexture()));

        var videoPlayer = GetComponentInChildren <VideoPlayer>();

        videoPlayer.clip = textureSource.videoClip;
        videoSource.GetComponent <RectTransform>().sizeDelta = new Vector2(textureSource.videoClip.width, textureSource.videoClip.height);
        RenderTexture texture = new RenderTexture((int)textureSource.videoClip.width, (int)textureSource.videoClip.height, 16);

        videoSource.GetComponent <RawImage>().texture = texture;
        videoPlayer.targetTexture = texture;

        var collider = gameObject.AddComponent <BoxCollider>();

        collider.size = new Vector3(textureSource.videoClip.width * 0.001f, textureSource.videoClip.height * 0.001f);

        videoPlayer.Play();
    }
Exemplo n.º 6
0
        //private void videoPlayer_NewFrame(object sender, ref Bitmap image)
        //{
        //    if (robustChecking)
        //    {
        //        framesCountedForDetection++;

        //        if (framesCountedForDetection > 5)
        //        {
        //            if (!plateDisplayed && lastCandidate.text != null)
        //            {
        //                if (lastDisplayedPlate.text == null)
        //                {
        //                    main.HandleResults(lastCandidate);
        //                    framesCountedForDetection = 0;
        //                    lastDisplayedPlate = lastCandidate;
        //                    plateDisplayed = false;
        //                }
        //                else if (!lastDisplayedPlate.text.Equals(lastCandidate.text))
        //                {
        //                    main.HandleResults(lastCandidate);
        //                    framesCountedForDetection = 0;
        //                    lastDisplayedPlate = lastCandidate;
        //                    plateDisplayed = false;
        //                }
        //            }
        //        }
        //    }

        //    _motionDetector.ProcessFrame(image);
        //    //force garbage collection since we are using Bitmap's and we
        //    //cant dispose them because of the ref to the video player
        //    //and for some reason it doesn't let go off the resources properly
        //    framesCountedForDisposal++;
        //    if (framesCountedForDisposal == 10)
        //    {
        //        GC.Collect();
        //        framesCountedForDisposal = 0;
        //    }
        //}

        private void loadVideo(String filename)
        {
            lblConnectMessage.Show();
            if (fileVideoSource != null)
            {
                if (fileVideoSource.IsRunning)
                {
                    CloseVideoSource();
                    fileVideoSource.NewFrame += null;
                    setPicture(null);
                    lblConnectMessage.Text = "Connecting to feed...";
                }
            }

            if (File.Exists(filename))
            {
                fileVideoSource           = new FileVideoSource(filename);
                fileVideoSource.NewFrame += fileVideoSource_NewFrame;
                lblConnectMessage.Hide();
            }
            else
            {
                lblConnectMessage.Text = "Error connecting to feed";
            }
        }
Exemplo n.º 7
0
 public override void Init(object initData)
 {
     base.Init(initData);
     Source = new FileVideoSource
     {
         File = (string)initData
     };
 }
Exemplo n.º 8
0
 private void OpenVideofileusingDirectShowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (OpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         var fileSource = new FileVideoSource(OpenFileDialog.FileName);
         OpenVideoSource(fileSource);
     }
 }
        public void play()
        {
            FileVideoSource fileSource = new FileVideoSource(System.Windows.Forms.Application.StartupPath + "\\MyVideo\\" +
                                                             CComLibrary.GlobeVal.filesave.play_avi_file);

            // open it
            OpenVideoSource(fileSource);
        }
 public void StopVideo()
 {
     if (_videoSource != null)
     {
         _videoSource.SignalToStop();
     }
     _videoSource = null;
 }
Exemplo n.º 11
0
 private void openVideo_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);
         OpenVideoSource(fileSource);
     }
 }
        // Class constructor
        public MainForm( )
        {
            InitializeComponent( );

            // For debugging, instantly open the test file.
            FileVideoSource fileSource = new FileVideoSource(@"C:\Users\STRIDERA\Videos\ttfatf.wmv");

            OpenVideoSource(fileSource);
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            FileVideoSource videoSource = new FileVideoSource(@"D:\Github\GiM\film1.avi");

            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            videoSource.Start();

            videoSourcePlayer1.VideoSource = videoSource;
        }
Exemplo n.º 14
0
 // Open video file using DirectShow
 private void openVideofileusingDirectShowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog( ) == DialogResult.OK)
     {
         // create video source
         FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);
         //FileVideoSource fileSource = new FileVideoSource("single.avi");
         // open it
         OpenVideoSource(fileSource);
     }
 }
Exemplo n.º 15
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                var videoSource = new FileVideoSource(openFileDialog.FileName);

                OpenVideoSource(videoSource);
            }
        }
 private void CloseVideoSource()
 {
     if (!(videoSource == null))
     {
         if (videoSource.IsRunning)
         {
             videoSource.SignalToStop();
             videoSource = null;
         }
     }
 }
        private void btnplay_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);

                // open it
                OpenVideoSource(fileSource);
            }
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);
                OpenVideoSource(fileSource);
            }

            SetMotionDetectionAlgorithm(new SimpleBackgroundModelingDetector(true, true));
            SetMotionProcessingAlgorithm(new BlobCountingObjectsProcessing());
        }
        public Task <string> LoadVideoAsync(VideoSource source, CancellationToken cancellationToken = new CancellationToken())
        {
            string          result  = null;
            FileVideoSource source2 = source as FileVideoSource;

            if (!string.IsNullOrEmpty(source2?.File) && File.Exists(source2.File))
            {
                result = source2.File;
            }
            return(Task.FromResult <string>(result));
        }
        private void buttonplayvideo_Click(object sender, EventArgs e)
        {
            // 活体对应视频路径的文件作为视频源
            FileVideoSource videoSource = new FileVideoSource(videoFilePath);

            videoSourcePlayer.VideoSource = videoSource;
            videoSourcePlayer.Start();
            output("已开始播放。", 1);
            buttonphoto.Enabled = true;
            isplay = true;
        }
Exemplo n.º 21
0
 public static VideoSourcePlayer play(this VideoSourcePlayer videoPlayer, string aviFile)
 {
     videoPlayer.invokeOnThread(
         () => {
         var videoSource = new FileVideoSource(aviFile);
         videoPlayer.SignalToStop( );
         videoPlayer.WaitForStop( );
         videoPlayer.VideoSource = videoSource;
         videoPlayer.Start( );
     });
     return(videoPlayer);
 }
 private void pictureBox2_Click(object sender, EventArgs e)
 {
     videoPlayer.Invoke((MethodInvoker) delegate
     {
         videoPlayer.SignalToStop();
     });
     processedPicture.Image       = null;
     buttonPlay.Image             = Resources.if_StepForwardDisabled_22933;
     labelTimeProgressFinish.Text = "--:--";
     labelTimeProgressStart.Text  = "--:--";
     videoPlayer.VideoSource      = null;
     _fileVideoSource             = null;
 }
Exemplo n.º 23
0
        void StartPlaying()
        {
            if (reader != null)
            {
                reader.PlayingFinished -= Reader_PlayingFinished;
                reader.NewFrame        -= Reader_NewFrame;
            }

            reader = new FileVideoSource("d:\\src\\star.avi");
            reader.PlayingFinished += Reader_PlayingFinished;
            reader.NewFrame        += Reader_NewFrame;
            reader.Start();
        }
Exemplo n.º 24
0
        public MainWindow()
        {
            InitializeComponent();

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);

                // open it
                OpenVideoSource(fileSource);
            }
        }
        private async void OnShowVideoLibraryCommand()
        {
            ButtonIsEnabled = false;
            string filename = await DependencyService.Get <IVideoPicker>().GetVideoFileAsync();

            if (!String.IsNullOrWhiteSpace(filename))
            {
                VideoPlayerSource = new FileVideoSource
                {
                    File = filename
                };
            }
            ButtonIsEnabled = true;
        }
Exemplo n.º 26
0
        private void baslat_Click(object sender, EventArgs e)
        {
            OpenFileDialog openfd = new OpenFileDialog();

            if (openfd.ShowDialog() == DialogResult.OK)
            {
                FileVideoSource videoSource = new FileVideoSource(openfd.FileName);
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
                videoSource.Start();
                int a = videoSource.FramesReceived;
                label1.Text = "Frames:" + a;
                //videoSource.SignalToStop();
            }
        }
Exemplo n.º 27
0
        private void playVideo_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);

                // open it
                OpenVideoSource(fileSource, videoKind.playvideo, false);
                // info, finish, video, single, savebutton, sxga, xga, svga, vga, cif, diconnect
                //  0     0       0       1        0         0     0    0     0   0      1
                EnableDisableButtons(0b0000000010000001);
            }
        }
Exemplo n.º 28
0
 private void btnOpenVideoFile_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog()
     {
         Filter = "mp4|*.mp4"
     })
     {
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             FileVideoSource fileSource = new FileVideoSource(ofd.FileName);
             fileSource.VideoSourceError += FileSource_VideoSourceError;
             OpenVideoSource(fileSource);
         }
     }
 }
        public void SetVideo(string filepath)
        {
            _ellipsePB.BackColor = Color.Transparent;
            if (_videoSource != null)
            {
                _videoSource.SignalToStop();
                _videoSource = null;
            }

            _videoSource = new FileVideoSource(filepath);
            // set NewFrame event handler
            _videoSource.NewFrame         += new NewFrameEventHandler(video_NewFrame);
            _videoSource.PlayingFinished  += new PlayingFinishedEventHandler(videoFinished);
            _videoSource.VideoSourceError += new VideoSourceErrorEventHandler(videoSource_Error);
            _videoSource.Start();
        }
Exemplo n.º 30
0
        // Open video source
        private void OpenVideoSource(string file)
        {
            FileVideoSource source = new FileVideoSource(file);

            // set busy cursor
            this.Cursor = Cursors.WaitCursor;

            // stop current video source
            CloseCurrentVideoSource();

            // start new video source
            videoSourcePlayer.VideoSource = source;
            videoSourcePlayer.Start();

            this.Cursor = Cursors.Default;
        }