DK kim
DK kim

Reputation: 29

AccessViolationException in emgu.cv Rtsp Player

I'm trying to make RTSP Player, Using Emgu.cv.

but when I dispose VideoCapture, AccessViolationException occured at capture.QueryFrame();

I want know how to fix it

also capture frame was delayed,

webcam's frame is 20fps, but my project captured only 8 frame.

please help me.

thank you.

this is my Code.

private void UpdateFrame(object sender, EventArgs e)
    {
        try
        {
            if (capture == null)
                return;
            if (capture != null && capture.Ptr != IntPtr.Zero)
            {
                if (capture.QueryFrame() != null)
                {
                    using (Image<Bgr, byte> image = capture.QueryFrame().ToImage<Bgr, byte>())
                    {
                        lock (captureLock)
                        {
                            isPlaying = true;
                            if (!isRecording && videoWriter != null)
                                videoWriter.Dispose();
                            else if (isRecording && videoWriter != null && image != null)
                            {
                                videoWriter.Write(image);
                            }
                            if (pictureBoxMain.InvokeRequired)
                            {
                                pictureBoxMain.Invoke((MethodInvoker)(() => pictureBoxMain.Image = image.ToBitmap()));
                            }
                        }
                    }
                }
                else if(capture.QueryFrame() == null)
                {
                    Debug.WriteLine("QueryFrame = null");
                }
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("UC_MPP.MPP.UpdateFrame : " + ex.Message);
        }
    }

When I want stop capture, So I disposed capture.

however AccessViolationException occured in

using (Image<Bgr, byte> image = capture.QueryFrame().ToImage<Bgr, byte>()) ---- this Line

at capture.QueryFrame().

thank you for all of your comment.

Upvotes: 1

Views: 35

Answers (0)

Related Questions