genicam / harvesters

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

Ranger3 Sick (3d Machine Vision Camera) not being able to fetch buffer through harvester #269

Closed pratiksparwatwar closed 2 years ago

pratiksparwatwar commented 2 years ago

Describe the Bug I am using Ranger3 Sick (3d machine vision camera) with Ubuntu 18.04. I have *.cti file from their Linux SDK. I am able to load cti file through harvester and get Camer info. but when I try to fetch_buffer I am gettig the following error. _genapi.RuntimeException: Invalid layout of buffer attached to chunk parser! : RuntimeException thrown (file 'ChunkAdapterGEV.cpp', line 99)

I have used following code

from harvesters.core import Harvester import numpy as np h = Harvester() h.add_file("sickGenTLProducer.cti") h.update() print(len(h.device_info_list)) print(h.device_info_list[0]) ia = h.create_image_acquirer(0) ia.start_acquisition() with ia.fetch_buffer() as buffer: print(buffer)

To Reproduce Steps to reproduce the behavior:

  1. Connect Ranger3 sick camera with Ubuntu system.
  2. Build Linux sdk from sicksupportportal
  3. Install genicam and harvester
  4. Use the code from harvester for image aquisition
  5. See error

Expected Behavior Needed buffer data from camera through code

Screenshots If applicable, add screenshots to help explain your problem; Note that it is not necessary to put everything as a screenshot! If the source is a text just paste the text because that is much helpful for us.

Configuration

Reproducibility

This phenomenon can be reproduced by other versions:

If so, please list up the reproducible versions you have confirmed:

Actions You Have Taken

Additional context Add any other context about the problem here.

kazunarikudo commented 2 years ago

@pratiksparwatwar Hi,

Thank you for the report and for trying out Harvester. Here's a quick question: Does the issue happen every fetch_buffer call?

As a typical scenario, there is a case where a frame turns corrupted due to an unexpected trouble such as insufficiently small size buffers; once an image buffer consisted of corrupted part then it cannot be parsed as long as the chunk parser is enabled. This case can be resolved with a large enough buffer that's about 9 kB enabling jumbo frame on the NIC. There is also a case where the corruption is introduced by a poor quality cable but it should be enough if you remind there's such a case.

Best regards, Kazunari

fswane commented 2 years ago

Hi

I have exactly the same problem as reported above by @pratiksparwatwar. My setup is also the same as his.

With device setting DeviceScanType = "Linescan3D" the following happens:

The first 17 calls to 'fetch_buffer' raises an exception with: Invalid layout of buffer attached to chunk parser! : RuntimeException thrown (file 'ChunkAdapterGEV.cpp', line 99)

Calls to 'fetch_buffer" after the first 17 calls raise a TimeoutException.

With device setting DeviceScanType = "Areascan" I do get 2D frames from the device when calling 'fetch_buffer'.

I.e. Areascan works whereas Linescan3D does not work.

Regards Francois

pratiksparwatwar commented 2 years ago

@pratiksparwatwar Hi,

Thank you for the report and for trying out Harvester. Here's a quick question: Does the issue happen every fetch_buffer call?

As a typical scenario, there is a case where a frame turns corrupted due to an unexpected trouble such as insufficiently small size buffers; once an image buffer consisted of corrupted part then it cannot be parsed as long as the chunk parser is enabled. This case can be resolved with a large enough buffer that's about 9 kB enabling jumbo frame on the NIC. There is also a case where the corruption is introduced by a poor quality cable but it should be enough if you remind there's such a case.

Best regards, Kazunari

Issue Happens every fetch buffer call

pratiksparwatwar commented 2 years ago

Hi

I have exactly the same problem as reported above by @pratiksparwatwar. My setup is also the same as his.

With device setting DeviceScanType = "Linescan3D" the following happens:

The first 17 calls to 'fetch_buffer' raises an exception with: Invalid layout of buffer attached to chunk parser! : RuntimeException thrown (file 'ChunkAdapterGEV.cpp', line 99)

Calls to 'fetch_buffer" after the first 17 calls raise a TimeoutException.

With device setting DeviceScanType = "Areascan" I do get 2D frames from the device when calling 'fetch_buffer'.

I.e. Areascan works whereas Linescan3D does not work.

Regards Francois

Can you please share how to apply device settings through code.

fswane commented 2 years ago

Device settings are applied programatically using:

self.ia = self.harvester.create_image_acquirer(dev_idx)

# Iterate over all settings and apply.
nm = self.ia.remote_device.node_map
for m in my_camera_config:
    for (k, v) in m.items():
        if nm.has_node(k):
            nm.get_node(k).value = v

In this code my_camera_config is a list of dictionaries with key/value pairs being the name of the setting and the required valued.

For the Ranger3, these are two of the settings supported by the device: my_camera_config = [{"DeviceScanType": "Linescan3D"}, {"RegionSelector": "Region1"}]

I have these in a TOML configuration file which the application loads and applies.

I tested the behaviour of harvesters_gui (from https://github.com/genicam/harvesters_gui) and see the same problem that the 3D data cannot be acquired from the Ranger3 due to:

Invalid layout of buffer attached to chunk parser! : RuntimeException thrown (file 'ChunkAdapterGEV.cpp', line 99)

kazunarikudo commented 2 years ago

Hi, I'd appreciate it if you could give it a try with the GenTL producer from MATRIX VISION to check if the phenomenon can be reproduced with that. Here's the link to their installer:

Once you installed that on your machine, please grep their CTI file (i.e., a GenTL producer). And then, please run your program again with their CTI file. Thanks! Regards, Kazunari.

fswane commented 2 years ago

Hi @kazunarikudo

Thanks for the idea to use the Matrix Vision CTI file. Using this file

/opt/mvIMPACT_Acquire/lib/x86_64/mvGenTLProducer.cti

I am able to acquire buffers from the SICK Ranger3 device!

I will see whether I can extract 3D profiles as needed using this.

Does this mean there is a bug in the CTI file provided by SICK?

Regards Francois

fswane commented 2 years ago

Hi @pratiksparwatwar

I finally got feedback from Sick support. It seems there is an issue where chunk data provided by the Ranger3 is not dealt with well in Harvester. Their recommendation is to disable Chunk Data on the device.

I tried this and it seems to have fixed the problem.

Regards Francois

olofsjo1SICKAG commented 2 years ago

@fswane and @pratiksparwatwar I would recommend that you test the fix provided by #281 and see if that solves your problems with chunks together with the Ranger3-camera.

Please report back if you still experience troubles. Best regards Jonas

kazunarikudo commented 2 years ago

@olofsjo Hi Jonas, thank you for taking care of this issue. I appreciate that. I have added some lines based on the suggested fix presented by Alfred to take care of some more practical situations. Hence, it's ready to be tested on the field! Thank you again for your support. Regards, Kazunari.

kazunarikudo commented 2 years ago

Hi Everybody, Could you ping me when any of you could confirm the issue has been resolved. We have resolved the first issue but I do not know if there are some more defects that block us to get the SICK Ranger 3 working. Thanks!

olofsjo1SICKAG commented 2 years ago

We have started testing on the release candidate for GenApi v3.4. Alfred found a smaller problem and made a pull request https://github.com/genicam/harvesters/pull/295, we will continue testing this week.

fswane commented 2 years ago

Hi

Thanks we'll have a look later this week and provide feedback.

Regards

Francois

On 2022/03/07 08:12, Kazunari Kudo wrote:

Hi Everybody, Could you ping me when any of you could confirm the issue has been resolved. We have resolved the first issue but I do not know if there are some more defects that block us to get the SICK Ranger 3 working. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/genicam/harvesters/issues/269#issuecomment-1060228222, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHIR3T63NFHP4Z43VHU6STU6WM4TANCNFSM5JJPRZWA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

manhsp commented 2 years ago

Hi everyone, please help me down sdk 2.8 or 2.9 sick ranger3 from website sicksupportportal. Thanks

olofsjo1SICKAG commented 2 years ago

@manhsp I recommend that you pick 2.9 or a later version. 2.9 can be found here: https://supportportal.sick.com/release/3d-stream-sdk-version-29/ and 3.1 (currently the latest) here: https://supportportal.sick.com/release/3d-stream-sdk-version-31/

manhsp commented 2 years ago

I don't have account this website. Can you help me?

Vào Th 2, 29 thg 8, 2022 vào lúc 13:33 Jonas Olofsson < @.***> đã viết:

@manhsp https://github.com/manhsp I recommend that you pick 2.9 or a later version. 2.9 can be found here: https://supportportal.sick.com/release/3d-stream-sdk-version-29/ and 3.1 (currently the latest) here: https://supportportal.sick.com/release/3d-stream-sdk-version-31/

— Reply to this email directly, view it on GitHub https://github.com/genicam/harvesters/issues/269#issuecomment-1229839286, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASAXPHZUQDG7PXHHCROEVALV3RKVBANCNFSM5JJPRZWA . You are receiving this because you were mentioned.Message ID: @.***>

olofsjo1SICKAG commented 2 years ago

@manhsp I recommend that you register for an account at https://supportportal.sick.com/

MedMazigh commented 2 months ago

Hello everyone, I have a question regarding the scaling factors of the ranger3 3D camera, I have the datacube with the following bands: 'ZRange', 'Reflectance', 'XRange'. I also have the scaling factors: 'scale_factors_x_y_z': ['0.0130191', '1', '0.00870004']. I used this code in python to convert pixel values into real distances: z_range = data_cube[:,:,0] x_range = data_cube[:,:,2] ref = data_cube[:,:,1]

converted_data = np.empty_like(data_cube)

converted_data[:,:,0] = z_range scale[2] converted_data[:,:,1] = ref scale[1] converted_data[:,:,2] = x_range * scale[0] but the resulted values do not represent the real distances. I would very much appreciate any help on this matter. Note: the camera is well calibrated and the aspect ratio is also well calibrated. Thank you