Videocapture in python

K

koranthala

I face issues in videocapture in python. Cant find anyplace where we
can raise bug reports, so mentioning here. Also help required if
somebody has solved it earlier.

On using videocapture (python 2.4), I am facing the following issues
while creating a video sort of application.
-> Pull out the usb cable : Videocapture gets the data stored
initially in the buffer and returns always. The images are not updated
- but also there is no error returned.
i.e. there is no information to the viewer that it is not working
anymore. Especially because since the timestamp is updated everytime
(it is done inside videocapture.py - wherein current time is
overwritten on the received image), it gives a feeling that video is
running.

Currently I have done a workaround in that every 2 captures, i setup
the camera again - but it takes too much time. Anyone has any
suggestions on solving this?
 
K

koranthala

Can you post your code or a code segment? I would be interested in seeing
how this works.

Since the code uses a lot of other variables - due to being a part of
a larger project, I will try to provide pseudocode.
At initialization:
def setup_cam():
global cam, i
cam = Device (devnum = 0)
i = 0

def take_photo(obj):
i += 1
if i >2:
setup_cam()
obj.img = cam.getImage(timestamp=3)

I actually would like to have the code as
try:
obj.img = cam.getImage(timestamp=3)
except CamException:
setup_cam()

But, since no exception is provided, I have to resort to the kludge
shown.
Please let me know if you need any more information.
 
M

Marc 'BlackJack' Rintsch

Please let me know if you need any more information.

Where does `videocapture.py` coming from? It's not part of the standard
library. And which operating system are we talking about?

Ciao,
Marc 'BlackJack' Rintsch
 
D

David

Marc said:
Where does `videocapture.py` coming from? It's not part of the standard
library. And which operating system are we talking about?

Ciao,
Marc 'BlackJack' Rintsch
Hope this is not off topic, I am new to python. I use linux and use the
subprocess module, feel free to point out my noviceness;
#!/usr/bin/python

import subprocess

def take_shot_func():
streamer = "/usr/bin/streamer"
s_arg1 = "-c"
s_device = "/dev/video0"
s_arg2 = "-b"
s_rate = "16"
s_arg3 = "-o"
save_to = "/tmp/camshot.jpeg"

print "Taking picture with webcam and saved to /tmp/camshot.jpeg"

subprocess.call([streamer, s_arg1, s_device, s_arg2,
s_rate, s_arg3, save_to])

def main():
take_shot_func()

if __name__ == "__main__":
main()
 
K

koranthala

Where does `videocapture.py` coming from?  It's not part of the standard
library.  And which operating system are we talking about?

Ciao,
        Marc 'BlackJack' Rintsch

Hi Marc,
It is not part of standard library. Sorry for me being very brief
earlier.
It is taken from http://videocapture.sourceforge.net/, - a very
good tool for webcam capture in Win32.
Hi David,
I am in Windows. And there is a possibility that I might be using
device 0 or 1. So, I am using the excellent VideoCapture tool created
by Markus Gritsch.
 
T

Terry Reedy

It is taken from http://videocapture.sourceforge.net/, - a very
good tool for webcam capture in Win32.
Hi David,
I am in Windows. And there is a possibility that I might be using
device 0 or 1. So, I am using the excellent VideoCapture tool created
by Markus Gritsch.

Does the capture software require 2.4?

Given
"
I actually would like to have the code as
try:
obj.img = cam.getImage(timestamp=3)
except CamException:
setup_cam()

But, since no exception is provided,
"

I do not think the tool is so excellent. It should either return a
picture or raise and exception. Request that of the author.
 
T

Tim Roberts

On using videocapture (python 2.4), I am facing the following issues
while creating a video sort of application.
-> Pull out the usb cable : Videocapture gets the data stored
initially in the buffer and returns always. The images are not updated
- but also there is no error returned.
i.e. there is no information to the viewer that it is not working
anymore. Especially because since the timestamp is updated everytime
(it is done inside videocapture.py - wherein current time is
overwritten on the received image), it gives a feeling that video is
running.

Currently I have done a workaround in that every 2 captures, i setup
the camera again - but it takes too much time. Anyone has any
suggestions on solving this?

The "right" way to fix this is to modify the C++ code that sets up the
DirectShow filter graph. The graph builder has the ability to deliver
events asynchronously, like when the device goes away, but it would not be
trivial to incorporate that into the module as written.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top