genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
501 stars 86 forks source link

Unexplainable error #401

Open eli-osherovich opened 1 year ago

eli-osherovich commented 1 year ago

Describe the Issue I am observing a strange error on my Specim FX17 camera. When trying to set OffsetX, the SW raises an exception saying that the maximal value is 0 (no offset). This is strange because we have already used a non-zero offset on this very camera just a day ago. Nothing has changed since then. In fact, when we tried first to set this offset, we got this error, but somehow it disappeared. And now appeared again....

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/neolithics/nx/code/streaming/video_streaming/video_input_stream.py", line 222, in _readloop_wrapper
    self._readloop(self)  # Could avoid using self using Python descriptors
  File "/home/neolithics/nx/code/streaming/video_streaming/linescan_input_stream.py", line 108, in _readloop
    set_genicam_values(self._initial_genicam_settings, ia.remote_device.node_map, self._stream_id,
  File "/home/neolithics/nx/code/streaming/video_streaming/common.py", line 33, in set_genicam_values
    node.set_value(v)
  File "/home/neolithics/nx/venv38/lib/python3.8/site-packages/genicam/genapi.py", line 2354, in set_value
    self._primal_set_value(value, verify)
  File "/home/neolithics/nx/venv38/lib/python3.8/site-packages/genicam/genapi.py", line 2270, in _primal_set_value
    return _genapi.IInteger__primal_set_value(self, Value, Verify)
_genapi.OutOfRangeException: Value = 192 must be equal or smaller than Max = 0. : OutOfRangeException thrown in node 'OffsetX' while calling 'OffsetX.SetValue()' (file 'IntegerT.h', line 79)
jcormier commented 1 year ago

I know for our cameras you usually have to reduce the width before you can change offsetX since we set up the validators in the XML that way. Maybe its the same for the Specim camera?

eli-osherovich commented 1 year ago

Width is already reduced. The max value of 0 does not make any sense. Especially, given the fact that the same config worked a day before.

eli-osherovich commented 1 year ago

In fact, we have a similar situation with FPS -- often an assertion error appears saying that the max value is, say, 164 when we try to set it to something like 350. However, after several re-tries to restart the program, it works.

eli-osherovich commented 1 year ago

I can actually find an reasonable explanation for this -- some of the previous settings did not work. E.g., the width was not really set to our target value, hence, the offsetX cannot be changed. Same for FPS -- the exposure time might have not been updated, hence the exposure limit was not re-adjusted. But those failures happen silently.

jcormier commented 1 year ago

You should report this to Specim. This sounds more like a camera or XML bug than a problem in harvesters.

eli-osherovich commented 1 year ago

@jcormier thanks. What XML do you refer to? If there is a file that I can "fix" -- I will try to do that.

P.S. I will definitely try to write to Specim.

jcormier commented 1 year ago

The camera sends the XML file to the gentle consumer, which tells it about all the parameters and their min/max values, etc. Your out-of-range exceptions are coming from rules set by this XML. This is usually not changeable by the user but would require code changes on the camera side.

Gornoka commented 11 months ago

Describe the Issue I am observing a strange error on my Specim FX17 camera. When trying to set OffsetX, the SW raises an exception saying that the maximal value is 0 (no offset). This is strange because we have already used a non-zero offset on this very camera just a day ago. Nothing has changed since then. In fact, when we tried first to set this offset, we got this error, but somehow it disappeared. And now appeared again....

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/neolithics/nx/code/streaming/video_streaming/video_input_stream.py", line 222, in _readloop_wrapper
    self._readloop(self)  # Could avoid using self using Python descriptors
  File "/home/neolithics/nx/code/streaming/video_streaming/linescan_input_stream.py", line 108, in _readloop
    set_genicam_values(self._initial_genicam_settings, ia.remote_device.node_map, self._stream_id,
  File "/home/neolithics/nx/code/streaming/video_streaming/common.py", line 33, in set_genicam_values
    node.set_value(v)
  File "/home/neolithics/nx/venv38/lib/python3.8/site-packages/genicam/genapi.py", line 2354, in set_value
    self._primal_set_value(value, verify)
  File "/home/neolithics/nx/venv38/lib/python3.8/site-packages/genicam/genapi.py", line 2270, in _primal_set_value
    return _genapi.IInteger__primal_set_value(self, Value, Verify)
_genapi.OutOfRangeException: Value = 192 must be equal or smaller than Max = 0. : OutOfRangeException thrown in node 'OffsetX' while calling 'OffsetX.SetValue()' (file 'IntegerT.h', line 79)

This erratic behaviour usually is the result of the camera settings being done in a "wrong" order.

The camera stores its settings internally and validates every combination that you apply, so every step you create must be valid. This also applies for every third-party tool you use with it, so if you used the manufacturer's GUI tool then the state of the camera has changed, and your program may yield different outputs, despite "nothing" having changed in your code.

The thing you are seeing here usually happens when you change the Width and ROI and attempt to Center the image on the sensor again. The workaround we use for this is to change the ROI params to 0,0 before we touch the width or height and then set it to the correct location on the sensor afterwards.