opencvsharp icon indicating copy to clipboard operation
opencvsharp copied to clipboard

VideoCapture Dispose long time.

Open simphonydeveloper opened this issue 1 year ago • 1 comments

Summary of your issue

I dispose VideoCapture on my own computer is very fast, but it closes very slowly on a surface computer. Usually takes 6-7 seconds

Environment

.NET Version:4.8

NUGET:

  <package id="OpenCvSharp4" version="4.10.0.20240616" targetFramework="net48" />
  <package id="OpenCvSharp4.Extensions" version="4.10.0.20240616" targetFramework="net48" />
  <package id="OpenCvSharp4.runtime.win" version="4.10.0.20240616" targetFramework="net48" />
  <package id="OpenCvSharp4.WpfExtensions" version="4.10.0.20240616" targetFramework="net48" />

My PC: WIN10 CPU:Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz 2.59 GHz

Surface GO: WIN10 CPU:Intel(R)N200 1.00 GHZ

What did you do when you faced the problem?

I use task.factory.startnew(()=>{}) to dispose it. but this will cause my content to go white at some point.

Example code:

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();

//capture.Release();
Task.Factory.StartNew(() =>
{
    capture.Dispose();
});
sw.Stop();
Console.WriteLine("capture" + sw.Elapsed.TotalSeconds);
logger.Info("capture" + sw.Elapsed.TotalSeconds);

Output:

StopCamera Info capture7.7534943

What did you intend to be?

simphonydeveloper avatar Sep 16 '24 15:09 simphonydeveloper

Find a possible reason, the Windows Camera Frame Server will occupy CPU 100% when opening the camera, and then VideoCapture Dispose will take a long time.

simphonydeveloper avatar Oct 07 '24 06:10 simphonydeveloper

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 01:04 stale[bot]