harvesters
harvesters copied to clipboard
AttributeError: __enter__ while trying "with ia.try_fetch(timeout=3) as buffer:
Describe the Issue Hello! I am trying to acquire images in loop, but .fetch() returns None or throws an error. While when I use CamExpert for image capturing it goes without problems. Sometimes it turns out to read one image outside the loop successfully, but I don't know what it depends on.
To Reproduce Steps to reproduce the behavior:
- Run script
Sample Code I can show a piece of code that demonstrates the reported phenomenon:
- [X] Yes
- [ ] No
If yes, please provide a sample code:
from harvesters.core import Harvester
import time
import traceback
import sys
h = Harvester()
h.add_file('/opt/mvIMPACT_Acquire/lib/x86_64/mvGenTLProducer.cti')
h.update()
print('Camera devices list: ', h.device_info_list)
ia = h.create(0)
ia.remote_device.node_map.AcquisitionMode.value = 'Continuous'
ia.remote_device.node_map.TriggerMode.value = 'On'
ia.remote_device.node_map.TriggerSource.value = 'Software'
ia.remote_device.node_map.PixelFormat.value = 'Mono8'
ia.start()
print('Image aquisition initialized')
time.sleep(5)
for i in range(0, 4):
try:
with ia.try_fetch(timeout=3) as buffer:
print(i, '\n', buffer)
except Exception as e:
traceback.print_exc(file=sys.stdout)
ia.stop()
ia.destroy()
h.reset()
exit()
If applicable, please paste the actual output (its whole traceback, etc) here:
Camera devices list: [{'access_status': 1, 'display_name': 'Teledyne DALSA Nano-M2020(00:01:0d:c5:2e:67)', 'id_': 'Nano-M2020(00:01:0d:c5:2e:67)', 'model': 'Nano-M2020', 'parent': <genicam.gentl.Interface; proxy of <Swig Object of type 'std::shared_ptr< GenTLCpp::TLInterface > *' at 0x7f511a975a80> >, 'serial_number': 'S1236159', 'tl_type': 'GEV', 'user_defined_name': 'S1236159', 'vendor': 'Teledyne DALSA', 'version': '1.08'}]
Image aquisition initialized
Traceback (most recent call last):
File "2test_camera.py", line 26, in <module>
with ia.try_fetch(timeout=3) as buffer:
AttributeError: __enter__
Traceback (most recent call last):
File "2test_camera.py", line 26, in <module>
with ia.try_fetch(timeout=3) as buffer:
AttributeError: __enter__
Traceback (most recent call last):
File "2test_camera.py", line 26, in <module>
with ia.try_fetch(timeout=3) as buffer:
AttributeError: __enter__
Traceback (most recent call last):
File "2test_camera.py", line 26, in <module>
with ia.try_fetch(timeout=3) as buffer:
AttributeError: __enter__
Expected Behavior Script can fetch images endlessly in a loop.
Configuration
- OS: Ubuntu Linux 22.04
- Python: 3.8.16
- Harvester: 1.4.2; 1.4.1; 1.4.0; 1.3.8; 1.3.7;
- GenTL Producer: Matrix Vision 2.44; 2.47
- Camera: Teledyne DALSA Nano-M2020
Reproducibility
This phenomenon can be stably reproduced:
- [X] Yes
- [ ] No.
- [X] I've read the Harvester FAQ page.