pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

如何初始化 AForge 網絡攝像頭

How initialize AForge webcam(如何初始化 AForge 網絡攝像頭)
本文介紹了如何初始化 AForge 網絡攝像頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我嘗試使用 Aforge 編寫一小段代碼來捕獲幀我參考了 Aforge.dll 和 AForge.Video.DirectShow.dll代碼如下,但我做錯了什么.警告我得到名稱 videoDevices 在當前上下文中不存在.我認為這與我嘗試創建該變量的位置有關,但我不確定在哪里放置按鈕的代碼以使其初始化.錯誤在 Visual Studio 中也顯示為對象videoDevices"下的紅線

I try to write a small peace of code to capture a frame using Aforge I made a reference to Aforge.dll and AForge.Video.DirectShow.dll The code is below, but i am doing something wrong. The Warning i get "the name videoDevices does not exist in the current context. I think it has to do about where i try to create that variable but i'm not exactly sure as where to place that code of the button to get it initialized. The error is displayed in visual studio also as a redline under the object "videoDevices"

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge;
using AForge.Video.DirectShow;

namespace AforgeCam
 {
   public partial class Form1 : Form
 {
    public Form1()
    {
        InitializeComponent();

    }

    private void button1_Click(object sender, EventArgs e)
    {

        videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

        if (videoDevices.Count == 0)
            throw new ApplicationException();

        foreach (FilterInfo device in videoDevices)
        {
    VideoCaptureDevice videoSource = new    VideoCaptureDevice(device.MonikerString);
            videoSource.DesiredFrameSize = new Size(320, 240);
            videoSource.DesiredFrameRate = 15;
            videoSourcePlayer1.VideoSource = videoSource;
            videoSourcePlayer1.Start();
        }

    }
    }
}

推薦答案

根據要求,解決方案如下,代碼有效,我將針對我對此提出的另一個問題提出一個新問題.該代碼需要一個下拉框、2個按鈕和一個圖片框

As requested the solution is below , the code works, i will raise a new question for another question i have about it. the code requires a dropdown box, 2 buttons and a picturebox

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AforgeCam;
using AForge.Video;
using AForge.Video.DirectShow;

namespace AforgeCam
{
public partial class Form1 : Form
{
private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideo;

public Form1() // init
{
    InitializeComponent();
    {
        VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
        {
            comboBox1.Items.Add(VideoCaptureDevice.Name);
        }
        comboBox1.SelectedIndex = 0;
    }
}

private void button1_Click(object sender, EventArgs e)
{
    FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
    FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
    FinalVideo.Start();
}

void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    Bitmap video = (Bitmap)eventArgs.Frame.Clone();
    pictureBox1.Image = video;

}

private void button2_Click(object sender, EventArgs e)
{
    FinalVideo.Stop();
}
}

這篇關于如何初始化 AForge 網絡攝像頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 无负压供水设备,消防稳压供水设备-淄博创辉供水设备有限公司 | 臭氧发生器_臭氧消毒机 - 【同林品牌 实力厂家】 | 超声波清洗机_超声波清洗机设备_超声波清洗机厂家_鼎泰恒胜 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 济南品牌设计-济南品牌策划-即合品牌策划设计-山东即合官网 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 结晶点测定仪-润滑脂滴点测定仪-大连煜烁 | 法兰螺母 - 不锈钢螺母制造厂家 - 万千紧固件--螺母街 | 江苏农村商业银行招聘网_2024江苏农商行考试指南_江苏农商行校园招聘 | 临朐空调移机_空调维修「空调回收」临朐二手空调 | 京港视通报道-质量走进大江南北-京港视通传媒[北京]有限公司 | 中视电广_短视频拍摄_短视频推广_短视频代运营_宣传片拍摄_影视广告制作_中视电广 | 颗粒机,颗粒机组,木屑颗粒机-济南劲能机械有限公司 | 卓能JOINTLEAN端子连接器厂家-专业提供PCB接线端子|轨道式端子|重载连接器|欧式连接器等电气连接产品和服务 | 刹车盘机床-刹车盘生产线-龙口亨嘉智能装备 | 定制异形重型钢格栅板/钢格板_定做踏步板/排水沟盖板_钢格栅板批发厂家-河北圣墨金属制品有限公司 | 液压油缸生产厂家-山东液压站-济南捷兴液压机电设备有限公司 | 西点培训学校_法式西点培训班_西点师培训_西点蛋糕培训-广州烘趣西点烘焙培训学院 | 选宝石船-陆地水上开采「精选」色选机械设备-青州冠诚重工机械有限公司 | 北京律师事务所_房屋拆迁律师_24小时免费法律咨询_云合专业律师网 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 铝机箱_铝外壳加工_铝外壳厂家_CNC散热器加工-惠州市铂源五金制品有限公司 | 上海阳光泵业制造有限公司 -【官方网站】| 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 成都装修公司-成都装修设计公司推荐-成都朗煜装饰公司 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 钢制暖气片散热器_天津钢制暖气片_卡麦罗散热器厂家 | 结晶点测定仪-润滑脂滴点测定仪-大连煜烁 | 脉冲除尘器,除尘器厂家-淄博机械 | 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 爱德华真空泵油/罗茨泵维修,爱发科-比其尔产品供应东莞/杭州/上海等全国各地 | _网名词典_网名大全_qq网名_情侣网名_个性网名 | 苏商学院官网 - 江苏地区唯一一家企业家自办的前瞻型、实操型商学院 | 新密高铝耐火砖,轻质保温砖价格,浇注料厂家直销-郑州荣盛窑炉耐火材料有限公司 | 立式硫化罐-劳保用品硫化罐-厂家直销-山东鑫泰鑫硫化罐厂家 | 废旧物资回收公司_广州废旧设备回收_报废设备物资回收-益美工厂设备回收公司 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 「银杏树」银杏树行情价格_银杏树种植_山东程锦园林 | 精密冲床,高速冲床等冲压设备生产商-常州晋志德压力机厂 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 |