472,954 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

wxPython Video Capture using ActiveX (OCX) Control

bartonc
6,596 Expert 4TB
I just got video capture working in my wxPython project, if any one is interested.
Another really cool thing that I got working tonight is Boa Constructor _Custom_Classes, which allow my video window to be displayed in the Designer window. Very handy!
Aug 17 '07 #1
6 6518
I'm extremely interested, just setting out to do this same sort of thing, any little bit would help.

Thanks if possible, hopefully you'll see this....
Dec 4 '07 #2
bartonc
6,596 Expert 4TB
I'm extremely interested, just setting out to do this same sort of thing, any little bit would help.

Thanks if possible, hopefully you'll see this....
OK. How familiar with wxPython are you?

I ended up purchasing an ActiveX control from Russia for $60 US but I'm not really allowed to link to commercial sites here. You'll find many such goodies by Googling "ActiveX video capture". The one I chose is called ELVideoCapture. My favorite one was from Germany, but didn't seem to have much support, hadn't been updated in a while and was much more expensive. I'd stay way from XVideoOCX. The product is OK, but the support team only knows VB.
Dec 4 '07 #3
I'm very familiar with wxPython, but not very familiar with ActiveX. I don't imagine you have a moment to write a primer on that?

I've been experimenting with capturing video using the videocapture module (http://videocapture.sourceforge.net/), which works well enough, and returns a PIL instance, which is great. But so far I'm writing each JPG to the harddrive as its capture, which is of course slow. On my computer I'm getting about 13fps maximum.

I'm then stitching together with mencoder.

Issues:

- how to display the images as they're captured? That's something I need to do, which is where wx will come in.

- how to increase the FPS?

- how to do sound capture?
Dec 5 '07 #4
bartonc
6,596 Expert 4TB
I'm very familiar with wxPython, but not very familiar with ActiveX. I don't imagine you have a moment to write a primer on that?

I've been experimenting with capturing video using the videocapture module (http://videocapture.sourceforge.net/), which works well enough, and returns a PIL instance, which is great. But so far I'm writing each JPG to the harddrive as its capture, which is of course slow. On my computer I'm getting about 13fps maximum.

I'm then stitching together with mencoder.

Issues:

- how to display the images as they're captured? That's something I need to do, which is where wx will come in.

- how to increase the FPS?

- how to do sound capture?
One answer: ActiveX will take care of all the performance, sound?, etc. issues.
The wx.lib has all that you will need. Here is one of my early tests. the vb thing was a trial download:
Expand|Select|Wrap|Line Numbers
  1. #Boa:Frame:Frame1
  2.  
  3. import wx
  4. import wx.activex as ActiveX
  5.  
  6.  
  7. ## From OLE Object Viewer ##
  8. guidStr = "{DF6D6569-5B0C-11D3-9396-008029E9B3A6}"
  9.  
  10. ## make wx compatible ##
  11. CLSID_vbVidC60 = ActiveX.CLSID(guidStr)
  12. name = "vbVidC60"
  13.  
  14. ### post gen #
  15. ##from vbVidC60 import vbVidC60
  16.  
  17. def create(parent):
  18.     return Frame1(parent)
  19.  
  20. [wxID_FRAME1, wxID_FRAME1WINDOW1, 
  21. ] = [wx.NewId() for _init_ctrls in range(2)]
  22.  
  23. class Frame1(wx.Frame):
  24. ##    _custom_classes = {'wx.Window': ['vbVidC60']}
  25. ##    def _init_sizers(self):
  26. ##        # generated method, don't edit
  27. ##        self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
  28. ##
  29. ##        self._init_coll_boxSizer1_Items(self.boxSizer1)
  30. ##
  31. ##        self.SetSizer(self.boxSizer1)
  32. ##
  33. ##
  34. ##    def _init_coll_boxSizer1_Items(self, parent):
  35. ##        # generated method, don't edit
  36. ##
  37. ##        parent.AddWindow(self.window1, 1, border=0, flag=wx.EXPAND)
  38. ##
  39. ##    def _init_ctrls(self, prnt):
  40. ##        # generated method, don't edit
  41. ##        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(198, 198),
  42. ##                size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
  43. ##        self.SetClientSize(wx.Size(392, 223))
  44. ##
  45. ##        self.window1 = vbVidC60(ID=wxID_FRAME1WINDOW1, name='window1', parent=self, pos=wx.Point(0,
  46. ##                0), size=wx.Size(392, 223), style=0)
  47. ##
  48. ##        self._init_sizers()
  49.  
  50.     def __init__(self, parent):
  51. ##        self._init_ctrls(parent)
  52. ##        self.window1.autosize = False
  53. ##        print self.window1.NumCapDevs()
  54. ##        print self.window1.driverindex
  55.  
  56.  
  57. ##        try:
  58.         vidwin = ActiveX.ActiveXWindow(self, CLSID_vbVidC60, -1, wx.DefaultPosition,
  59.                                        wx.DefaultSize, 0, name)
  60.  
  61.         print "Generating %s from CLSID %s" %(name, guidStr)
  62.         print "!!!!!!"
  63.         dummy = ActiveX.GernerateAXModule(vidwin, name, ".", None, True)
  64.         print "!!!!!!"
  65. # I don't remember why the next line was here:
  66. ##        vidwin.Destroy()
  67.         print "!!!!!!"
  68. ##        except Exception, e:
  69. ##            print "Couldn't create %s with %s" %(name, guidStr)
  70. ##            print e
  71.  
  72.  
  73. if __name__ == "__main__":
  74.     app = wx.PySimpleApp()
  75.     frame = create(None)
  76.     frame.Show()
  77.     app.MainLoop()
  78.  
Dec 7 '07 #5
I'm trying to get this to work, and having problems. It fails when defining vidwin (the ActiveXWindow). Here's my code, adapted from yours, trying to use it with the EL VideoCapture DLL.

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import wx.activex as ActiveX
  3.  
  4. class Frame1(wx.Frame):
  5.     def __init__(self, parent):
  6.  
  7.         wx.Frame.__init__(self, None , wx.ID_ANY, "Test")
  8.  
  9.         ## make wx compatible ##
  10.         #guidStr = "{DF6D6569-5B0C-11D3-9396-008029E9B3A6}" # string for EZVidCap5
  11.         guidStr = "{16761F2C-934F-4851-8897-DC01F46253C8}" # string for ELVideoCapture?
  12.         CLSID_ELVidCap = ActiveX.CLSID(guidStr)
  13.         name = "vbVidC60"
  14.  
  15.         vidwin = ActiveX.ActiveXWindow(self, CLSID_ELVidCap, -1, wx.DefaultPosition, wx.DefaultSize, 0, name)
  16.  
  17.         print "Generating %s from CLSID %s" %(name, guidStr)
  18.         print "!!!!!!"
  19.         dummy = ActiveX.GernerateAXModule(vidwin, name, ".", None, True)
  20.         print "!!!!!!"
  21.  
  22.         self.Show()
  23.  
  24. app = wx.App(redirect=0)
  25. Frame1(None)
  26. app.MainLoop()
  27.  
It fails like this:

Expand|Select|Wrap|Line Numbers
  1. C:\Python24>activecapture.py
  2. Traceback (most recent call last):
  3.   File "C:\Python24\activecapture.py", line 29, in ?
  4.     Frame1(None)
  5.   File "C:\Python24\activecapture.py", line 17, in __init__
  6.     vidwin = ActiveX.ActiveXWindow(self, CLSID_ELVidCap, -1, wx.DefaultPosition, wx.DefaultSize, 0,
  7. name)
  8.   File "C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wx\activex.py", line 226, in __init__
  9.     _activex.ActiveXWindow_swiginit(self,_activex.new_ActiveXWindow(*args, **kwargs))
  10. wx._core.PyAssertionError: C++ assertion "m_ActiveX.Ok()" failed at contrib\activex\wxie/wxactivex.c
  11. pp(323) in wxActiveX::CreateActiveX(): m_ActiveX.CreateInstance failed
  12.  
I'm not at all sure if I'm doing anything correctly with EL VideoCapture. After installing it, I registered the DLL (I think) like this, which appeared to be successfull:

Regsvr32 ELVideoCapture.dll

When I run tools --> Com MakePy Utility from PythonWin, the ELVideoCapture.dll does show up. I then open the file in gen_py (called 16761F2C-934F-4851-8897-DC01F46253C8x0x1x0.py) and get the CLSID. I can see all the methods in that file. But alas, I can't initialize it.

Did you use genaxmodule.py?

I don't imagine it'd be possible to post the code that you got working with EL VideoCapture? Or point out some error in my code?

Extremely grateful for any help.
Jan 28 '08 #6
I've made some good progress.

I used genaxmodule.py to wrap the EL Videocapture drivers. It produced a module that I uploaded here . Note that I also zipped the output from the Com MakePy Utility, it's the file with the long filename. It has some useful comments.

Anyway, I'm now having an odd problem. I seem to be successfully initializing the DLL, at least the ActiveXWindow is initializing successfully. However WX crashes hard whenever I start capture.

I've been emailing with ELVidcapture tech support, and they gave me different CLSIDs than I'm using. Theirs don't allow me to initialize the window though. So I'm wondering what CLSID you're using?

When I use the following code without registering, it shows the EL Videocapture logo, saying "unregistered". However when I close the window, it crashes. When I register (registration line omitted here since it's my licensing info), it simply crashes. So I don't think I'm initializing things correctly.

Any help would be phenomenal, I'm near wit's end on this.


Expand|Select|Wrap|Line Numbers
  1. import os
  2. import wx
  3. import wx.activex
  4.  
  5. class Frame1(wx.Frame):
  6.     def __init__(self, parent):
  7.  
  8.         wx.Frame.__init__(self, None , wx.ID_ANY, "Test")
  9.  
  10.         self.panel = wx.Panel(self)
  11.  
  12.         wx.EVT_CLOSE(self, self.OnClose)
  13.  
  14.         # CLSID from Com Object Viewer
  15.         clstr = "{84985BC1-BCB3-45E6-9ECF-DC006ACCC1CF}" # the one I got semi working
  16.         #clstr = "{16761F2C-934F-4851-8897-DC01F46253C8}" # they said to use this one or two below, neither work for me
  17.         #clstr = "{BDB13542-5849-4493-8B3E-1371C30E374F}"
  18.         #clstr = "{81FF70E3-AFDD-4618-98AE-A0FF67BBF95C}"
  19.  
  20.         ctrl = wx.activex.ActiveXWindow(self,
  21.                        clsId=wx.activex.CLSID(clstr),
  22.                        id=-1,
  23.                        name="somename"
  24.                        )
  25.  
  26.         import elvidcap
  27.         a = elvidcap.elvidcap(ctrl)
  28.  
  29.         print a.Register("[my name deleted]", "[my license deleted]")
  30.         a.StartPreview() # crash!
  31.  
  32.         # this works:
  33.         for i in range(a.capturedrivercount):
  34.             print a.GetCaptureDriverNameByIndex(i)
  35.  
  36.         self.Show()
  37.  
  38.     # Stuff to do when we exit:    
  39.     def OnClose(self, event):
  40.         print "deleting"
  41.         #a.StopPreview()
  42.         #del a
  43.         print "exiting"
  44.         os._exit(1)
  45.  
  46.  
  47.  
  48. app = wx.App(redirect=0)
  49. Frame1(None)
  50. app.MainLoop()
  51.  
Jan 28 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
0
by: Ike | last post by:
I have an Activex Control created in VB6, which, displays no problem on any machine I have, but, on some machines of others, it does not. All machines are running either XP or Windows 2000, and all...
17
by: MLH | last post by:
After running the following code snippet... MyURL = "http://tycho.usno.navy.mil/what.html" msXML.Open "GET", MyURL, False msXML.send I would like to execute code to perform essentially what...
1
by: Steve | last post by:
I am having an issue deploying an ActiveX control. This is a .NET project in C#. The ActiveX control is written in VB6. I use the PDW (Package and Deployment Wizard) to create a .CAB for the...
4
by: ABC | last post by:
I. I have a video capture project, like AmCap, written in VB.NET. It is a windows applications. Is it possible to put it into a web page? II. Is the conversion in I complicated? Involve ActiveX...
8
by: las | last post by:
(Originally posted to framework.aspnet.webservices, but I am casting a larger net and trying again) I am using a library supplied by a third-party vendor. Although the library has no UI, the...
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
3
by: rajibnsu | last post by:
While searching for capturing video with a webcam I god the following code.It gives two errors.Says:The type or namespace name 'WebcamEventArgs' does not exit in the namespace 'WebCam_Capture' (are...
3
by: ghostrider | last post by:
Does anyone know how to recognise the image capture signal from a medical scope such as a video colonoscope? I've got video streaming from the scope to the computer but want my app to recognise...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.