Joe wrote:
I have a question an hope you can help me. I am trying to control a
UVC webcam
using the DirectShow API, but could not get anything to work.
The question is already posted on StackOverflow:
https://stackoverflow.com/questions/51843523/accessing-webcam-via-directshow-using-com-with-python
I am not familiar with using CLSID, IID so playing with the few
examples I found
got my nowhere:
# IID_IAMVideoProcAmp is C6E13360-30AC-11d0-A18C-00A0C9118956
from win32com.client import Dispatch
from win32com.client.gencache import EnsureDispatch,GetClassForProgID,
GetClassForCLSID, GetModuleForProgID, GetModuleForCLSID
iid = '{c6e13360-30ac-11d0-a18c-00a0c9118956}'
print(GetClassForCLSID(iid))
print(GetModuleForProgID(iid))
print(GetModuleForCLSID(iid))
CLSID = IID('{c6e13360-30ac-11d0-a18c-00a0c9118956}')
print(CLSID)
print(Dispatch(CLSID))
pywintypes.com_error: (-2147220990, 'CONNECT_E_CANNOTCONNECT',
None, None)
Could someone of you point me in the right direction and maybe put
together a few lines to get me started?
I am not entirely convinced it is possible to control DirectShow from
Python, but I'll give you some general information.
An "interface" in COM terms, described by an IID, is just a set of
functions declarations. It defines the things you can do with an
object, but it is not actually an object. A "CLSID", on the other hand,
defines a COM object. The CLSID doesn't tell you what the object can
do, it's just a way of creating an object. Once you have used a CLSID
to create an object, you can ask it for an interface.
So, you can't just create IID_IAMVideoProcAmp. You have to ask an
existing object for its IAMVideoProcAmp interface. You would create
your camera object, and then query the camera object for IAMVideoProcAmp.
Creating a DirectShow graph is a multi-step process. You create a
filter graph, you add your camera to the graph, you tell the graph to
render the stream (which means it automatically fills in the other
filters), and you control it. Here is some sample code that does this:
https://gist.github.com/dust8/3890196
This is actually more complicated than it needs to be, because it's
trying to handle TV devices with tuner and audio filters as well. You
don't need that. Once you have a device from VideoInputDeviceCategory,
you don't need the video decoder or the audio. You can just render the
graph at that point.
Alternatively, it looks like this package might be more applicable:
http://videocapture.sourceforge.net/
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32