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()
{
IPAddress ipAddre = IPAddress.Loopback;
TcpListener listener = new TcpListener(ipAddre, _listeningPort);
listener.Start();
LogMessage("Server is running");
LogMessage("Listening on port " + _listeningPort);
while (true)
{
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++;
}
}
I want to use image(bitmap video) in method CodingImages.
Hope, that someone can help me.
Sorry for my English