예제 #1
0
 public GZVideoCapture(Action <Mat> grabAction, int ind = 0)
 {
     //DsDevice[] _SystemCamereas = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
     //WebCams = new Video_Device[_SystemCamereas.Length];
     vid = new VideoCapture(ind);
     W   = (int)vid.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth);
     H   = (int)vid.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight);
     vid.ImageGrabbed += (sender, e) =>
     {
         if (vid != null)
         {
             using (Mat mat = new Mat())
             {
                 lock (vidLock)
                 {
                     if (vid != null) //mat = vid.QueryFrame();
                     {
                         vid.Retrieve(mat);
                     }
                 }
                 if (mat == null)
                 {
                     return;
                 }
                 grabAction(mat);
             }
         }
     };
     vid.Start();
 }
예제 #2
0
        public void readWriteVideo(String filePath, String name, String outputFolder)
        {
            String       outputVideo = outputFolder + "\\" + name.Split('.')[0] + ".avi";
            double       TotalFrame;
            double       Fps;
            int          FrameNo = 0;
            VideoCapture capture = new VideoCapture(filePath);

            TotalFrame = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
            Fps        = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
            int fourcc = Convert.ToInt32(capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FourCC));
            int Width  = Convert.ToInt32(capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth));
            int Height = Convert.ToInt32(capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight));


            //VideoWriter writer = new VideoWriter(outputVideo, VideoWriter.Fourcc('X', '2', '6', '4'), Fps, new Size(Width, Height), true);
            VideoWriter writer = new VideoWriter(outputVideo, VideoWriter.Fourcc('M', 'P', '4', 'V'), Fps, new Size(640, 360), true);
            Mat         m      = new Mat();

            while (FrameNo < TotalFrame)
            {
                capture.Read(m);
                Image <Bgr, byte> frmImage = m.ToImage <Bgr, byte>().Resize(416, 416, Inter.Cubic);
                writer.Write(frmImage.Mat);
                FrameNo++;
            }
            if (writer.IsOpened)
            {
                writer.Dispose();
            }

            Console.WriteLine("Success:  " + outputVideo);
            capture.Stop();
            capture.Dispose();
        }
예제 #3
0
        void generateVideo(string path, string filename)
        {
            int i   = -1;
            var fcc = VideoWriter.Fourcc('m', 'p', '4', 'v');

            Stopwatch watch = new Stopwatch();

            watch.Start();
            using (var video = new VideoCapture(path))
                using (var writer = new VideoWriter(@$ "{filename}.mp4", fcc, video.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps) / FRAMES,
                                                    new Size((int)video.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth), (int)video.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight)), true))
                    using (var img = new Mat()) {
                        while (video.Grab())
                        {
                            if (++i % FRAMES == 0)
                            {
                                video.Read(img);
                                Bitmap            bmp   = new Bitmap(convertIntoAscii(img.ToBitmap()), (int)video.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth), (int)video.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight));
                                Image <Bgr, byte> frame = bmp.ToImage <Bgr, byte>();
                                writer.Write(frame.Mat);
                            }
                        }
                    }
            watch.Stop();
            Console.WriteLine($"\u001b[36mTime: {watch.ElapsedMilliseconds/60} sec.\u001b[0m");
        }
        private async void importVideoFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.FileName = "";
            openFileDialog.Filter   = "mp4文件|*.mp4|avi文件|*avi|所有文件|*.*";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                info.VideoPath            = openFileDialog.FileName;
                labelVideoPath.Text       = openFileDialog.SafeFileName;
                trackBarBeginTime.Maximum = (int)await Info.GetMediaTime(info.VideoPath);

                buttonMakeSure.Enabled = true;
                if (trackBarBeginTime.Maximum == 0)
                {
                    MessageBox.Show("无法读取视频长度,长度调节暂不可用");
                }
                Task a = new Task(new Action(() => {
                    Split.ExtractAudio(info);
                }));
                a.Start();
                a.Wait();
                VideoCapture cap = new VideoCapture(info.VideoPath);
                info.width  = (int)cap.GetCaptureProperty(CapProp.FrameWidth);
                info.height = (int)cap.GetCaptureProperty(CapProp.FrameHeight);
                info.bmp    = cap.QueryFrame().ToBitmap();
                pictureBox1.CreateGraphics().DrawImage(info.bmp, new System.Drawing.Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
                cap.Dispose();
                if (modeVideoToolStripMenuItem.Checked && info.subtitles != null)
                {
                    info.AudioPath = info.bgmTemp;
                    Merge.MixBgmAndSpeech(info);
                }
            }
        }
예제 #5
0
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            var frame = capture.QueryFrame();

            sourceImage      = frame.ToImage <Bgr, byte>().Resize(550, 350, Inter.Linear);
            processor.SrcImg = sourceImage;

            if (playingVideoText)
            {
                imageBox2.Image = processor.drawInterestAreas();
                String newText = processor.getTextFromVideoFrame();
                if (!newText.Equals(lastText))
                {
                    listBox1.Items.Add(processor.getTextFromVideoFrame());
                    listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    listBox1.SelectedIndex = -1;
                    lastText = newText;
                }
            }
            //imageBox2.Image = GetImageWithCellShading(trackBar3.Value);
            //imageBox2.Image = GetImageWithCanny();
            frameCounter++;

            if (frameCounter >= capture.GetCaptureProperty(CapProp.FrameCount))
            {
                timer1.Enabled   = false;
                frameCounter     = 0;
                playingVideoText = false;
            }
        }
    static void Main()
    {
        VideoCapture cap = new VideoCapture(0);

        if (!cap.IsOpened)
        {
            return;
        }
        cap.SetCaptureProperty(CapProp.FrameWidth, 1920);
        cap.SetCaptureProperty(CapProp.FrameHeight, 1080);
        cap.SetCaptureProperty(CapProp.Fps, 30);

        Mat  frame       = new Mat();
        long msecCounter = 0;
        long frameNumber = 0;

        for (;;)
        {
            if (cap.Grab())
            {
                msecCounter = (long)cap.GetCaptureProperty(CapProp.PosMsec);
                frameNumber = (long)cap.GetCaptureProperty(CapProp.PosFrames);

                if (cap.Retrieve(frame))
                {
                    ProcessFrame(frame, msecCounter, frameNumber);
                }
            }
            // TODO: Determine when to quit the processing loop
        }
    }
예제 #7
0
        private void btnPlakayiBul_Click_1(object sender, EventArgs e)
        {
            try
            {
                // openfile diyalog oluştur
                OpenFileDialog fileDia = new OpenFileDialog();
                fileDia.InitialDirectory = Environment.CurrentDirectory;
                fileDia.Filter           = "Video files (*.mp4)|*.mp4|All files (*.*)|*.*";
                if (fileDia.ShowDialog() == DialogResult.OK)
                {
                    capture   = new VideoCapture(fileDia.FileName);
                    MediaFile = fileDia.FileName;

                    if (capture.QueryFrame() != null && capture.GetCaptureProperty(CapProp.Fps) > 0.0)
                    {
                        double fps = capture.GetCaptureProperty(CapProp.Fps);

                        // Reset capture & init. timer
                        capture = new VideoCapture(MediaFile);

                        timer.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "File error");
            }
        }
예제 #8
0
        internal void GetVideoFrameData()
        {
            if (options.frame_rate == null)
            {
                options.frame_rate = inputVideo.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
            }


            var frameWidth  = (int)inputVideo.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth);
            var frameHeight = (int)inputVideo.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight);
            var frameCount  = (int)(inputVideo.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount));;
            var videoLength = (int)(frameCount / options.frame_rate);

            //Just to avoid numbers like 29.99999954
            //frameRate = Math.Round(frameRate, 4);


            options.frame_count     = frameCount;
            options.orignial_length = videoLength;
            options.frame_size      = new System.Drawing.Size(frameWidth, frameHeight);

            //Only need to do this to have the same input codec as output codec, we will be using MP4 so we omit this
            //var codec = (int)(inputVideo.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FourCC));
            //options.video_codec = codec;


            Console.WriteLine("\t" + options.frame_rate + " fps | " + options.orignial_length + " seconds | " + options.frame_count + " frames | " + options.frame_size.Height + "p");
        }
예제 #9
0
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult res = openFileDialog1.ShowDialog();

                if (res == DialogResult.OK)
                {
                    capture = new VideoCapture(openFileDialog1.FileName);

                    Mat m = new Mat();

                    capture.Read(m);

                    pictureBox1.Image = m.Bitmap;

                    fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);

                    frames = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);

                    framesCounter = 1;
                }
                else
                {
                    MessageBox.Show("Video has not choosen!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ComparePoseUC(String poseName, string room)
        {
            InitializeComponent();


            poseNamelb.Content = poseName;
            this.poseName      = poseName;
            this.classRoom     = room;
            this.type          = pose.getPoseDescription(poseName, room)[1];
            //poseType.Content = type;
            this.deslb.Text = pose.getPoseDescription(poseName, room)[0];
            int num = position.lenghtFrame(poseName, room);

            if (type == "Motion")
            {
                string name = path1 + "\\" + poseName.Replace(' ', '_').ToString() + ".mp4";
                videoCapture = new VideoCapture(path1 + "\\" + poseName.Replace(' ', '_').ToString() + ".mp4");
                Mat m = new Mat();
                videoCapture.Read(m);
                exampleImage.Source = ImageSourceForBitmap(m.Bitmap);
                TotalFrame          = videoCapture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                Fps = videoCapture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
            }
            else
            {
                exampleImage.Source = new BitmapImage(new Uri(path1 + "\\" + poseName.Replace(' ', '_').ToString() + ".png"));
            }

            //string name = poseName.Replace(' ', '_') + "7";
            //this.exampleImage.Source = new BitmapImage(new Uri(path1 + "\\" + name + ".png"));
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Video files. | *.mp4; *.avi";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    capture           = new VideoCapture(ofd.FileName);
                    totalFrame        = Convert.ToInt32(capture.GetCaptureProperty(CapProp.FrameCount));
                    fps               = Convert.ToInt32(capture.GetCaptureProperty(CapProp.Fps));
                    isPlaying         = true;
                    curFrameM         = new Mat();
                    curFrameN         = 0;
                    trackBar1.Minimum = 0;
                    trackBar1.Maximum = totalFrame - 1;
                    trackBar1.Value   = 0;
                    PlayVideo();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
        private void Buscar()//Buscar fotos en el explorador de windows
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            string         ruta;

            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    ruta              = openFileDialog1.FileName;
                    video             = new VideoCapture(ruta);
                    TotalFrames       = Convert.ToInt32(video.GetCaptureProperty(CapProp.FrameCount));
                    FPS               = Convert.ToInt32(video.GetCaptureProperty(CapProp.Fps));
                    IsPlaying         = true;
                    CurrentFrame      = new Mat();
                    CurrentFrameNo    = 0;
                    trackBar1.Minimum = 0;
                    trackBar1.Maximum = TotalFrames - 1;
                    trackBar1.Value   = 0;
                    PlayVideo();



                    //matrix.Data[]
                }
            }
            catch
            {
            }
        }
        private void loadVideo()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "WMV Files (*.wmv)|*.wmv|mp4 Files (*.mp4)|*.mp4|All files (*.*)|*.*";

            openFileDialog1.FileName = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _capture    = null;
                    _capture    = new VideoCapture(openFileDialog1.FileName.ToString());
                    TotalFrame  = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                    Fps         = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                    label1.Text = "Frame count = " + TotalFrame + ", Fps: " + Fps;

                    _capture.ImageGrabbed += ProcessFrame;
                    curFrameCount          = 0;
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
        }
예제 #14
0
        public bool open(string filename_origin1, string filename_origin2, string filename_dest)
        {
            mode = 1;
            this.filename_origin1 = filename_origin1;
            this.filename_origin2 = filename_origin2;
            this.filename_dest    = filename_dest;
            cap1 = new VideoCapture(filename_origin1);
            cap2 = new VideoCapture(filename_origin2);

            if (!cap1.IsOpened || !cap2.IsOpened)
            {
                return(false);
            }
            //get fps
            fps1 = cap1.GetCaptureProperty(CapProp.Fps);
            fps2 = cap2.GetCaptureProperty(CapProp.Fps);

            fourCC1 = cap1.GetCaptureProperty(CapProp.FourCC);
            fourCC2 = cap2.GetCaptureProperty(CapProp.FourCC);

            //double count1=cap1.GetCaptureProperty(CapProp.FrameCount);

            if ((cap1.Width == cap2.Width) && (cap1.Height == cap2.Height))
            {
                return(true);
            }
            return(false);
        }
        private void M_capture_ImageGrabbed(object sender, EventArgs e)
        {
            Console.WriteLine("test: " + startIndex.ToString());
            startIndex++;


            if (fileChanged)
            {
                nameofRecording = nameofrecord_textbox.Text;
                destin          = directorytosave_textbox.Text;

                totalFrames = m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                fps         = m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                int    fourcc      = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FourCC));
                int    frameHeight = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight));
                int    frameWidth  = Convert.ToInt32(m_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth));
                string destination = destin + nameofRecording + ".avi";
                videoWriter = new VideoWriter(destination, VideoWriter.Fourcc('I', 'Y', 'U', 'V'), fps, new System.Drawing.Size(frameWidth, frameHeight), true);
                fileChanged = false;
            }


            Mat m = new Mat();

            m_capture.Retrieve(m);
            // pictureBox1.Image = m.ToImage<Bgr, byte>().Bitmap;
            videoWriter.Write(m);



            //throw new NotImplementedException();
        }
예제 #16
0
        private async void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (capture == null)
            {
                return;
            }

            try
            {
                while (!Pause)
                {
                    Mat m = new Mat();
                    capture.Read(m);

                    if (!m.IsEmpty)
                    {
                        pictureBox2.Image = m.Bitmap;
                        double fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                        await Task.Delay(1000 / Convert.ToInt32(fps));
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #17
0
        private async void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            if (capture == null)
            {
                return;
            }

            try
            {
                while (true)
                {
                    Mat m = new Mat();
                    capture.Read(m);

                    if (!m.IsEmpty)
                    {
                        pictureBox1.Source = Bitmap2BitmapImage(m.Bitmap);
                        DetectText(m.ToImage <Bgr, byte>());
                        double fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                        await Task.Delay(1000 / Convert.ToInt32(fps));
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #18
0
 private void process(object sender, EventArgs e)
 {
     if (video == null || cascadeClassifier == null)
     {
         statLabel.Text = "No video and/or haar cascades file";
         return;
     }
     using (Mat imgFrame = video.QueryFrame())
     {
         if (imgFrame == null)
         {
             video.SetCaptureProperty(CapProp.PosAviRatio, 0);
             return;
         }
         Rectangle[] rects = cascadeClassifier.DetectMultiScale(imgFrame, 1.1, 1 /*, default(Size), gray.Size*/);
         using (Image <Bgr, byte> output = imgFrame.ToImage <Bgr, byte>())
         {
             foreach (Rectangle rect in rects)
             {
                 output.Draw(rect, new Bgr(Color.Red), 3);
             }
             ibMonitor.Image = output;
         }
         //status update
         var max = video.GetCaptureProperty(CapProp.FrameCount);
         var now = video.GetCaptureProperty(CapProp.PosFrames);
         statLabel.Text = $"Position: {now}/{max}";
     }
 }
예제 #19
0
        private void Load_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (capture != null)
                {
                    capture.Dispose();
                }
                capture = new VideoCapture(ofd.FileName);
                Mat m = new Mat();
                //capture.ImageGrabbed += Capture_ImageGrabbed;
                capture.Read(m);
                pictureBox1.Image = Emgu.CV.BitmapExtension.ToBitmap(m);

                TotalFrame = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                Fps        = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                capture.SetCaptureProperty(CapProp.Fps, 30);
                Fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                iImage.Resize(Snap_GrayImg, m.Width, m.Height);



                //hDC = g.GetHdc();


                //iROI.Plot(TrainROITool, hDC);
                //pictureBox1.Refresh();
            }
        }
        /// <summary>
        /// Load a new file.
        /// </summary>
        /// <param name="sender"> sender </param>
        /// <param name="e"> args </param>
        private void btnLoadFile_Click(object sender, EventArgs e)
        {
            try
            {
                // Create en open file dialog
                OpenFileDialog fileDia = new OpenFileDialog();
                fileDia.InitialDirectory = Environment.CurrentDirectory;
                fileDia.Filter           = "Video files (*.mp4)|*.mp4|All files (*.*)|*.*";
                if (fileDia.ShowDialog() == DialogResult.OK)
                {
                    capture          = new VideoCapture(fileDia.FileName);
                    MediaFile        = fileDia.FileName;
                    lblFileName.Text = Path.GetFileName(fileDia.FileName);
                    if (capture.QueryFrame() != null && capture.GetCaptureProperty(CapProp.Fps) > 0.0)
                    {
                        double fps = capture.GetCaptureProperty(CapProp.Fps);

                        // Reset capture & init. timer
                        capture        = new VideoCapture(MediaFile);
                        timer.Interval = (int)(1000 / fps);
                        timer.Enabled  = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "File error");
            }
        }
예제 #21
0
        private void loadMenuItem_Click(object sender, EventArgs e)
        {
            if (fileCheck.Checked)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Video Files (*.mp4, *.flv)| *.mp4;*.flv";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    videocapture      = new VideoCapture(ofd.FileName);
                    TotalFrames       = Convert.ToInt32(videocapture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount));
                    FPS               = Convert.ToInt32(videocapture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps));
                    IsPlaying         = true;
                    CurrentFrame      = new Mat();
                    CurrentFrameNo    = 0;
                    trackBar1.Minimum = 0;
                    trackBar1.Maximum = TotalFrames - 1;
                    trackBar1.Value   = 0;
                    PlayVideo();
                }
            }
            else
            {
                //OpenFileDialog ofd = new OpenFileDialog();

                //if (ofd.ShowDialog() == DialogResult.OK)
                //{

                videocapture = new VideoCapture(0);
                Mat m = new Mat();
                videocapture.ImageGrabbed += Capture_ImageGrabbed;
                videocapture.Start();
                //}
            }
        }
        private void writeVideoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (capture == null)
            {
                return;
            }
            int               fourcc          = Convert.ToInt32(capture.GetCaptureProperty(CapProp.FourCC));
            int               weidht          = Convert.ToInt32(capture.GetCaptureProperty(CapProp.FrameWidth));
            int               height          = Convert.ToInt32(capture.GetCaptureProperty(CapProp.FrameHeight));
            string            destinationPath = @"C:\Video\out.mp4";
            VideoWriter       writer          = new VideoWriter(destinationPath, fourcc, fps, new Size(weidht, height), true);
            Image <Bgr, byte> logo            = new Image <Bgr, byte>("C:\\Pictures\\3.jpg");
            Mat               m = new Mat();

            while (frameN < 500)
            {
                capture.Read(m);
                //add logo part
                Image <Bgr, byte> img = m.ToImage <Bgr, byte>();
                img.ROI = new Rectangle(0, 0, logo.Width, logo.Height);
                logo.CopyTo(img);
                img.ROI = Rectangle.Empty;
                //
                writer.Write(img.Mat);
                frameN++;
            }
            if (writer.IsOpened)
            {
                writer.Dispose();
            }
            MessageBox.Show("Complited.");
        }
 public int GetFPS()
 {
     if (IsOpenAndValid())
     {
         return((int)videoCapture.GetCaptureProperty(CapProp.Fps));
     }
     return(-1);
 }
예제 #24
0
 private void updateSeekBar()
 {
     if (videoCapture != null)
     {
         tbVideoSeek.Maximum = (int)videoCapture.GetCaptureProperty(CapProp.FrameCount);
         tbVideoSeek.Value   = (int)videoCapture.GetCaptureProperty(CapProp.PosFrames);
     }
 }
예제 #25
0
 public VideoInfo(VideoCapture v)
 {
     fps       = v.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
     frameSize = new Size((int)(v.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth)),
                          (int)(v.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight)));
     frameCount = (int)(v.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount));
     pos        = (int)(v.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames));
     duration   = frameCount / fps;
 }
예제 #26
0
        //readonly char mode;

        public Transposer(string video_name)
        {
            videofile           = new VideoCapture(video_name);
            originalWidth       = (int)videofile.GetCaptureProperty(CapProp.FrameWidth);
            originalHeight      = (int)videofile.GetCaptureProperty(CapProp.FrameHeight);
            originalFramesCount = (int)videofile.GetCaptureProperty(CapProp.FrameCount);
            fps           = (int)videofile.GetCaptureProperty(CapProp.Fps);
            currentColumn = 0;
        }
예제 #27
0
 public Capture(string videoUri, string fileUri, string codec = "MPEG")
 {
     _vsrc = new VideoCapture(videoUri, VideoCapture.API.Ffmpeg);
     _vsrc.ImageGrabbed += ImageGrabbed;
     _sink = new VideoWriter(fileUri, FourCC(codec), 0.25,
                             new Size((int)_vsrc.GetCaptureProperty(CapProp.FrameWidth), (int)_vsrc.GetCaptureProperty(CapProp.FrameHeight)),
                             _vsrc.GetCaptureProperty(CapProp.Monochrome) == 0);
     _sink.Set(VideoWriter.WriterProperty.NStripes, 1);
 }
        public KiemTraBienSoXeForm()
        {
            //Thread t = new Thread(new ThreadStart(Loading));
            //t.Start();
            //for (int i = 0; i <= 1000; i++)
            //    Thread.Sleep(10);
            // t.Abort();
            InitializeComponent();
            SVM svm = new SVM();

            _lpr = new LPR(svm);

            #region Khởi tạo Camera nếu là Demo
            if (isDemo)
            {
                _capturePlateIn = new Emgu.CV.VideoCapture(PATH_PLATE_IN);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameWidth, 640);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameHeight, 480);
                _fpsPlateIn        = (Int32)_capturePlateIn.GetCaptureProperty(CapProp.Fps);
                _totalFramePlateIn = Convert.ToInt32(_capturePlateIn.GetCaptureProperty(CapProp.FrameCount)) - 4;

                _captureFaceIn = new Emgu.CV.VideoCapture(PATH_FACE_IN);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameWidth, 320);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameHeight, 240);
                _fpsFaceIn           = (Int32)_captureFaceIn.GetCaptureProperty(CapProp.Fps);
                _totalFrameFaceIn    = (Int32)_captureFaceIn.GetCaptureProperty(CapProp.FrameCount) - 4;
                timerFaceIn.Enabled  = true;
                timerPlateIn.Enabled = true;
            }
            #endregion
            #region Khởi tạo Camera bình thường
            else
            {
                //_capturePlateIn = new Emgu.CV.VideoCapture(1);
                //_capturePlateIn.SetCaptureProperty(CapProp.FrameWidth, 640);
                // _capturePlateIn.SetCaptureProperty(CapProp.FrameHeight, 480);
                //_captureFaceIn = new Emgu.CV.VideoCapture(1);
                //_captureFaceIn.SetCaptureProperty(CapProp.FrameWidth, 320);
                //_captureFaceIn.SetCaptureProperty(CapProp.FrameHeight, 240);
                // timerFaceIn.Enabled = true;
                //timerPlateIn.Enabled = true;
            }
            #endregion


            //timer1.Enabled = true;
            if (_captureFaceOut == null)
            {
            }
            if (_capturePlateOut == null)
            {
            }
            //Application.Idle += new EventHandler(FrameGrabber);
            //timer1.Interval = 1000 / _fpsFaceIn;
            //timer1.Tick += new EventHandler(timer1_Tick);
            //timer1.Start();
        }
예제 #29
0
 private void button5_Click(object sender, EventArgs e) //video
 {
     capture = new VideoCapture(logic.openVideo());
     capture.ImageGrabbed += ProcessFrame_vid;
     capture.Start();
     textBox4.Text = capture.GetCaptureProperty(CapProp.FrameCount).ToString();  //количество кадров в видео
     textBox5.Text = capture.GetCaptureProperty(CapProp.XiFramerate).ToString(); //кадроы в секунду в герцах
     textBox6.Text = capture.GetCaptureProperty(CapProp.FrameHeight).ToString(); //высота кадров видео
     textBox7.Text = capture.GetCaptureProperty(CapProp.FrameWidth).ToString();  //ширина кадров видео
 }
예제 #30
0
 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
     if (Video.Checked)
     {
         capt              = new VideoCapture(openFileDialog1.FileName);
         TotalFrames       = capt.GetCaptureProperty(CapProp.FrameCount);
         FrameRate         = capt.GetCaptureProperty(CapProp.Fps);
         trackBar1.Maximum = (int)TotalFrames;
     }
 }