I'm thinking about an alternative solution to the question I posted about using Direct Show to modify/display frames from a video stream in real-time.
Instead of trying to access the video stream, I wonder if I can put code in WM_Paint to draw on top of the video output?
The code below tries to simply draw rectangles over a a dialog, where Direct Show is being used to display camera output. But in the code below, the video output draws over the GDI output. In this case, I want the GDI drawn on top of the video images.
In the final solution, I want to copy the video frame that is shown on the window, modify the copy, and then place the modified copy on top of the video.

Instead of trying to access the video stream, I wonder if I can put code in WM_Paint to draw on top of the video output?
The code below tries to simply draw rectangles over a a dialog, where Direct Show is being used to display camera output. But in the code below, the video output draws over the GDI output. In this case, I want the GDI drawn on top of the video images.
In the final solution, I want to copy the video frame that is shown on the window, modify the copy, and then place the modified copy on top of the video.
Code:
'Compilable Example: #Compile Exe #Dim All #Debug Error On #Debug Display On %Unicode = 1 #Include "Win32API.inc" #Include Once "dshow.inc" #Include "qedit.inc" Global hDlg, hDC, wRes, hRes As Dword Global pBuffer As String Ptr, pBufferSize As Long Global pGraph As IGraphBuilder 'Filter Graph Manager Global pBuild As ICaptureGraphBuilder2 'Capture Graph Builder Global pSysDevEnum As ICreateDevEnum 'enumeration object Global pEnumCat As IEnumMoniker Global pMoniker As IMoniker 'contains information about other objects Global pceltFetched As Dword Global pCap As IBaseFilter 'Video capture filter Global pControl As IMediaControl Global pWindow As IVideoWindow 'Display Window Function PBMain() As Long Dialog Default Font "Tahoma", 12, 1 Dialog New Pixels, 0, "DirectShow SampleGrabber Test",300,300,640+150,480, %WS_OverlappedWindow Or %WS_ClipSiblings Or %WS_ClipChildren To hDlg Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Local w,h As Long, PS As PaintStruct Select Case Cb.Msg Case %WM_InitDialog pGraph = NewCom ClsId $CLSID_FilterGraph 'filter graph pBuild = NewCom ClsId $CLSID_CaptureGraphBuilder2 'capture graph builder pSysDevEnum = NewCom ClsId $CLSID_SystemDeviceEnum 'enumeration object DisplayFirstCamera Case %WM_Command Select Case Cb.Ctl End Select Case %WM_Paint 'draw on dialog hDC = BeginPaint(hDlg, PS) Rectangle hDC, 20,20,200,200 Rectangle hDC, 60,60,100,100 EndPaint hDlg, PS Case %WM_Destroy pGraph = Nothing pBuild = Nothing pSysDevEnum = Nothing Case %WM_Size Dialog Get Client hDlg To w,h pWindow.SetWindowPosition(150,0,w-150,h) End Select End Function Sub DisplayFirstCamera If pSysDevEnum.CreateClassEnumerator($CLSID_VideoInputDeviceCategory, pEnumCat, 0) <> %S_Ok Then Exit Sub pEnumCat.next(1, pMoniker, pceltFetched) 'cycle through monikders pMoniker.BindToObject(Nothing, Nothing, $IID_IBaseFilter, pCap) 'create device filter for the chosen device pGraph.AddFilter(pCap,"First Camera") 'add chosen device filter to the filter graph pBuild.SetFilterGraph(pGraph) 'initialize pBuild pBuild.RenderStream $Pin_Category_Preview, $MediaType_Video, pCap, Nothing, Nothing 'render the live source pWindow = pGraph pWindow.Owner = hDlg pWindow.WindowStyle = %WS_Child Or %WS_ClipChildren Or %WS_ClipSiblings 'video window settings pControl = pGraph pControl.Run End Sub
Comment