CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2008
    Posts
    111

    Question Directshow flip cam image FlipHorizontal

    Hey all i am trying to figure out how to use this code in order to flip the image Horizontal Currently it is reading words i have on cam backwards. The code is using the DirectShow.net DLL from here: http://directshownet.sourceforge.net/ and also using the deveck dotNetWebcamLibrary here https://github.com/deveck/dotNetWebcamLibrary
    Code:
        For Each device__1 As Device In Device.FindDevices()
             If device__1.ToString() = "BackupCamera" Then
                 Dim selectedDevice As Device = TryCast(device__1, Device)
                 Dim graphBuilder As IGraphBuilder = TryCast(New FilterGraph(), IGraphBuilder)
                 Dim device1 As DsDevice = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)(1)
                 Dim baseFilterIdentifier As Guid = GetType(IBaseFilter).GUID
                 Dim videoSourceObject As Object = Nothing
    
                 device1.Mon.BindToObject(Nothing, Nothing, baseFilterIdentifier, videoSourceObject)
                 Dim videoSourceBaseFilter As IBaseFilter = TryCast(videoSourceObject, IBaseFilter)
    
                 graphBuilder.AddFilter(videoSourceBaseFilter, "Source")
                 Dim captureGraphBuilder As ICaptureGraphBuilder2 = TryCast(New CaptureGraphBuilder2(), ICaptureGraphBuilder2)
    
                 captureGraphBuilder.SetFiltergraph(graphBuilder)
                 Dim crossbarObject As Object = Nothing
    
                 captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, Nothing, videoSourceBaseFilter, GetType(IAMCrossbar).GUID, crossbarObject)
    
                 Dim crossbar As IAMCrossbar = TryCast(crossbarObject, IAMCrossbar)
                 Dim inputPinCount As Integer, outputPinCount As Integer
    
                 crossbar.get_PinCounts(inputPinCount, outputPinCount)
                 crossbar.Route(0, 1)
    
                 Dim theFlipping As Object = Nothing
    
                 captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, Nothing, videoSourceBaseFilter, GetType(VideoControlFlags).GUID, theFlipping)
    
                 Dim flipHor As VideoControlFlags = DirectCast(theFlipping, VideoControlFlags)
    
                 imageCapture.Device = TryCast(selectedDevice, Device)
                 imageCapture.PerformAutoScale()
                 imageCapture.Refresh()
                 imageCapture.Start()
             End If
        Next
    Notice the Dim flipHor As VideoControlFlags = DirectCast(theFlipping, VideoControlFlags) ..... yeah that's all i can come up with.... Doesn't do anything but close my program without an error.

    Any help would be great!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Directshow flip cam image FlipHorizontal

    Check the return value of each CAST. This looks like the one...
    Code:
    Debug.Print theFlipping
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured