开发者

How to import live video stream and capture one frame

开发者 https://www.devze.com 2023-01-11 02:38 出处:网络
How would I go abou开发者_运维问答t capturing one frame from a feed of video from a webcam or video capture card in C#?I want to display the live feed and have a method that takes one frame and saves

How would I go abou开发者_运维问答t capturing one frame from a feed of video from a webcam or video capture card in C#? I want to display the live feed and have a method that takes one frame and saves it to a remote server either via FTP or over a shared network path.


If you are able to streaming live video, then you can capture the live video stream just click on button by this code:

private Capture capture = null;

private void btnStart_Click(object sender, System.EventArgs e)
        {
            try
            {
                if ( capture == null )
                    throw new ApplicationException( "Please select a video and/or audio device." );
                if ( !capture.Cued )
                    capture.Filename = txtFilename.Text;
                capture.Start();
                btnCue.Enabled = false;
                btnStart.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show( ex.Message + "\n\n" + ex.ToString() );
            }
        }


You could use OpenCV. If you search on StackOverflow you'll find a lot of source on how to do that.

There's even .NET wrappers for OpenCV like opencvdotnet and Emgu CV.

You will probably end up using a few functions from the library, such as cvCaptureFromCAM() and cvQueryFrame().

0

精彩评论

暂无评论...
验证码 换一张
取 消