rtsp makes high cpu and memory usage #887
Unanswered
DongkyuK25
asked this question in
Q&A
Replies: 1 comment
-
GC.Collect(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i'm novice developer using c#. I made User Control for playing rtsp from emgu.cv. I used this user control for my main program for playing 9 rtsp. but when i used my user control 9 times, it makes my cpu overflow, more than 70% cpu usage, also 1.3GB memory usage. i don't know what's wrong with my code. please help me anyone used emgu.cv in c#. it doesn't matter when use only one rtsp user Control. please tell me if my code seems bad, how to fix it! i don't know reason. please help me as fast as you can! this is my code
capture = new VideoCapture(rtspUrl, VideoCapture.API.Ffmpeg);
capture.SetCaptureProperty(CapProp.Fps, frame);
capture.Start();
Task.Run(async () =>
{
while (isPlaying)
{
UpdateFrame();
await Task.Delay(1000 / frame);
Thread.Sleep(1);
}
});
}
using (Mat frame = new Mat())
{
capture.Retrieve(frame, 0);
if (!frame.IsEmpty)
{
using (Image<Bgr, byte> image = frame.ToImage<Bgr, byte>())
{
lock (captureLock)
{
try
{
if (!isRecording && videoWriter !=null)
videoWriter.Dispose();
else if (isRecording && videoWriter != null)
{
if(frame!=null)
videoWriter.Write(frame)
}
}
catch (System.AccessViolationException) { }
}
pictureBoxRTSP1.Invoke((MethodInvoker)(() =>pictureBoxRTSP1.Image = image.ToBitmap()));
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions