Answer the question
In order to leave comments, you need to log in
Why is this code using so much memory?
The code below uses a lot of memory, can you tell me how to make it not use so much?
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Windows.Forms;
// Important: include the opencvsharp library in your code
using OpenCvSharp;
using OpenCvSharp.Extensions;
namespace CameraApp
{
public partial class Form1 : Form
{
private Thread camera;
private void CaptureCamera()
{
camera = new Thread(new ThreadStart(CaptureCameraCallback));
camera.Start();
}
private void CaptureCameraCallback()
{
VideoCapture capture = new VideoCapture(0);
capture.Open(0);
while (true)
{
pictureBox1.Image = BitmapConverter.ToBitmap(capture.RetrieveMat());
}
}
public Form1()
{
InitializeComponent();
CaptureCamera();
}
// When the user clicks on the start/stop button, start or release the camera and setup flags
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.Show();
}
private void button2_Click(object sender, EventArgs e)
{
pictureBox1.Hide();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question