I'm running Aforge.net's provided camera test samples on my Dual Core 2.0 GHz laptop with 2 GB RAM. Right now I'm seeing a lot of CPU usage as the application starts displaying visuals from cameras. It's currently consuming 60% to 70% of the entire CPU power.
Can anyone tell me why it's consuming that much CPU and how can I avoid it? I have to build a similar application which would require camera vision and I would be using C#.
In this method CPU consuming more.
public void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap imgforms = (Bitmap)eventArgs.Frame.Clone();
h = imgforms.Height;
w = imgforms.Width;
//video = (Bitmap)eventArgs.Frame.Clone();
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
imgforms.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
bi.EndInit();
bi.Freeze();
Dispatcher.Invoke(new ThreadStart(delegate
{
cam_image.Source = bi;//GetBitmapImage(imgforms);
}));
//bi = null;
// BitmapSource bi = Convert(video);
if(statusText == "Stop Record")
{
// AVIwriter.Quality = 0;
avwriter.AddFrame(imgforms);
}
}