Re: [python-win32] Using DirectShow API to access webcam

2018-08-17 Thread Tim Roberts

Joe wrote:


thanks for your helpful answer and the explanations.
Following up on your comment on http://videocapture.sourceforge.net/
I found that there is jaraco.video, which seems to be
"a port of the VideoCapture module in pure Python using ctypes and 
comtypes."

(https://github.com/jaraco/jaraco.video)

It is using a 'DirectShow.tlb' file, whatever that is, to get the
definitions into comtypes.


A TLB file is a "type library".  It is a compiled version of the IDL for 
a set of COM interfaces.  IDL is modified subset of C++ that is used to 
declare the functions within a COM interface, their parameters, and 
their types.  It is intended to be  a language-independent way to define 
the functions within an interface.


Looks like you're on your way.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using DirectShow API to access webcam

2018-08-17 Thread Joe

Hello Tim,

thanks for your helpful answer and the explanations.
Following up on your comment on http://videocapture.sourceforge.net/
I found that there is jaraco.video, which seems to be
"a port of the VideoCapture module in pure Python using ctypes and 
comtypes."

(https://github.com/jaraco/jaraco.video)

It is using a 'DirectShow.tlb' file, whatever that is, to get the
definitions into comtypes.

https://github.com/jaraco/jaraco.video/blob/master/jaraco/video/api/__init__.py#L35

https://github.com/jaraco/jaraco.video/blob/master/jaraco/video/api/objects.py#L9

If your interested, I will post my progress on SO.

Kind regards,
Joe





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/

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Using DirectShow API to access webcam

2018-08-16 Thread Tim Roberts

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


[python-win32] Using DirectShow API to access webcam

2018-08-16 Thread Joe

Hello,

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?

Kind regards,
Joe


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32