Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. CaptureFrame inside Thread

CaptureFrame inside Thread

Scheduled Pinned Locked Moved Graphics
helpcsharpcomgraphicsgame-dev
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anki123
    wrote on last edited by
    #1

    Hi I m using Directx.Capture library in C#. In capture.cs one function named as GrapImg() which is used to capture image from video. When I call the method GrapImg() from button click event it works fine. Now I need to call it within thread from the main form. But it gives an error Unable to cast COM object of type 'System.__ComObject' to interface type 'DShowNET.ISampleGrabber' public void GrapImg() { Trace.Write("IMG"); if (savedArray == null) { int size = videoInfoHeader.BmiHeader.ImageSize; if ((size < 1000) || (size > 16000000)) return; savedArray = new byte[size + 64000]; } sampGrabber.SetCallback(this, 1); } Error comes from the line sampGrabber.SetCallback(this, 1); Plz help me to solve this problem. Thanks in Advance

    U 1 Reply Last reply
    0
    • A anki123

      Hi I m using Directx.Capture library in C#. In capture.cs one function named as GrapImg() which is used to capture image from video. When I call the method GrapImg() from button click event it works fine. Now I need to call it within thread from the main form. But it gives an error Unable to cast COM object of type 'System.__ComObject' to interface type 'DShowNET.ISampleGrabber' public void GrapImg() { Trace.Write("IMG"); if (savedArray == null) { int size = videoInfoHeader.BmiHeader.ImageSize; if ((size < 1000) || (size > 16000000)) return; savedArray = new byte[size + 64000]; } sampGrabber.SetCallback(this, 1); } Error comes from the line sampGrabber.SetCallback(this, 1); Plz help me to solve this problem. Thanks in Advance

      U Offline
      U Offline
      User 3598653
      wrote on last edited by
      #2

      I just had the same issue. You have to call capture.GrapImg() in the same thread where the DirectX.Capture object was created. If you created it within the main form thread try using this.Invoke, that fixed it for me. Best, Carlos

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups