genicam / harvesters

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

No metadata in buffer from SICK TriSpector 1000 #297

Closed maciejolszanski closed 2 years ago

maciejolszanski commented 2 years ago

Describe the Bug I am trying to acquire 3D images using SICK TriSpector 1000 Streamer. Based on the SICK tutorial the TriSpector GenTL producer sends out 8-bit reflectance image, 16-bit range image and metadate (scale and offset), which are used for measurment conversion. I successfully receive 8-bit and 16-bit images, but in the buffer there is no metadata. The length of the buffer is equal to 2.

print(buffer)
print(len(buffer.payload.components))
Component #0: 296 x 420, Mono8, 124320 elements,
[255 255 255 ... 255 255 255]
Component #1: 296 x 420, Coord3D_C16, 124320 elements,
[523 523 523 ... 349 349 349]
2

Expected Behavior I believe that it should be another element in the buffer. Is it possible that the metadata is missing? Or maybe I am looking for it in wrong place?

Configuration

Screenshots These are screenshots from the SICK tutorial: image image

kazunarikudo commented 2 years ago

@maciejolszanski Hi Maciej, thank you for the report. Here's a quick question: Is the metadata a part of the buffer? Or, is it a set of feature nodes in the node map that is delivered as a chunk data? If the metadata is mapped to the feature nodes, you should be able to read the value from the corresponding node such as ia.remote_device.Scale.value. If it is a part of the buffer that resides at the same level as the components you have already acquired, then it would imply there's a defect in Harvester. Perhaps Jonas (@olofsjo) could help you. Best regards, Kazunari.

kazunarikudo commented 2 years ago

@olofsjo By the way, did SICK acquire Harvester?! 😅 Ha ha!

olofsjo1SICKAG commented 2 years ago

@kazunarikudo I do not have that much knowledge on the Trispector but I will hand over the question to a colleague and hopefully we can help out with an answer.

maciejolszanski commented 2 years ago

Thanks for quick response 😄

@kazunarikudo You are probably right that I should get these values using node of the remote device.

I found the example program in Halcon 13: image I do not know this language, but I guess that set_framegrabber_param sets a value 'CoordinateA' to node ChunkScan3dCoordinateSelector and get_framegrabber_param gets a value of node and assigns to variable 😉

I tried to do it in my program. Assigning a value to node works fine, but when I want to read a value of the Scale or Offset I receive an error. I noticed that Selector node, which I can read and write without any problem has acces mode = 4, while the Scale and Offset nodes has access mode = 1. I haven't found any method to change the access mode. Is there any way to do this?

node.ChunkScan3dCoordinateSelector.value ='CoordinateA'
print('Selector access mode: ', node.ChunkScan3dCoordinateSelector.get_access_mode())
print('Scale access mode: ', node.ChunkScan3dCoordinateScale.get_access_mode())
print('Scale valid: ', node.ChunkScan3dCoordinateScale.is_value_cache_valid())
print(node.ChunkScan3dCoordinateScale.value)
Selector access mode:  4
Scale access mode:  1
Scale valid:  False
---------------------------------------------------------------------------
AccessException                           Traceback (most recent call last)
g:\studia\2_MAGISTERKA\TRISPECTOR_RAMKA\program\acquire.ipynb Cell [5](vscode-notebook-cell:/g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/acquire.ipynb#ch0000004?line=4)' in <module>
      4 print('Scale access mode: ', node.ChunkScan3dCoordinateScale.get_access_mode())
      5 print('Scale valid: ', node.ChunkScan3dCoordinateScale.is_value_cache_valid())
----> [6](vscode-notebook-cell:/g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/acquire.ipynb#ch0000004?line=5) print(node.ChunkScan3dCoordinateScale.value)

File g:\studia\2_MAGISTERKA\TRISPECTOR_RAMKA\program\my_env\lib\site-packages\genicam\genapi.py:2234, in IFloat._get_value(self)
   [2233](file:///g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/my_env/lib/site-packages/genicam/genapi.py?line=2232) def _get_value(self):
-> [2234](file:///g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/my_env/lib/site-packages/genicam/genapi.py?line=2233)     return self._primal_get_value()

File g:\studia\2_MAGISTERKA\TRISPECTOR_RAMKA\program\my_env\lib\site-packages\genicam\genapi.py:2147, in IFloat._primal_get_value(self, Verify, IgnoreCache)
   [2146](file:///g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/my_env/lib/site-packages/genicam/genapi.py?line=2145) def _primal_get_value(self, Verify=False, IgnoreCache=False):
-> [2147](file:///g%3A/studia/2_MAGISTERKA/TRISPECTOR_RAMKA/program/my_env/lib/site-packages/genicam/genapi.py?line=2146)     return _genapi.IFloat__primal_get_value(self, Verify, IgnoreCache)

AccessException: Node is not readable. : AccessException thrown in node 'ChunkScan3dCoordinateScale' while calling 'ChunkScan3dCoordinateScale.GetValue()' (file 'FloatT.h', line 294)
olofsjo1SICKAG commented 2 years ago

Looks strange that you cannot access it. According to the xml it should be read-only and not write-only as your prints indicates (I do not the device in question available for testing at the moment). Have you tested to acquire an image before trying to read the value or did you just try to read?

maciejolszanski commented 2 years ago

I tried both options. Neither before nor after the acquisition I cannot read the node value.

What xml do you mean? I have edited the example xml that SICK provides, and put it in directory foo/xml/. I've created the env variable HARVESTERS_XML_FILE_DIR which value is a path to foo/xml/.

My xml is:

<?xml version="1.0" encoding="utf-8" ?>    
<ROOT>

    <!-- Camera basic information -->
<DEVICE>TrispectorS</DEVICE>
<DEVICE_SN>
    <DEVICE_SN_N SN="my_serial_number>>"/>
</DEVICE_SN>

<CAM_PARA>on</CAM_PARA>

<CAM_IP>10.9.17.103</CAM_IP>
<CAM_PORT>9000</CAM_PORT>

<Profile_Trigger>FreeRunning</Profile_Trigger>
<Image_Trigger>None</Image_Trigger>
</ROOT>

I noticed that changing the Profie Trigger and Image Trigger has no effect on the device, so I configured them, as well as field of view in SopasET. Then I was able to acquire images in a way i needed.

Well, now I removed this xml from this directory, and still was able to acquire images. So it looks like my xml file is not needed. But if it is unused, how the harvester knows the IP address of the TriSpector?

PS My TriSpector firmware is 4.2.0. Maybe I should try with another firmware?

olofsjo1SICKAG commented 2 years ago

@maciejolszanski could you open a support ticket at https://supportportal.sick.com/ so we have an easier time assigning the correct people and priority to helping you. And I think it would be good to provide the complete sample of your code.

The xml I'm looking at is the device-xml that describes all parameters.

maciejolszanski commented 2 years ago

I was in the process of opening the ticket and then I made a small correct in my code to make it more readable. I run my program and it worked.

These nodes are only readable after acquring the image. I checked it earlier but it was a bug in my code 🤦

Thanks @olofsjo and @kazunarikudo for your help. Problem solved!

kazunarikudo commented 2 years ago

@maciejolszanski Hi Maciej, I'm glad to hear that you've got it running in the end. I hope you enjoy working on your project with Harvester.

@olofsjo Hi Jonas, thanks again for your kind help!

olofsjo1SICKAG commented 2 years ago

@maciejolszanski good to hear that it now works! I hope you enjoy capturing images with Harvester and your Trispector!

maciejolszanski commented 2 years ago

To bo honest, I was terrified at the beggining, but now I really enjoy working with Harvester and TriSpector. Thank you again 😄