Draw Shape Over camera Preview in Visual basic 2010

asked 2021-01-17T08:12:10.933+00:00
Lokesh R 61 Reputation points

djsalkd fbdjfdf fdnjlfg gfgnkfnflkg fgf gf fjgkfjgfg fgnlkfnglfngl >>

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
1,828 questions
{count} votes

Accepted answer
  1. answered 2021-01-18T17:55:19.377+00:00
    Castorix31 65,366 Reputation points

    To draw over Camera Preview, you can use DirectShow
    I made a test by drawing a rectangle with GDI by using [Video Mixing Renderer Filter 9][1], that you can improve
    There are a lot of declarations , but the main code is not complicated, in CaptureVideo function =>

    ![Direct-Show-Draw-Over-Preview.jpg][2]

    Imports System.Runtime.InteropServices  
      
    Public Class Form1  
        Public Enum HRESULT As Integer  
            S_OK = 0  
            S_FALSE = 1  
            E_NOTIMPL = &H80004001  
            E_NOINTERFACE = &H80004002  
            E_POINTER = &H80004003  
            E_FAIL = &H80004005  
            E_UNEXPECTED = &H8000FFFF  
            E_OUTOFMEMORY = &H8007000E  
        End Enum  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a868a9-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IGraphBuilder  
            Inherits IFilterGraph  
      
            Overloads Function AddFilter(ByVal pFilter As IBaseFilter, ByVal pName As String) As HRESULT  
            Overloads Function RemoveFilter(ByVal pFilter As IBaseFilter) As HRESULT  
            Overloads Function EnumFilters(<Out> ByRef ppEnum As IEnumFilters) As HRESULT  
            Overloads Function FindFilterByName(ByVal pName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Overloads Function ConnectDirect(ByVal ppinOut As IPin, ByVal ppinIn As IPin, ByVal pmt As IntPtr) As HRESULT  
            Overloads Function Reconnect(ByVal ppin As IPin) As HRESULT  
            Overloads Function Disconnect(ByVal ppin As IPin) As HRESULT  
            Overloads Function SetDefaultSyncSource() As HRESULT  
            Function Connect(ByVal ppinOut As IPin, ByVal ppinIn As IPin) As HRESULT  
            Function Render(ByVal ppinOut As IPin) As HRESULT  
            Function RenderFile(ByVal lpcwstrFile As String, ByVal lpcwstrPlayList As String) As HRESULT  
            Function AddSourceFilter(ByVal lpcwstrFileName As String, ByVal lpcwstrFilterName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Function SetLogFile(ByVal hFile As IntPtr) As HRESULT  
            Function Abort() As HRESULT  
            Function ShouldOperationContinue() As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("36b73882-c2c8-11cf-8b46-00805f6cef60")>  
        Interface IFilterGraph2  
            Inherits IGraphBuilder  
      
            Overloads Function AddFilter(ByVal pFilter As IBaseFilter, ByVal pName As String) As HRESULT  
            Overloads Function RemoveFilter(ByVal pFilter As IBaseFilter) As HRESULT  
            Overloads Function EnumFilters(<Out> ByRef ppEnum As IEnumFilters) As HRESULT  
            Overloads Function FindFilterByName(ByVal pName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Overloads Function ConnectDirect(ByVal ppinOut As IPin, ByVal ppinIn As IPin, ByVal pmt As IntPtr) As HRESULT  
            Overloads Function Reconnect(ByVal ppin As IPin) As HRESULT  
            Overloads Function Disconnect(ByVal ppin As IPin) As HRESULT  
            Overloads Function SetDefaultSyncSource() As HRESULT  
            Overloads Function Connect(ByVal ppinOut As IPin, ByVal ppinIn As IPin) As HRESULT  
            Overloads Function Render(ByVal ppinOut As IPin) As HRESULT  
            Overloads Function RenderFile(ByVal lpcwstrFile As String, ByVal lpcwstrPlayList As String) As HRESULT  
            Overloads Function AddSourceFilter(ByVal lpcwstrFileName As String, ByVal lpcwstrFilterName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Overloads Function SetLogFile(ByVal hFile As IntPtr) As HRESULT  
            Overloads Function Abort() As HRESULT  
            Overloads Function ShouldOperationContinue() As HRESULT  
            Function AddSourceFilterForMoniker(ByVal pMoniker As IMoniker, ByVal pCtx As IntPtr, ByVal lpcwstrFilterName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Function ReconnectEx(ByVal ppin As IPin, ByVal pmt As AM_MEDIA_TYPE) As HRESULT  
            Function RenderEx(ByVal pPinOut As IPin, ByVal dwFlags As UInteger, ByRef pvContext As UInteger) As HRESULT  
        End Interface  
      
        Public Enum AM_RENSDEREXFLAGS  
            AM_RENDEREX_RENDERTOEXISTINGRENDERERS = &H1  
        End Enum  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a8689f-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IFilterGraph  
            Function AddFilter(ByVal pFilter As IBaseFilter, ByVal pName As String) As HRESULT  
            Function RemoveFilter(ByVal pFilter As IBaseFilter) As HRESULT  
            Function EnumFilters(<Out> ByRef ppEnum As IEnumFilters) As HRESULT  
            Function FindFilterByName(ByVal pName As String, <Out> ByRef ppFilter As IBaseFilter) As HRESULT  
            Function ConnectDirect(ByVal ppinOut As IPin, ByVal ppinIn As IPin, ByVal pmt As IntPtr) As HRESULT  
            Function Reconnect(ByVal ppin As IPin) As HRESULT  
            Function Disconnect(ByVal ppin As IPin) As HRESULT  
            Function SetDefaultSyncSource() As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a86893-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IEnumFilters  
            Function [Next](ByVal cFilters As UInteger, <Out> ByRef ppFilter As IBaseFilter, <Out> ByRef pcFetched As UInteger) As HRESULT  
            Function Skip(ByVal cFilters As UInteger) As HRESULT  
            Function Reset() As HRESULT  
            Function Clone(<Out> ByRef ppEnum As IEnumFilters) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("0000010c-0000-0000-C000-000000000046")>  
        Interface IPersist  
            Function GetClassID(<Out> ByRef pClassID As Guid) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a86899-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IMediaFilter  
            Inherits IPersist  
      
            Overloads Function GetClassID(<Out> ByRef pClassID As Guid) As HRESULT  
            Function [Stop]() As HRESULT  
            Function Pause() As HRESULT  
            Function Run(ByVal tStart As Int64) As HRESULT  
            Function GetState(ByVal dwMilliSecsTimeout As Integer, <Out> ByRef State As FILTER_STATE) As HRESULT  
            Function SetSyncSource(ByVal pClock As IntPtr) As HRESULT  
            Function GetSyncSource(<Out> ByRef pClock As IntPtr) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a86895-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IBaseFilter  
            Inherits IMediaFilter  
      
            Overloads Function GetClassID(<Out> ByRef pClassID As Guid) As HRESULT  
            Overloads Function [Stop]() As HRESULT  
            Overloads Function Pause() As HRESULT  
            Overloads Function Run(ByVal tStart As Int64) As HRESULT  
            Overloads Function GetState(ByVal dwMilliSecsTimeout As Integer, <Out> ByRef State As FILTER_STATE) As HRESULT  
            Overloads Function SetSyncSource(ByVal pClock As IntPtr) As HRESULT  
            Overloads Function GetSyncSource(<Out> ByRef pClock As IntPtr) As HRESULT  
            Function EnumPins(<Out> ByRef ppEnum As IEnumPins) As HRESULT  
            Function FindPin(ByVal Id As String, <Out> ByRef ppPin As IPin) As HRESULT  
            Function QueryFilterInfo(<Out> ByRef pInfo As FILTER_INFO) As HRESULT  
            Function JoinFilterGraph(ByVal pGraph As IFilterGraph, ByVal pName As String) As HRESULT  
            Function QueryVendorInfo(<Out> ByRef pVendorInfo As String) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a86892-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IEnumPins  
            Function [Next](ByVal cPins As UInteger, <Out> ByRef ppPins As IPin, <Out> ByRef pcFetched As UInteger) As HRESULT  
            Function Skip(ByVal cPins As UInteger) As HRESULT  
            Function Reset() As HRESULT  
            Function Clone(<Out> ByRef ppEnum As IEnumPins) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("56a86891-0ad4-11ce-b03a-0020af0ba770")>  
        Interface IPin  
            Function Connect(ByVal pReceivePin As IPin, ByVal pmt As AM_MEDIA_TYPE) As HRESULT  
            Function ReceiveConnection(ByVal pConnector As IPin, ByVal pmt As AM_MEDIA_TYPE) As HRESULT  
            Function Disconnect() As HRESULT  
            Function ConnectedTo(<Out> ByRef pPin As IPin) As HRESULT  
            Function ConnectionMediaType(<Out> ByRef pmt As AM_MEDIA_TYPE) As HRESULT  
            Function QueryPinInfo(<Out> ByRef pInfo As PIN_INFO) As HRESULT  
            Function QueryDirection(<Out> ByRef pPinDir As PIN_DIRECTION) As HRESULT  
            Function QueryId(<Out> ByRef Id As String) As HRESULT  
            Function QueryAccept(ByVal pmt As AM_MEDIA_TYPE) As HRESULT  
            Function EnumMediaTypes(<Out> ByRef ppEnum As IEnumMediaTypes) As HRESULT  
            Function QueryInternalConnections(<Out> ByRef apPin As IPin, ByRef nPin As UInteger) As HRESULT  
            Function EndOfStream() As HRESULT  
            Function BeginFlush() As HRESULT  
            Function EndFlush() As HRESULT  
            Function NewSegment(ByVal tStart As Int64, ByVal tStop As Int64, ByVal dRate As Double) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("89c31040-846b-11ce-97d3-00aa0055595a")>  
        Public Interface IEnumMediaTypes  
            Function [Next](ByVal cMediaTypes As UInteger, ByRef ppMediaTypes As AM_MEDIA_TYPE, ByRef pcFetched As UInteger) As HRESULT  
            Function Skip(ByVal cMediaTypes As UInteger) As HRESULT  
            Function Reset() As HRESULT  
            Function Clone(ByRef ppEnum As IEnumMediaTypes) As HRESULT  
        End Interface  
        <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>  
        Public Structure AM_MEDIA_TYPE  
            Public majortype As Guid  
            Public subtype As Guid  
            Public bFixedSizeSamples As Boolean  
            Public bTemporalCompression As Boolean  
            Public lSampleSize As UInteger  
            Public formattype As Guid  
            ' public pUnk As IUnknown  
            Public pUnk As IntPtr  
            Public cbFormat As UInteger  
            Public pbFormat As Byte  
        End Structure  
      
        Public Enum PIN_DIRECTION As Integer  
            PINDIR_INPUT = 0  
            PINDIR_OUTPUT = (PINDIR_INPUT + 1)  
        End Enum  
      
        <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>  
        Public Class PIN_INFO  
            Public filter As IBaseFilter  
            Public dir As PIN_DIRECTION  
            <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)>  
            Public name As String  
        End Class  
      
        <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>  
        Public Class FILTER_INFO  
            <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)>  
            Public achName As String  
            <MarshalAs(UnmanagedType.IUnknown)> ' IFilterGraph  
            Private pUnk As Object  
        End Class  
      
        Public Enum FILTER_STATE  
            State_Stopped = 0  
            State_Paused = (State_Stopped + 1)  
            State_Running = (State_Paused + 1)  
        End Enum  
      
        <ComImport()>  
        <Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770")>  
        <InterfaceType(ComInterfaceType.InterfaceIsDual)>  
        Public Interface IMediaControl  
            Function Run() As HRESULT  
            Function Pause() As HRESULT  
            Function [Stop]() As HRESULT  
            Function GetState(ByVal msTimeout As Integer, ByRef pfs As Integer) As HRESULT  
            Function RenderFile(ByVal strFilename As String) As HRESULT  
            Function AddSourceFilter(ByVal strFilename As String, ByRef ppUnk As Object) As HRESULT  
            Function get_FilterCollection(ByRef ppUnk As Object) As HRESULT  
            Function get_RegFilterCollection(ByRef ppUnk As Object) As HRESULT  
            Function StopWhenReady() As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsDual)>  
        <Guid("56a868b4-0ad4-11ce-b03a-0020af0ba770")>  
        Public Interface IVideoWindow  
            Function put_Caption(ByVal strCaption As String) As HRESULT  
            Function get_Caption(ByRef strCaption As String) As HRESULT  
            Function put_WindowStyle(ByVal WindowStyle As Integer) As HRESULT  
            Function get_WindowStyle(ByRef WindowStyle As Integer) As HRESULT  
            Function put_WindowStyleEx(ByVal WindowStyleEx As Integer) As HRESULT  
            Function get_WindowStyleEx(ByRef WindowStyleEx As Integer) As HRESULT  
            Function put_AutoShow(ByVal AutoShow As Integer) As HRESULT  
            Function get_AutoShow(ByRef AutoShow As Integer) As HRESULT  
            Function put_WindowState(ByVal WindowState As Integer) As HRESULT  
            Function get_WindowState(ByRef WindowState As Integer) As HRESULT  
            Function put_BackgroundPalette(ByVal BackgroundPalette As Integer) As HRESULT  
            Function get_BackgroundPalette(ByRef pBackgroundPalette As Integer) As HRESULT  
            <PreserveSig()>  
            Function put_Visible(ByVal Visible As Integer) As HRESULT  
            Function get_Visible(ByRef pVisible As Integer) As HRESULT  
            Function put_Left(ByVal Left As Integer) As HRESULT  
            Function get_Left(ByRef pLeft As Integer) As HRESULT  
            Function put_Width(ByVal Width As Integer) As HRESULT  
            Function get_Width(ByRef pWidth As Integer) As HRESULT  
            Function put_Top(ByVal Top As Integer) As HRESULT  
            Function get_Top(ByRef pTop As Integer) As HRESULT  
            Function put_Height(ByVal Height As Integer) As HRESULT  
            Function get_Height(ByRef pHeight As Integer) As HRESULT  
            <PreserveSig()>  
            Function put_Owner(ByVal Owner As IntPtr) As HRESULT  
            Function get_Owner(ByRef Owner As IntPtr) As HRESULT  
            Function put_MessageDrain(ByVal Drain As IntPtr) As HRESULT  
            Function get_MessageDrain(ByRef Drain As IntPtr) As HRESULT  
            Function get_BorderColor(ByRef Color As Integer) As HRESULT  
            Function put_BorderColor(ByVal Color As Integer) As HRESULT  
            Function get_FullScreenMode(ByRef FullScreenMode As Integer) As HRESULT  
            Function put_FullScreenMode(ByVal FullScreenMode As Integer) As HRESULT  
            Function SetWindowForeground(ByVal Focus As Integer) As HRESULT  
            Function NotifyOwnerMessage(ByVal hwnd As IntPtr, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As HRESULT  
            <PreserveSig()>  
            Function SetWindowPosition(ByVal Left As Integer, ByVal Top As Integer, ByVal Width As Integer, ByVal Height As Integer) As HRESULT  
            Function GetWindowPosition(ByRef pLeft As Integer, ByRef pTop As Integer, ByRef pWidth As Integer, ByRef pHeight As Integer) As HRESULT  
            Function GetMinIdealImageSize(ByRef pWidth As Integer, ByRef pHeight As Integer) As HRESULT  
            Function GetMaxIdealImageSize(ByRef pWidth As Integer, ByRef pHeight As Integer) As HRESULT  
            Function GetRestorePosition(ByRef pLeft As Integer, ByRef pTop As Integer, ByRef pWidth As Integer, ByRef pHeight As Integer) As HRESULT  
            Function HideCursor(ByVal Hide As Integer) As HRESULT  
            Function IsCursorHidden(ByRef CursorHidden As Integer) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsDual)>  
        <Guid("56a868c0-0ad4-11ce-b03a-0020af0ba770")>  
        Public Interface IMediaEventEx  
            Inherits IMediaEvent  
      
    #Region "IMediaEvent"  
            Shadows Function GetEventHandle(ByRef hEvent As IntPtr) As HRESULT  
            <PreserveSig()>  
            Shadows Function GetEvent(ByRef lEventCode As Integer, ByRef lParam1 As IntPtr, ByRef lParam2 As IntPtr, ByVal msTimeout As Integer) As HRESULT  
            Shadows Function WaitForCompletion(ByVal msTimeout As Integer, ByRef pEvCode As Integer) As HRESULT  
            Shadows Function CancelDefaultHandling(ByVal lEvCode As Long) As HRESULT  
            Shadows Function RestoreDefaultHandling(ByVal lEvCode As Integer) As HRESULT  
            Shadows Function FreeEventParams(ByVal lEvCode As Integer, ByVal lParam1 As IntPtr, ByVal lParam2 As IntPtr) As HRESULT  
    #End Region  
      
            Function SetNotifyWindow(ByVal hwnd As IntPtr, ByVal lMsg As Integer, ByVal lInstanceData As IntPtr) As HRESULT  
            Function SetNotifyFlags(ByVal lNoNotifyFlags As Integer) As HRESULT  
            Function GetNotifyFlags(ByRef lplNoNotifyFlags As Integer) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsDual)>  
        <Guid("56a868b6-0ad4-11ce-b03a-0020af0ba770")>  
        Public Interface IMediaEvent  
            Function GetEventHandle(ByRef hEvent As IntPtr) As HRESULT  
            <PreserveSig()>  
            Function GetEvent(ByRef lEventCode As Integer, ByRef lParam1 As IntPtr, ByRef lParam2 As IntPtr, ByVal msTimeout As Integer) As HRESULT  
            Function WaitForCompletion(ByVal msTimeout As Integer, ByRef pEvCode As Integer) As HRESULT  
            Function CancelDefaultHandling(ByVal lEvCode As Long) As HRESULT  
            Function RestoreDefaultHandling(ByVal lEvCode As Integer) As HRESULT  
            Function FreeEventParams(ByVal lEvCode As Integer, ByVal lParam1 As IntPtr, ByVal lParam2 As IntPtr) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D")>  
        Public Interface ICaptureGraphBuilder2  
            Function SetFiltergraph(ByVal pfg As IGraphBuilder) As HRESULT  
            Function GetFiltergraph(ByRef ppfg As IGraphBuilder) As HRESULT  
            Function SetOutputFileName(ByRef pType As Guid, ByVal lpstrFile As String, ByRef ppf As IBaseFilter, ByRef ppSink As IFileSinkFilter) As HRESULT  
            Function FindInterface(ByRef pCategory As Guid, ByRef pType As Guid, ByVal pf As IBaseFilter, ByRef riid As Guid, ByRef ppint As IntPtr) As HRESULT  
            <PreserveSig()>  
            Function RenderStream(ByRef pCategory As Guid, ByRef pType As Guid, ByVal pSource As IntPtr, ByVal pfCompressor As IBaseFilter, ByVal pfRenderer As IBaseFilter) As HRESULT  
            Function ControlStream(ByRef pCategory As Guid, ByRef pType As Guid, ByVal pFilter As IBaseFilter, ByVal pstart As Int64, ByVal pstop As Int64, ByVal wStartCookie As UInt16, ByVal wStopCookie As UInt16) As HRESULT  
            Function AllocCapFile(ByVal lpstr As String, ByVal dwlSize As UInt64) As HRESULT  
            Function CopyCaptureFile(ByVal lpwstrOld As String, ByVal lpwstrNew As String, ByVal fAllowEscAbort As Integer, ByVal pCallback As IAMCopyCaptureFileProgress) As HRESULT  
            Function FindPin(ByVal pSource As IntPtr, ByVal pindir As PIN_DIRECTION, ByRef pCategory As Guid, ByRef pType As Guid, ByVal fUnconnected As Boolean, ByVal num As Integer, ByRef ppPin As IPin) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("a2104830-7c70-11cf-8bce-00aa00a3f1a6")>  
        Public Interface IFileSinkFilter  
            Function SetFileName(ByVal pszFileName As String, ByVal pmt As AM_MEDIA_TYPE) As HRESULT  
            Function GetCurFile(ByRef ppszFileName As String, ByRef pmt As AM_MEDIA_TYPE) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("670d1d20-a068-11d0-b3f0-00aa003761c5")>  
        Public Interface IAMCopyCaptureFileProgress  
            Function Progress(ByVal iProgress As Integer) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        <Guid("29840822-5B84-11D0-BD3B-00A0C911CE86")>  
        Public Interface ICreateDevEnum  
            Function CreateClassEnumerator(ByRef clsidDeviceClass As Guid, ByRef ppEnumMoniker As IEnumMoniker, ByVal dwFlags As Integer) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <Guid("00000102-0000-0000-C000-000000000046")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IEnumMoniker  
            Function [Next](ByVal celt As UInteger, ByRef rgelt As IMoniker, ByRef pceltFetched As UInteger) As HRESULT  
            Function Skip(ByVal celt As UInteger) As HRESULT  
            Function Reset() As HRESULT  
            Function Clone(ByRef ppenum As IEnumMoniker) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <Guid("0000000f-0000-0000-C000-000000000046")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IMoniker  
            Inherits IPersistStream  
      
    #Region "IPersist"  
            Shadows Function GetClassID(ByRef pClassID As Guid) As HRESULT  
    #End Region  
    #Region "IPersistStream"  
            Shadows Function IsDirty() As HRESULT  
            Shadows Function Load(ByVal pStm As System.Runtime.InteropServices.ComTypes.IStream) As HRESULT  
            Shadows Function Save(ByVal pStm As System.Runtime.InteropServices.ComTypes.IStream, ByVal fClearDirty As Boolean) As HRESULT  
            Shadows Function GetSizeMax(ByRef pcbSize As ULARGE_INTEGER) As HRESULT  
    #End Region  
      
            Function BindToObject(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByRef riidResult As Guid, ByRef ppvResult As IntPtr) As HRESULT  
            Function BindToStorage(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByRef riid As Guid, ByRef ppvObj As IntPtr) As HRESULT  
            Function Reduce(ByVal pbc As IntPtr, ByVal dwReduceHowFar As Integer, ByRef ppmkToLeft As IMoniker, ByRef ppmkReduced As IMoniker) As HRESULT  
            Function ComposeWith(ByVal pmkRight As IMoniker, ByVal fOnlyIfNotGeneric As Boolean, ByRef ppmkComposite As IMoniker) As HRESULT  
            Function [Enum](ByVal fForward As Boolean, ByRef ppenumMoniker As IEnumMoniker) As HRESULT  
            Function IsEqual(ByVal pmkOtherMoniker As IMoniker) As HRESULT  
            Function Hash(ByRef pdwHash As Integer) As HRESULT  
            Function IsRunning(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByVal pmkNewlyRunning As IMoniker) As HRESULT  
            Function GetTimeOfLastChange(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByRef pFileTime As System.Runtime.InteropServices.ComTypes.FILETIME) As HRESULT  
            Function Inverse(ByRef ppmk As IMoniker) As HRESULT  
            Function CommonPrefixWith(ByVal pmkOther As IMoniker, ByRef ppmkPrefix As IMoniker) As HRESULT  
            Function RelativePathTo(ByVal pmkOther As IMoniker, ByRef ppmkRelPath As IMoniker) As HRESULT  
            Function GetDisplayName(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByRef ppszDisplayName As String) As HRESULT  
            Function ParseDisplayName(ByVal pbc As IntPtr, ByVal pmkToLeft As IMoniker, ByVal pszDisplayName As String, ByRef pchEaten As UInteger, ByRef ppmkOut As IMoniker) As HRESULT  
            Function IsSystemMoniker(ByRef pdwMksys As Integer) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <Guid("00000109-0000-0000-C000-000000000046")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IPersistStream  
            Inherits IPersist  
    #Region "IPersist"  
            Shadows Function GetClassID(ByRef pClassID As Guid) As HRESULT  
    #End Region  
      
            Function IsDirty() As HRESULT  
            Function Load(ByVal pStm As System.Runtime.InteropServices.ComTypes.IStream) As HRESULT  
            Function Save(ByVal pStm As System.Runtime.InteropServices.ComTypes.IStream, ByVal fClearDirty As Boolean) As HRESULT  
            Function GetSizeMax(ByRef pcbSize As ULARGE_INTEGER) As HRESULT  
        End Interface  
      
        <StructLayout(LayoutKind.Explicit)>  
        Public Structure ULARGE_INTEGER  
            <FieldOffset(0)>  
            Public LowPart As Integer  
            <FieldOffset(4)>  
            Public HighPart As Integer  
            <FieldOffset(0)>  
            Public QuadPart As Long  
        End Structure  
      
        <ComImport()>  
        <Guid("55272A00-42CB-11CE-8135-00AA004BB851")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IPropertyBag  
            Function Read(ByVal pszPropName As String, ByRef pVar As PROPVARIANT, ByVal pErrorLog As IErrorLog) As HRESULT  
            Function Write(ByVal pszPropName As String, ByVal pVar As IntPtr) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <Guid("3127CA40-446E-11CE-8135-00AA004BB851")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IErrorLog  
            Function AddError(ByVal pszPropName As String, ByVal pExcepInfo As System.Runtime.InteropServices.ComTypes.EXCEPINFO) As HRESULT  
        End Interface  
      
        <StructLayout(LayoutKind.Sequential)>  
        Public Structure PROPARRAY  
            Public cElems As UInteger  
            Public pElems As IntPtr  
        End Structure  
      
        <StructLayout(LayoutKind.Explicit, Pack:=1)>  
        Public Structure PROPVARIANT  
            <FieldOffset(0)>  
            Public varType As System.UInt16  
            <FieldOffset(2)>  
            Public wReserved1 As System.UInt16  
            <FieldOffset(4)>  
            Public wReserved2 As System.UInt16  
            <FieldOffset(6)>  
            Public wReserved3 As System.UInt16  
            <FieldOffset(8)>  
            Public bVal As Byte  
            <FieldOffset(8)>  
            Public cVal As System.SByte  
            <FieldOffset(8)>  
            Public uiVal As System.UInt16  
            <FieldOffset(8)>  
            Public iVal As Short  
            <FieldOffset(8)>  
            Public uintVal As UInt32  
            <FieldOffset(8)>  
            Public intVal As Int32  
            <FieldOffset(8)>  
            Public ulVal As UInt64  
            <FieldOffset(8)>  
            Public lVal As Int64  
            <FieldOffset(8)>  
            Public fltVal As Single  
            <FieldOffset(8)>  
            Public dblVal As Double  
            <FieldOffset(8)>  
            Public boolVal As Short  
            <FieldOffset(8)>  
            Public pclsidVal As IntPtr  
            ' GUID ID pointer  
            <FieldOffset(8)>  
            Public pszVal As IntPtr  
            ' Ansi string pointer  
            <FieldOffset(8)>  
            Public pwszVal As IntPtr  
            ' Unicode string pointer  
            <FieldOffset(8)>  
            Public punkVal As IntPtr  
            ' punkVal (interface pointer)  
            <FieldOffset(8)>  
            Public ca As PROPARRAY  
            <FieldOffset(8)>  
            Public filetime As System.Runtime.InteropServices.ComTypes.FILETIME  
        End Structure  
      
        Public Enum VARENUM  
            VT_EMPTY = 0  
            VT_NULL = 1  
            VT_I2 = 2  
            VT_I4 = 3  
            VT_R4 = 4  
            VT_R8 = 5  
            VT_CY = 6  
            VT_DATE = 7  
            VT_BSTR = 8  
            VT_DISPATCH = 9  
            VT_ERROR = 10  
            VT_BOOL = 11  
            VT_VARIANT = 12  
            VT_UNKNOWN = 13  
            VT_DECIMAL = 14  
            VT_I1 = 16  
            VT_UI1 = 17  
            VT_UI2 = 18  
            VT_UI4 = 19  
            VT_I8 = 20  
            VT_UI8 = 21  
            VT_INT = 22  
            VT_UINT = 23  
            VT_VOID = 24  
            VT_HRESULT = 25  
            VT_PTR = 26  
            VT_SAFEARRAY = 27  
            VT_CARRAY = 28  
            VT_USERDEFINED = 29  
            VT_LPSTR = 30  
            VT_LPWSTR = 31  
            VT_RECORD = 36  
            VT_INT_PTR = 37  
            VT_UINT_PTR = 38  
            VT_FILETIME = 64  
            VT_BLOB = 65  
            VT_STREAM = 66  
            VT_STORAGE = 67  
            VT_STREAMED_OBJECT = 68  
            VT_STORED_OBJECT = 69  
            VT_BLOB_OBJECT = 70  
            VT_CF = 71  
            VT_CLSID = 72  
            VT_VERSIONED_STREAM = 73  
            VT_BSTR_BLOB = &HFFF  
            VT_VECTOR = &H1000  
            VT_ARRAY = &H2000  
            VT_BYREF = &H4000  
            VT_RESERVED = &H8000  
            VT_ILLEGAL = &HFFF  
            VT_ILLEGALMASKED = &HFFF  
            VT_TYPEMASK = &HFFF  
        End Enum  
      
        <ComImport()>  
        <Guid("5a804648-4f66-4867-9c43-4f5c822cf1b8")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IVMRFilterConfig9  
            Function SetImageCompositor(ByVal lpVMRImgCompositor As IVMRImageCompositor9) As HRESULT  
            Function SetNumberOfStreams(ByVal dwMaxStreams As UInteger) As HRESULT  
            Function GetNumberOfStreams(ByRef pdwMaxStreams As UInteger) As HRESULT  
            Function SetRenderingPrefs(ByVal dwRenderFlags As UInteger) As HRESULT  
            Function GetRenderingPrefs(ByRef pdwRenderFlags As UInteger) As HRESULT  
            Function SetRenderingMode(ByVal Mode As UInteger) As HRESULT  
            Function GetRenderingMode(ByRef pMode As UInteger) As HRESULT  
        End Interface  
      
        <ComImport()>  
        <Guid("4a5c89eb-df51-4654-ac2a-e48e02bbabf6")>  
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>  
        Public Interface IVMRImageCompositor9  
            Function InitCompositionDevice(ByVal pD3DDevice As IntPtr) As HRESULT  
            Function TermCompositionDevice(ByVal pD3DDevice As IntPtr) As HRESULT  
            Function SetStreamMediaType(ByVal dwStrmID As UInteger, ByVal pmt As AM_MEDIA_TYPE, ByVal fTexture As Boolean) As HRESULT  
            Function CompositeImage(ByVal pD3DDevice As IntPtr, ByVal pddsRenderTarget As IntPtr, ByVal pmtRenderTarget As AM_MEDIA_TYPE, ByVal rtStart As Long, ByVal rtEnd As Long, ByVal dwClrBkGnd As UInteger, ByRef pVideoStreamInfo As VMR9VideoStreamInfo, ByVal cStreams As UInteger) As HRESULT  
        End Interface  
      
        <StructLayout(LayoutKind.Sequential)>  
        Public Structure VMR9VideoStreamInfo  
            Public pddsVideoSurface As IntPtr  
            Public dwWidth As UInteger  
            Public dwHeight As UInteger  
            Public dwStrmID As UInteger  
            Public fAlpha As Single  
            Private rNormal As VMR9NormalizedRect  
            Private rtStart As Long  
            Private rtEnd As Long  
            Private SampleFormat As VMR9_SampleFormat  
        End Structure  
      
        <StructLayout(LayoutKind.Sequential)>  
        Public Structure VMR9NormalizedRect  
            Public left As Single  
            Public top As Single  
            Public right As Single  
            Public bottom As Single  
        End Structure  
      
        Public Enum VMR9_SampleFormat  
            VMR9_SampleReserved = 1  
            VMR9_SampleProgressiveFrame = 2  
            VMR9_SampleFieldInterleavedEvenFirst = 3  
            VMR9_SampleFieldInterleavedOddFirst = 4  
            VMR9_Sampl
    

1 additional answer

Sort by: Most helpful
  1. answered 2021-01-17T20:28:06.707+00:00
    Anonymous

    Hi Thanks for putting code into a readable format. Here is some code tht may help. You are a bit sparse on the information you provide so I just made some up. This code shows how to place and persist a graphic on an Image. Your image would be from the camera capture, I just use an Image File. ![57309-1.png][1] ' Form1 with PictureBox named ' picCapture Option Strict On Option Explicit On Imports System.Drawing.Drawing2D Public Class Form1 ' your image would be capture Private Im As New Bitmap("C:\Users\lesha\Documents\VB Resources\Images\Architecture XVIII.jpg") ' you don't say what you are ' drawing - here I just set ' up and draw a GraphicsPath Dim gp As New GraphicsPath Dim str As String = "Testing" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' something to draw on Image gp.AddString(str, Me.Font.FontFamily, FontStyle.Bold, 74, New Point(20, ClientRectangle.Top + 20), New StringFormat()) ' set up PictureBox With picCapture .Location = New Point(4, 4) .Size = New Size(ClientRectangle.Width - 8, ClientRectangle.Height - 8) .Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top .SizeMode = PictureBoxSizeMode.StretchImage .Image = Im End With End Sub Private Sub picCapture_Paint(sender As Object, e As PaintEventArgs) Handles picCapture.Paint ' to persist drawn text e.Graphics.DrawPath(New Pen(Color.Red, 4), gp) End Sub End Class [1]: /api/attachments/57309-1.png?platform=QnA