zed-sdk icon indicating copy to clipboard operation
zed-sdk copied to clipboard

interface 0 sometimes not released on ZED 2i

Open davehawkey opened this issue 3 years ago • 2 comments

Preliminary Checks

  • [X] This issue is not a duplicate. Before opening a new issue, please search existing issues.
  • [X] This issue is not a question, feature request, or anything other than a bug report directly related to this project.

Description

I have an application that uses 2 cameras (ZED M and ZED 2i) and periodically opens both cameras, records a video from both, and then closes them.

Occasionally when re-opening the ZED 2i the open will fail:

can't claim interface 0: -6
[Sample][Error] Camera Open 1  | INVALID CALIBRATION FILE : Calibration file found but it is corrupted. Download your factory calibration file from calib.stereolabs.com or use ZED calibration tool to recalibrate. Exit program.

When this happens the following file gets created: /usr/local/zed/settings/SN0.conf

I can reproduce quite frequently in my application for some reason. I also created a test program attached below which is able to reproduce after some time. Restarting the application allows the camera to be opened again.

Steps to Reproduce

  1. 2 cameras connected to ZED Box (ZED M and ZED 2i)
  2. Run attached program which opens each camera, records a video, then closes repeatedly

main.cpp.txt

Expected Result

Can continuously open/close cameras

Actual Result

After some number of iterations the ZED 2i open() will fail and following messages printed:

can't claim interface 0: -6
[Sample][Error] Camera Open 1  | INVALID CALIBRATION FILE : Calibration file found but it is corrupted. Download your factory calibration file from calib.stereolabs.com or use ZED calibration tool to recalibrate. Exit program.

Restarting the application allows it to open successfully again.

ZED Camera model

ZED2i

Environment

ZED Box Xavier NX
Jetpack version: 4.6-b197
ZED SDK Version: 3.7.7

Anything else?

I've tried running the application with "export LIBUSB_DEBUG=4".

I noticed that normally when calling Camera.close() I see the following message for each camera: [39.523691] [000044d6] libusb: debug [libusb_release_interface] interface 0

However when the issue reproduces I do not see the message when closing the ZED 2i.

In addition I continue to see various libusb messages printed like: [145.631209] [00003548] libusb: debug [add_to_flying_list] arm timerfd for timeout in 5000ms (first in line)

at 5 second intervals. Normally when the cameras close successfully I see no further messages from libusb.

davehawkey avatar Sep 22 '22 03:09 davehawkey

Attaching the libusb messages from success and failure case.

Look at log lines between "Closing camera: 0" and "Closed camera: 0". In the failure case there are no messages from libusb, while in the success case there are many messages such as libusb_release_interface and libusb_exit.

In the failure case you can also see there continues to be libusb messages every 5 seconds after closing the cameras.

zed_close_success.txt zed_close_fail.txt

davehawkey avatar Sep 22 '22 04:09 davehawkey

Updating the sample code to start/stop recording twice before closing the camera seems to make it reproduce much more easily.

main2.cpp.txt

davehawkey avatar Sep 22 '22 04:09 davehawkey

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days

github-actions[bot] avatar Oct 23 '22 02:10 github-actions[bot]