eeteee 2017-02-25 01:36 采纳率: 50%
浏览 1682
已结题

c# AForge 摄像程序xp系统下不正常

AForge.NET 2.2.5 的videoSourcePlayer控件做的摄像程序在新装的xp系统下调用采摄像头无图像黑屏,采集不到图像,但摄像头灯会亮。
但把程序拷贝到win7或自己做开发的xp系统上能正常使用,在不能正常用的xp系统下直接用vc+ directshow开发的视频软件也能正常使用。
为什么会出现这种情况?

  • 写回答

1条回答 默认 最新

  • eeteee 2017-02-25 01:57
    关注

    //代码
    videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
    。。。
    //委托促发分辨率等设置
    private void EnumeratedSupportedFrameSizes(VideoCaptureDevice videoDevice)
    {
    this.Cursor = Cursors.WaitCursor;

            videoResolutionsCombo.Items.Clear();
            snapshotResolutionsCombo.Items.Clear();
    
            try
            {
                videoCapabilities = videoDevice.VideoCapabilities;
                snapshotCapabilities = videoDevice.SnapshotCapabilities;
    
                //视频分辨率
                foreach (VideoCapabilities capabilty in videoCapabilities)
                {
                    videoResolutionsCombo.Items.Add(string.Format("{0} x {1}",
                        capabilty.FrameSize.Width, capabilty.FrameSize.Height));
                }
                //快照
                foreach (VideoCapabilities capabilty in snapshotCapabilities)
                {
                    snapshotResolutionsCombo.Items.Add(string.Format("{0} x {1}",
                        capabilty.FrameSize.Width, capabilty.FrameSize.Height));
                }
    
    
                if (videoCapabilities.Length == 0)
                {
                    videoResolutionsCombo.Items.Add("不支持");
                }
    
                if (snapshotCapabilities.Length == 0)
                {
                    snapshotResolutionsCombo.Items.Add("不支持");
                }
    
                videoResolutionsCombo.SelectedIndex = Convert.ToInt32( ContentValue("Device", "SVideoIndex"));
                snapshotResolutionsCombo.SelectedIndex = 0;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
    设备连接
    

    private void VideoConnect()
    {
    if (videoDevice != null)
    {
    //选择连接设备
    if ((videoCapabilities != null) && (videoCapabilities.Length != 0))
    {

    //分辨率设置
    videoDevice.VideoResolution = videoCapabilities[videoResolutionsCombo.SelectedIndex];

    }

                //快照用
                if ((snapshotCapabilities != null) && (snapshotCapabilities.Length != 0))
                {
                    videoDevice.ProvideSnapshots = true;
                    videoDevice.SnapshotResolution = snapshotCapabilities[snapshotResolutionsCombo.SelectedIndex];
                    videoDevice.SnapshotFrame += new NewFrameEventHandler(videoDevice_SnapshotFrame);
                }
    
                EnableConnectionControls(false);
                videoSourcePlayer.VideoSource = videoDevice;
                videoSourcePlayer.Start();
            }
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog