catching exceptions from camera thread

41 views
Skip to first unread message

cody dooderson

unread,
Apr 11, 2014, 8:10:30 PM4/11/14
to pydc...@googlegroups.com
I am running a program that captures images and checks for a laser pointer. 
It runs well most of the time. But occasionally I will get an error

libdc1394 error: Generic failure: in dc1394_format7_get_color_coding (format7.c, line 329): Could not get current color_id

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/camera.py", line 221, in run
    self._cam.mode.shape
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_mode.py", line 337, in shape
    self._calc_dtype_and_shape()
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_mode.py", line 69, in _calc_dtype_and_shape
    self._cam, self._mode_id, byref(cc))
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_dc1394core.py", line 669, in _errcheck
    % error_vals[rtype])
RuntimeError: Error in dc1394 function call: FAILURE

It would not be a big deal but I can't seem to trap the error. I think it gets fired from a thread, and its fairly hard to reproduce. So this might be a more basic question. How do I catch an error coming from the camera thread?

Holger Rapp

unread,
Apr 12, 2014, 6:00:09 AM4/12/14
to pydc...@googlegroups.com


On Saturday, April 12, 2014 2:10:30 AM UTC+2, cody dooderson wrote:
I am running a program that captures images and checks for a laser pointer. 
It runs well most of the time. But occasionally I will get an error

libdc1394 error: Generic failure: in dc1394_format7_get_color_coding (format7.c, line 329): Could not get current color_id

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/camera.py", line 221, in run
    self._cam.mode.shape
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_mode.py", line 337, in shape
    self._calc_dtype_and_shape()
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_mode.py", line 69, in _calc_dtype_and_shape
    self._cam, self._mode_id, byref(cc))
  File "/usr/local/lib/python2.7/dist-packages/pydc1394/_dc1394core.py", line 669, in _errcheck
    % error_vals[rtype])
RuntimeError: Error in dc1394 function call: FAILURE


Try catching it in the line where it is thrown?   File "/usr/local/lib/python2.7/dist-packages/pydc1394/_dc1394core.py", line 669, in _errchec

The library is not in use or in development any longer by me - you need to bandaid fix this yourself.

cody dooderson

unread,
Apr 14, 2014, 3:44:11 PM4/14/14
to pydc...@googlegroups.com
That is too bad that you are not involved anymore.
Is there a newer alternative?

I think that there was a race condition in the actual c code. 
We did a really hacky fix. It works for now, until we figure out the correct way to catch this exception. In camera.py we changed line 220 to about 228 to 
            #generate an Image class from the buffer:
            while True:
                try:
                    img = fromstring(buf, dtype=self._cam.mode.dtype).reshape(
                        self._cam.mode.shape
                    ).view(Image)
                    break 
                except:
                    time.sleep(0.1)   

Holger Rapp

unread,
Apr 15, 2014, 1:40:44 AM4/15/14
to pydc...@googlegroups.com


On Monday, April 14, 2014 9:44:11 PM UTC+2, cody dooderson wrote:
That is too bad that you are not involved anymore.
Is there a newer alternative?

I am not aware of any alternatives. I doubt that there are any as firewire cameras seem to be on the decline. 

Tamas H.

unread,
May 2, 2014, 5:21:18 AM5/2/14
to pydc...@googlegroups.com
The newest cameras often use networking to do their jobs, making communication simpler for the clients. However, there are still quite a couple of scientific cameras using the firewire. And there are plenty USB 2 or 3 cameras around as well.

Cody: I do not think you need the 'break' in the try: construct.


--
You received this message because you are subscribed to the Google Groups "pydc1394" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydc1394+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages