Giter Site home page Giter Site logo

Comments (3)

kolomietsvv avatar kolomietsvv commented on May 17, 2024

If still relevant. I have Inherited the Capture class (v3.1.0.1 the Capture class still had not been renamed to VideoCapture, version from nuget), and I have overrided the Grab function. That is what I've got.

public class VideoCapture : Capture
    {
        public new event EventHandler ImageGrabbed;

        public event EventHandler GrabFailed;

        public VideoCapture(string inputString) : base(inputString) { }

        [HandleProcessCorruptedStateExceptions]
        public override bool Grab()
        {
            try
            {
                if (_ptr == IntPtr.Zero)
                    return false;

                bool grabbed = cveVideoCaptureGrab(Ptr);

                if (grabbed)
                    ImageGrabbed?.Invoke(this, new EventArgs());
                else
                    GrabFailed?.Invoke(this, new EventArgs());
                return grabbed;
            }
            catch
            {
                Thread.Yield();
                GrabFailed?.Invoke(this, new EventArgs());
                return false;
            }
        }

        /// <summary>
        /// Grab a frame
        /// </summary>
        /// <param name="capture">Video capturing structure</param>
        /// <returns>True on success</returns>
        [DllImport("cvextern", CallingConvention = CvInvoke.CvCallingConvention)]
        [return: MarshalAs(CvInvoke.BoolToIntMarshalType)]
        internal static extern bool cveVideoCaptureGrab(IntPtr capture);
}

Sometimes _capture.GrabFailed += ReconnectCamera works, but sometimes it steps into grub, but doesn't reach the GrabFailed?.Invoke(this, new EventArgs());. And stays somwhere in bool grabbed = cveVideoCaptureGrab(Ptr);

from emgucv.

LingboTang avatar LingboTang commented on May 17, 2024

I don't think this problem has been fixed up till now, when I read the source code, there's no exception handling for Grab, Retrieve and QueryFrame. I'm using the *.dll directly, so I can't simply override that one function. It is really inconvenient, please consider fix it right away.

from emgucv.

LingboTang avatar LingboTang commented on May 17, 2024

After we get an decoding error like:

h264: cabac decode of qscale diff failed at error decoding

This line:

bool grabbed = CvInvoke.cveVideoCaptureGrab(Ptr);

will always return false because the Ptr will point to null, so cveVideoCaptureGrab will not grab any frames successfully. How I fix this problem right now is every time the decoding error pops up, I'll just restart the capture. But I think EmguCV should handle this problem on your side.

from emgucv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.