Open paulosousa32 opened 3 weeks ago
Hi paulosousa32,
I am not sure if this might be an issue, but I would try to acquire the camera exclusively.
The docs also mention that default is "exclusive"
privilege – Set an access privilege. exclusive, control, and read_only are supported. The default is exclusive.
I mean this is self-explanatory.
Error setting ExposureTime: Value 997.000000 must be smaller than or equal 97.439000. : OutOfRangeException thrown in node
'ExposureTime' while calling 'ExposureTime.SetValue()' (file 'FloatT.h', line 91)
Also I would begin trying with a basic example where you connect and acquire images and check if the buffer is empty.
Last: I am also not sure if PixelFormat can be just set since you might have to set TLParamsLocked first.
Just try a step-by-step approach.
Hello MYCL94, Thank you for your help, I have corrected the errors. However, do you have a basic example to test what you have just told me?
Hi, So i make the changes, put the exposure_time_node.value = 97.0, and the triggerMode to on. But wen i try to fetch the buffer they return None. Any ideas ?
New code
`def main(): h = Harvester()
try:
gentl_path = 'C:/Program Files/MATRIX VISION/mvIMPACT Acquire/bin/x64/mvGenTLProducer.cti'
if os.path.exists(gentl_path):
print(f"GenTL file found at {gentl_path}")
h.add_file(gentl_path)
else:
print(f"GenTL file not found at {gentl_path}")
return
print("Updating device list")
h.update()
print(f"Number of devices found: {len(h.device_info_list)}")
for device in h.device_info_list:
print(f"Device: {device.vendor} {device.model}")
if len(h.device_info_list) == 0:
print("No devices found. Exiting.")
return
# Manually specify the device using its serial number
device_info = h.device_info_list[0] # Assuming you want the first device in the list
try:
#ia = h.create_image_acquirer(0, privilege='exclusive')
ia = h.create(0)
print("Image acquirer created successfully")
except Exception as e:
print(f"Failed to create image acquirer: {str(e)}")
return
# Check the node map
print("Inspecting node map...")
node_map = ia.remote_device.node_map
# Attempt to configure camera settings directly
try:
exposure_time_node = node_map.get_node('ExposureTime')
exposure_time_node.value = 97.0 # Set exposure time
print(f"ExposureTime set to: {exposure_time_node.value} microseconds")
except Exception as e:
print(f"Error setting ExposureTime: {str(e)}")
try:
width_node = node_map.get_node('Width')
width_node.value = 2048 # Set width
print(f"Width set to: {width_node.value}")
except Exception as e:
print(f"Error setting Width: {str(e)}")
try:
height_node = node_map.get_node('Height')
height_node.value = 300 # Set height
print(f"Height set to: {height_node.value}")
except Exception as e:
print(f"Error setting Height: {str(e)}")
try:
ia.remote_device.node_map.AcquisitionMode.value = 'Continuous'
ia.remote_device.node_map.StreamChannelPacketSize.value = 9000
print("Acquisition mode set to Continuous.")
except Exception as e:
print(f"Error setting AcquisitionMode: {str(e)}")
try:
trigger_mode_node = node_map.get_node('TriggerMode')
trigger_mode_node.value = 'On'
print("Trigger mode set to On.")
except Exception as e:
print(f"Error setting TriggerMode: {str(e)}")
# Starting acquisition
print("Starting acquisition")
ia.start()
print(f"Acquisition status: {ia.is_acquiring()}")
# Fetch buffers
for i in range(3):
print(f"Fetching buffer {i + 1}")
try:
ia.remote_device.node_map.TriggerSoftware.execute()
buffer = ia.try_fetch(timeout=5)
print(buffer)
if buffer:
print("Buffer fetched successfully")
print(f"Buffer info: {buffer}")
# Check if the buffer payload has components
if hasattr(buffer.payload, 'components') and buffer.payload.components:
component = buffer.payload.components[0]
buffer_data = component.data if hasattr(component, 'data') else None
if buffer_data is not None:
width = width_node.value if width_node else 0
height = height_node.value if height_node else 0
image_size = width * height
# Create a numpy array from the buffer data
image_data = np.frombuffer(buffer_data, dtype=np.uint8, count=image_size)
# Ensure the buffer size is as expected
if image_data.size != image_size:
print(f"Unexpected buffer size: expected {image_size}, got {image_data.size}")
continue
# Reshape the image data
image = image_data.reshape((height, width))
print(f"Image shape: {image.shape}")
print(f"Image dtype: {image.dtype}")
# Display and save the image
window_name = f'output_image_{i + 1}'
cv2.imshow(window_name, image)
cv2.imwrite(f'{window_name}.png', image)
cv2.waitKey(10)
else:
print("Component data is None")
else:
print("Buffer payload has no components")
buffer.queue() # Requeue the buffer to continue acquisition
else:
print("Buffer is None")
except TimeoutException:
print(f"Timeout occurred while fetching buffer {i + 1}")
except Exception as e:
print(f"An error occurred while fetching buffer {i + 1}: {str(e)}")
traceback.print_exc()
time.sleep(1) # Add a small delay between buffer fetches
except Exception as e:
print(f"An error occurred: {str(e)}")
traceback.print_exc()
finally:
if 'ia' in locals():
print("Stopping acquisition and destroying image acquirer")
ia.stop()
ia.destroy()
print("Resetting Harvester")
h.reset()
if name == "main": main()`
Log
GenTL file found at C:/Program Files/MATRIX VISION/mvIMPACT Acquire/bin/x64/mvGenTLProducer.cti Updating device list Number of devices found: 1 Device: Teledyne DALSA Linea C4096-7um Image acquirer created successfully Inspecting node map... ExposureTime set to: 97.0 microseconds Width set to: 2048 Height set to: 300 Error setting AcquisitionMode: Trigger mode set to On. Starting acquisition Acquisition status: True Fetching buffer 1 None Buffer is None Fetching buffer 2 None Buffer is None Fetching buffer 3 None Buffer is None Stopping acquisition and destroying image acquirer Resetting Harvester
Hi,
I just realized this is a linescan camera and you are trying to acquire an image with "TriggerMode: On", but are you sure that you do have also a valid trigger? Also check if you have set SoftwareTrigger or HardwareTrigger in your nodemap. Which one do you want to use?
If it is SoftwareTrigger you also need to execute the command for it etc...
If it is HardwareTrigger make sure these settings are set properly. The best is to test the settings you need with Teledyne software.
Hi,
I'm using this command
ia.remote_device.node_map.TriggerSoftware.execute()
Or should I use another one?
I have checked the settings via Debug and they are receiving the values trigger_mode_node = On and trigger_sourece_node = Software.
Describe the Issue Hello. I'm using a DALSA linea C4096-7 camera. I'm trying to acquire images but without success. Below is the code I'm using and the error.
Sample Code
`from genicam.gentl import TimeoutException import numpy as np from harvesters.core import Harvester import cv2 import traceback import os import time
def main(): h = Harvester()
if name == "main": main()`
Complete Traceback error:
` GenTL file found at C:/Program Files/MATRIX VISION/mvIMPACT Acquire/bin/x64/mvGenTLProducer.cti
Updating device list
Number of devices found: 1
Device: Teledyne DALSA Linea C4096-7um
D:Testes\3.9\Harvester\tt.py:35: DeprecationWarning: please consider to use create() instead of create_image_acquirer(). ia = h.create_image_acquirer(0, privilege='control')
Image acquirer created successfully
Inspecting node map...
Error setting ExposureTime: Value 997.000000 must be smaller than or equal 97.439000. : OutOfRangeException thrown in node
'ExposureTime' while calling 'ExposureTime.SetValue()' (file 'FloatT.h', line 91)
Width set to: 2048
Height set to: 300
Error setting PixelFormat: Failed to write enumeration value. Enum entry is not writable : AccessException thrown in node
'PixelFormat' while calling 'PixelFormat.FromString()' (file 'Enumeration.cpp', line 139)
Acquisition mode set to Continuous.
Trigger mode set to Off.
Starting acquisition
Acquisition status: True
Fetching buffer 1
An error occurred while fetching buffer 1: GenTL exception: Given handle does not support the operation. (Message from the source: Invalid data stream handle) (ID: -1006)
2024-11-04 22:18:56,106 :: harvesters.core :: ERROR :: GenTL exception: Given handle does not support the operation. (Message from the source: Invalid data stream handle) (ID: -1006)
Traceback (most recent call last): File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2437, in _fetch monitor.update_event_data(self.timeout_period_on_update_event_data_call)
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\genicam\gentl.py", line 1296, in update_event_data return _gentl.EventManagerNewBuffer_update_event_data(self, timeout)
_gentl.InvalidHandleException: GenTL exception: Given handle does not support the operation. (Message from the source: Invalid data stream handle) (ID: -1006)
Traceback (most recent call last): File "D:\Testes\3.9\Harvester\tt.py", line 97, in main buffer = ia.fetch(timeout=5000)
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2562, in fetch buffer = self._fetch(monitor=monitor,
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2437, in _fetch monitor.update_event_data(self.timeout_period_on_update_event_data_call)
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\genicam\gentl.py", line 1296, in update_event_data return _gentl.EventManagerNewBuffer_update_event_data(self, timeout)
_gentl.InvalidHandleException: GenTL exception: Given handle does not support the operation. (Message from the source: Invalid data stream handle) (ID: -1006)
Fetching buffer 2
An error occurred while fetching buffer 2: list index out of range Traceback (most recent call last): File "D:\Testes\3.9\Harvester\tt.py", line 97, in main buffer = ia.fetch(timeout=5000)
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2568, in fetch return buffers if len(self._new_buffer_event_monitor_dict.values()) > 1 else buffers[0]
IndexError: list index out of range Fetching buffer 3 An error occurred while fetching buffer 3: list index out of range Traceback (most recent call last): File "D:\Testes\3.9\Harvester\tt.py", line 97, in main buffer = ia.fetch(timeout=5000)
File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2568, in fetch return buffers if len(self._new_buffer_event_monitor_dict.values()) > 1 else buffers[0]
IndexError: list index out of range
Fetching buffer 4 An error occurred while fetching buffer 4: list index out of range Traceback (most recent call last):
File "D:\Testes\3.9\Harvester\tt.py", line 97, in main buffer = ia.fetch(timeout=5000) File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2568, in fetch return buffers if len(self._new_buffer_event_monitor_dict.values()) > 1 else buffers[0] IndexError: list index out of range
Fetching buffer 5 An error occurred while fetching buffer 5: list index out of range Traceback (most recent call last):
File "D:\Testes\3.9\Harvester\tt.py", line 97, in main buffer = ia.fetch(timeout=5000) File "D:\Testes\3.9\Harvester\venv39\lib\site-packages\harvesters\core.py", line 2568, in fetch return buffers if len(self._new_buffer_event_monitor_dict.values()) > 1 else buffers[0] IndexError: list index out of range Stopping acquisition and destroying image acquirer Resetting Harvester `
Configuration