Not able to get connection with camera in python

General Information

  • Product: N36-Kit-BL
  • Serial Number: 231546
  • Ensenso SDK Version: 3.6.1321
  • Operating System: Linux Ubuntu 22.04

Problem / Question

With NxView, I can detect and open the camera without any problem:

When I use the example python script to print all available cameras I can see the camera again but the status is Not Calibrated:
image
Also when I try to open the camera and view the images I receive an error on the capture function:

I re-calibrated the camera in NxView using the ‘Download factory pattern positions’ method but this didn’t change the Not Calibrated status in python.

I also tried installing the nxlib with pip and from the sdk. Both installations were successful but connecting to the camera gave the same error.

Someone knows what I am doing wrong here?

Kind regards,
Simon

Hi,

NxView reports an issue with the configuration of your network adapters at the bottom of the window. You can click that to get more detailed information. Could you please check this first? The error might e.g. be an IP address collision between different adapters, which can lead to all kinds of surprising behavior.

Hi Daniel,
Thank you for your response.
The issues were related to two other adapters that had the same IP range. I closed one so now I don’t have the warning anymore. However, when I run the python script I still receive the error and the Not Calibrated status.

One thing I noticed in NxView is the little wrench icon at the camera icon. This tells something about a local settings file being used by NxView but not by NxLib. Could this be the problem?
Maybe another thing worth mentioning is that NxView runs on my host machine and the python scripts are being executed from a docker container.

Ok, then we have to search further.

NxView is the little wrench icon at the camera icon. This tells something about a local settings file being used by NxView but not by NxLib.

This just means that NxView has saved settings from the last time you opened the camera in it that it will use by default. When using the API you get the default parameters.

NxView runs on my host machine and the python scripts are being executed from a docker container.

I am not sure if this makes a difference. You got the network to detect the camera though, so it seems to work fine. Have you tried running the same script on the host and does that change anything?


I have some questions:

  • Do I understand your description and the screenshot correctly? You executed the Open command, which ran without an exception and then the Capture command, which gave the error in the image? That error message indicates that Open was not executed before Capture, but you mentioned that you did.
  • Can you try running the example nx_simple.py in the same setup and see if that works?
  • When it doesn’t work, could you please use NxTreeEdit to create a copy of the NxLib tree and a log and post it here? You have to insert a call to nxlib.api.open_tcp_port at the beginning of your program, then connect NxTreeEdit to it and start logging from the “Debug” tab at the bottom before running the commands. In Docker you might also need to forward the port.

Tried running the script on the host and it runs without any problems. When i run the nx_list_cams script I even see the Available status for the camera (in docker this still gives me Not Calibrated).
The script nx_simple gives me the average z value and with watch_point_cloud I was able to view the pointcloud.
So on the host I don’t see any problems, in the docker container I am still unable to connect to the camera.


Answers to the questions (all tested in docker container):

  • Using the script as is, with the camera initialization as with NxLib(), Camera.from_serial(args.serial) as camera:, i receive the error on this line.
    But when I move the camera initialization inside the with NxLib(): like camera = Camera.from_serial("231546") then I don’t recieve the error on this line but on the camera.capture() line.
  • nx_simple gives the same error
  • executing the open_tcp_port gives me the NxLibInitializationNotAllowed error: NxLib error 23 (NxLibInitializationNotAllowed) for item

I could reproduce this in a Docker container. The behavior you described seems to occur when the ENSENSO_INSTALL environment variable is not set. The deb package writes it to /etc/environment, which not used in Docker. When I manually set ENSENSO_INSTALL to /opt/ensenso everything worked.

The error messages are not the ones I would have expected in this case, we will look into this and improve them in the future.

Indeed, this solved the error.

Thanks for the help!