zoukankan      html  css  js  c++  java
  • 使用AForge.NET Framework打开摄像头并截图 C#

    videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                        if (videoDevices.Count == 0)
                        {
                            MessageBox.Show("未检测到摄像头,请确认!");
                            return;
                        }
                        selectedDeviceIndex = 0;
                        videoSource = new VideoCaptureDevice(videoDevices[selectedDeviceIndex].MonikerString);//连接摄像头
                        int ResolutionIndex = 0;
                        for (int i = 0; i < videoSource.VideoCapabilities.Length; i++)
                        {
                            if (videoSource.VideoCapabilities[i].FrameSize.Width == 1600)  //1600*1200分辨率即可
                            {
                                ResolutionIndex = i;
                                break;
                            }
                        }
                        videoSource.VideoResolution = videoSource.VideoCapabilities[ResolutionIndex];
                        videoSourcePlayer1.VideoSource = videoSource;
                        // set NewFrame event handler
                        videoSourcePlayer1.Start();
    

     

    下载库添加引用添加 

    videoSourcePlayer
    控件就不说了

    代码操作很简单

    但有可能部分usb摄像头不支持

    截图
    if (videoSource == null)
                                    return;
                                Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame();
    

      

  • 相关阅读:
    校赛writeup
    memory-300——Jarvis OJ
    校赛_warmup_pwn
    sctf
    iscc-pwn1
    level3-64——Jarvis OJ
    JarvisOJ——level2
    JarvisOJ——guestbook
    Javris oj——level0
    linux 服务器 tomcat环境部署出错 重启
  • 原文地址:https://www.cnblogs.com/jhlong/p/7488900.html
Copyright © 2011-2022 走看看