<div dir="ltr"><div><div><div>Hi!<br><br></div>I'm trying to use DirectShowLib for some basic media detection with the `IMediaDet` interface. However, trying to use methods of the interface from the instance throws `AttributeError` every time.<br><br></div>This is the script I'm using to test:<br><br>---<br>    import clr<br><br>    clr.AddReference('DirectShowLib')<br><br>    from DirectShowLib.DES import IMediaDet, DESError<br><br><br>    class Detector(IMediaDet):<br>        def __init__(self, *args, **kwargs):<br>            super(Detector, self).__init__(*args, **kwargs)<br><br><br>    mdet = Detector()<br><br>    print('Detector: {}\n'.format(mdet))<br>    print('Detector dir: {}\n'.format(dir(mdet)))<br>    print('Detector.put_Filename: {}\n'.format(mdet.put_Filename))<br>    print('Detector.put_Filename dir: {}\n'.format(dir(mdet.put_Filename)))<br>    print('Detector.put_Filename.Overloads: {}\n'.format(<br>        mdet.put_Filename.Overloads<br>    ))<br>    print('Detector.put_Filename.Overloads dir: {}\n'.format(<br>        dir(mdet.put_Filename.Overloads)<br>    ))<br>    print('Detector object is instance of IMediaDet: {}\n'.format(<br>        isinstance(mdet, IMediaDet)<br>    ))<br>    mdet.put_Filename('VID_20150207_133726.mp4')<br>---<br><br></div>And it prints the following information, finally throwing an error when I try to use the method:<br><br>---<br>$ ipy -X:Debug -X:ShowClrExceptions -X:ExceptionDetail testdshow.py<br>Detector: <Detector object at 0x000000000000002B><br><br>Detector dir: ['EnterBitmapGrabMode', 'Equals', 'GetBitmapBits', 'GetHashCode', 'GetSampleGrabber', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', 'WriteBitmapBits', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'get_CurrentStream', 'get_Filename', 'get_Filter', 'get_FrameRate', 'get_OutputStreams', 'get_StreamLength', 'get_StreamMediaType', 'get_StreamType', 'get_StreamTypeB', 'put_CurrentStream', 'put_Filename', 'put_Filter']<br><br>Detector.put_Filename: <built-in method put_Filename of Detector object at 0x000000000000002B><br><br>Detector.put_Filename dir: ['DeclaringType', 'Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'Overloads', 'ReferenceEquals', 'Targets', 'ToString', '__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']<br><br>Detector.put_Filename.Overloads: {'put_Filename(self: Object#IMediaDet_4$4, newVal: str) -> int\r\n': <built-in method put_Filename of Detector object at 0x000000000000002B>}<br><br>Detector.put_Filename.Overloads dir: ['Equals', 'Function', 'Functions', 'GetHashCode', 'GetOverload', 'GetTargetFunction', 'GetType', 'Item', 'MemberwiseClone', 'ReferenceEquals', 'Targets', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']<br><br>Detector object is instance of IMediaDet: True<br><br>'Detector' object has no attribute 'put_Filename'<br>   at IronPython.Runtime.Operations.PythonOps.MissingInvokeMethodException(Object o, String name)<br>   at IronPython.NewTypes.System.Object#IMediaDet_4$4.put_Filename(String newVal)<br>   at Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)<br>   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)<br>   at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)<br>   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)<br>   at __main__$15.__main__(FunctionCode $functionCode) in testdshow.py:line 22<br>   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)<br>   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)<br>   at IronPython.Hosting.PythonCommandLine.RunFileWorker(String fileName)<br>   at IronPython.Hosting.PythonCommandLine.RunFile(String fileName)<br>AttributeError: 'Detector' object has no attribute 'put_Filename'<br>CLR Exception:<br>    MissingMemberException<br>:<br>'Detector' object has no attribute 'put_Filename'<br clear="all"><div><div><div><div>---<br><br></div><div>I suspect it could be something related with overloading.<br><br></div><div>Any hints on why it's not working?<br><br></div><div>Best Regards,<br></div><div><br>-- <br><div class="gmail_signature">Sebastián Ramírez Magrí</div>
</div></div></div></div></div>