如何从事件befor执行方法AcceptTcpClientAsync获取位图变量

编程入门 行业动态 更新时间:2024-10-24 22:19:08
本文介绍了如何从事件befor执行方法AcceptTcpClientAsync获取位图变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我正在使用AForge框架,我从网络摄像头获取图像,然后我想将此图像从服务器发送到客户端。但问题在于,在执行方法AcceptTcpClientAsync并且位图变量为null之后,我得到了位图变量,该变量在事件中。如何在执行方法之前获取图像AcceptTcpClientAsync 代码:

Hello, I'm use AForge framework and i get image capture from webcam, then i want to send this image from server to client. But the problem consists of that i get the bitmap variable, which gets in event, after executing method AcceptTcpClientAsync and bitmap variable is null. How to get image before executing method AcceptTcpClientAsync Code:

private void Form1_Load(object sender, EventArgs e) { StartCapture(); Form1 async = new Form1(51510); async.Start(); Console.ReadLine(); }

public void StartCapture() { VidoeCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); FinalVideo = new VideoCaptureDevice(VidoeCaptureDevices[0].MonikerString); FinalVideo.VideoResolution = FinalVideo.VideoCapabilities[2]; FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); FinalVideo.Start(); Thread.Sleep(2000); } void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs) { video = (Bitmap)eventArgs.Frame.Clone(); }

public async void Start() { //Thread.Sleep(10000); IPAddress ipAddre = IPAddress.Loopback; TcpListener listener = new TcpListener(ipAddre, _listeningPort); listener.Start(); LogMessage("Server is running"); LogMessage("Listening on port " + _listeningPort); while (true) { //CaptureImageFromCamera captureFromCamera = new CaptureImageFromCamera(); //Bitmap image = captureFromCamera.StartCapture(); CodingImage img = new CodingImage(); buffer = img.CodingImages(video); count = buffer.Length; lenght = buffer.Length.ToString(); LogMessage("Waiting for connections..."); try { var tcpClient = await listener.AcceptTcpClientAsync(); HandleConnectionAsync(tcpClient); } catch (Exception exp) { LogMessage(exp.ToString()); } i++; } }

我想在方法CodingImages中使用图像(位图视频)。 希望,有人可以帮助我。 对不起我的英语

I want to use image(bitmap video) in method CodingImages. Hope, that someone can help me. Sorry for my English

推荐答案

更多推荐

如何从事件befor执行方法AcceptTcpClientAsync获取位图变量

本文发布于:2023-11-12 18:51:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位图   变量   事件   方法   befor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!