使用Visual Basic 2013中的EMGU 3.0.0分析视频文件中的帧

时间:2015-08-12 13:22:47

标签: vba video video-capture emgucv

我一直在Visual Basic环境中使用EMGU 2.9.0来打开视频文件,按顺序读取帧,分析它们并关闭视频。

这是通过以下方式完成的:

    Private Sub BW_JSD_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BW_JSD.DoWork
    Dim CurrentFrameMAT As New Mat()

    Dim frameCount As Integer = 1
    Dim numFrames As Integer                                                 ' video identifier, percentage complete, and number of frame for the video

    Dim filenr As Long = 0

    For Each file As String In lstbAnalysisList.Items
        Dim previousFrameMAT As New Mat()

        filenr += 1

        Using fingerprintCapture As New Capture(file)                                                                   ' Create a capture from file 
            numFrames = CType(Math.Round(fingerprintCapture.GetCaptureProperty(CapProp.FrameCount)), Integer)     ' Get video's total number of frames

            frameCount = 1

            fingerprintCapture.SetCaptureProperty(CapProp.PosFrames, 0)                                   ' Jump to start frame
            CurrentFrameMAT = fingerprintCapture.QueryFrame()

            While fingerprintCapture.GetCaptureProperty(CapProp.PosFrames) < 0.0                          ' Make sure the start frame was found (codecs create problems with the set frame pos function)
                CurrentFrameMAT = fingerprintCapture.QueryFrame()
            End While

            While CurrentFrameMAT IsNot Nothing                                                                            

                If MyFrameAnalysisFunction(currentFrameMAT, previousFrameMAT) = 1 Then
                    MessageBox.Show('This part is irrelevant')
                End If

                previousFrameMAT = CurrentFrameMAT.Clone()     ' Update frame objects by saving previous frame and querying a new one
                CurrentFrameMAT = fingerprintCapture.QueryFrame()

                frameCount += 1
            End While

        End Using
    Next

End Sub

将代码更新到较新版本的Emgu 3.0.0时,我一直在努力让它再次运行。似乎新版本已经不再使用Image类而更喜欢Mat类。

更新后的代码会编译,但我尝试检索的帧仍然没有。改编后的代码如下:

fingerprintCapture.Start()
fingerprintCapture.Grab() 'Grab a frame
fingerprintCapture.Retrieve() 'Gray image after Grab()

调试时,CurrentFrameMAT保持不变。

关于如何顺序读取帧的任何建议?

我见过一个名为Grab()的函数,并检索与捕获对象相关的函数但无法使其工作。一个人在哪里开始这个过程?

iname = $(this).val();
if (iname !== 'Submit')..

非常感谢任何有关视频/网络摄像头捕捉的新Emgu版本实施的建议或链接!

0 个答案:

没有答案