opencvsharp
opencvsharp copied to clipboard
`VideoCapture.Open()` is significantly slower on x64 as compared to x86.
Summary of your issue
VideoCapture.Open() is significantly slower on x64 as compared to x86.
x64: 5 to 10 seconds
x86: 1 to 2 seconds
I noticed this issue was raised but there wasn't a solution.
Environment
OpenCvSharp-4.5.3-20210821 .NET Framework 4.7.2 Windows 10 64-bit
What did you do when you faced the problem?
I ran the sample project provided (Added a x64 configuration).
- \Sample-4.5.3-20210821\VideoCaptureForm
Example code:
paste your core code
Output:
paste your output
What did you intend to be?
What Capture API do you use? You haven't posted any sample code to reproduce.
But i also noticed that - when getting webcam streams - camera.Set(OpenCvSharp.VideoCaptureProperties.FourCC, OpenCvSharp.VideoWriter.FourCC("MJPG")) and VideoCaptureAPIs.MSMF takes a very long time to load (10 seconds) compared to VideoCapturesAPIs.DSHOW which loads instantly. Set the Capture API manually, instead of VideoCaptureAPIs.ANY.
This will also remove weird webcam artifacts!
Thanks! Setting it to VideoCapturesAPIs.DSHOW solved the issue.
I was running the sample code provided (The exact project was mentioned in my post above, so I did not think it was necessary to post the code).
It seems to be this issue opencv/opencv#17687
Adding Environment.SetEnvironmentVariable("OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS", "0"); will fix it. Using VideoCapturesAPIs.DSHOW also works but it gave me a much choppier stream
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.
I have the same issue when i run the application using any cpu it take 2sec to laod the camera. when using x64 it takes 14sec!
It seems to be this issue opencv/opencv#17687 Adding
Environment.SetEnvironmentVariable("OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS", "0");will fix it. UsingVideoCapturesAPIs.DSHOWalso works but it gave me a much choppier stream
It work!