Why Attempt to read or write in protected memory.?

Asked

Viewed 180 times

0

What I’m doing is taking a frame of some videos, but whenever I try to access the saved images I get Read or write attempt in protected memory. I can’t use them after "saving". What I’m doing wrong?

Imports System.Drawing   
Imports System.Windows.Forms  
Imports Emgu.CV

    Private Const LocFrame = 0.2
    Public Shared listMiniatura As New ImageList With {.ColorDepth = ColorDepth.Depth32Bit, .ImageSize = New Size(255, 255)}        

    Public Shared Sub GetThumbnail(path As String)
            If listMiniatura.Images.ContainsKey(path) Then
                Exit Sub
            End If

            Dim f As Integer
            Dim m As Mat

            'Abre o video para pegar o frame
            Using cap As New VideoCapture(path)
                If cap.IsOpened Then

                    'Posição do frame que será retirado
                    f = cap.GetCaptureProperty(CvEnum.CapProp.FrameCount) * LocFrame
                    cap.SetCaptureProperty(CvEnum.CapProp.PosFrames, f)
                    m = New Mat
                    cap.Read(m)

                    'Salva em listMiniatura
                    listMiniatura.Images.Add(path, m.Bitmap)                    
                End If
            End Using
    End Sub
  • 1

    You’re probably trying to use parallelism without understanding how it works, and you probably don’t need it. I would avoid with all my might doing something like this, until there is no other way, but as it seems IO, there must be a better solution.

  • I’ve tried without the same thing.

  • When I will use the image that is in listMiniatura with or without parallelism of the same error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.