shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.22k stars 1.13k forks source link

OpenCV Wrapper Bug: Zero Frame Rate and Count with Special Characters in Filename #1633

Open interiv opened 6 months ago

interiv commented 6 months ago

Summary of your issue

Encountering a bug in OpenCV wrapper where special characters in filenames (like the 🔥 emoji) result in frame rate and frame count being returned as 0.

Environment

win11, last opencvsharp version

What did you do when you faced the problem?

Attempted to open and process a video file with a filename containing special characters (e.g., emojis).

Example code:

using (var videoCapture = new VideoCapture())
{
    videoCapture.Open(mediaFile); // Replace with your file path

    Mat mat = new Mat();
    videoCapture.Read(mat);

    double frameCount = videoCapture.Get(VideoCaptureProperties.FrameCount);
    double frameRate = videoCapture.Get(VideoCaptureProperties.Fps);
    double duration = frameCount / frameRate;
    if (frameCount == 1)
    {
        duration = 10800; // For images
    }
    return duration;
}

Output:

Frame Rate: 0
Frame Count: 0

What did you intend to be?

Expected the correct frame rate and frame count, irrespective of special characters in the filename. Currently, it seems that special characters cause these values to be incorrectly returned as 0.