Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49731 > unrolled thread
| Started by | ifelsetrue@gmail.com |
|---|---|
| First post | 2013-07-03 06:25 -0700 |
| Last post | 2013-07-03 14:38 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
python.exe crash if opencv tries to access busy webcam ifelsetrue@gmail.com - 2013-07-03 06:25 -0700
Re: python.exe crash if opencv tries to access busy webcam Tim Golden <mail@timgolden.me.uk> - 2013-07-03 14:38 +0100
| From | ifelsetrue@gmail.com |
|---|---|
| Date | 2013-07-03 06:25 -0700 |
| Subject | python.exe crash if opencv tries to access busy webcam |
| Message-ID | <aa2fde6a-ded2-4817-ad57-77efe3149361@googlegroups.com> |
Hello,
I have a while loop taking images every 5 minutes from webcam. Unfortunately, if the camera is busy, python.exe crashes and there is no exception to catch. Is there a way to check if camera is busy to avoid the crash?
Thanks!
from cv2 import *
while True:
time.sleep(4)
cam = VideoCapture(0)
s, img = cam.read()
if s: # frame captured without any errors
namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
imshow("cam-test",img)
waitKey(0)
destroyWindow("cam-test")
imwrite("filename.jpg",img) #save image
[toc] | [next] | [standalone]
| From | Tim Golden <mail@timgolden.me.uk> |
|---|---|
| Date | 2013-07-03 14:38 +0100 |
| Message-ID | <mailman.4165.1372858730.3114.python-list@python.org> |
| In reply to | #49731 |
On 03/07/2013 14:25, ifelsetrue@gmail.com wrote: > Hello, > > > I have a while loop taking images every 5 minutes from webcam. > Unfortunately, if the camera is busy, python.exe crashes and there is > no exception to catch. Is there a way to check if camera is busy to > avoid the crash? If python.exe crashes -- ie exits completely without a traceback, then it's most likely a flaw in the extension module which is capturing the image. If that's the case, there's nothing you can do in Python code to prevent it; you need to work with the project maintainers to fix that. If you're getting a traceback but the console window is then closing too fast for you to see it, then try running the code from an open console window rather than double-clicking on it. (You don't say how you're kicking the code off so I'm offering this just in case) TJG
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web