Cameras: clarify on macOS that Orbbec/RealSense2 need sudo (not udev)

On macOS both SDKs access the camera through libusb, which must seize the
USB interface from the system driver - that requires root. Make the
device-not-found / access-error messages say "run with sudo" on Apple
instead of the Linux-only "udev rules" text. Also fix a dangling %s (no
argument) in the Orbbec "device with ID not found" message.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
matlabbe
2026-06-28 14:38:28 -07:00
co-authored by Claude Opus 4.8
parent f7d855e798
commit 143f4a744b
2 changed files with 30 additions and 6 deletions
+18 -6
View File
@@ -282,16 +282,20 @@ bool CameraOrbbecSDK::init(const std::string & calibrationFolder, const std::str
}
if(device.get() == nullptr) {
#ifdef __APPLE__
const std::string connectHint = "camera is correctly connected. On macOS the Orbbec "
"camera can only be accessed with root privileges, so run the application with sudo.";
#else
const std::string connectHint = "camera is correctly connected and the udev rules are installed.";
#endif
if(deviceId_.empty()) {
UERROR( "Could not find any orbbec compatible devices! Verify that the "
"camera is correctly connected and the udev rules are installed.");
UERROR("Could not find any orbbec compatible devices! Verify that the %s", connectHint.c_str());
}
else {
UERROR("Could not find an orbbec device with ID \"%s\"! Verify that the "
"camera is correctly connected and the udev rules are installed. "
"Unset the ID to choose the first camera found.");
UERROR("Could not find an orbbec device with ID \"%s\"! Verify that the %s "
"Unset the ID to choose the first camera found.", deviceId_.c_str(), connectHint.c_str());
}
return false;
}
@@ -555,7 +559,15 @@ bool CameraOrbbecSDK::init(const std::string & calibrationFolder, const std::str
}
catch(const ob::Error & e)
{
#ifdef __APPLE__
UERROR("Failed to initialize Orbbec camera: %s. On macOS the Orbbec SDK accesses "
"the camera through libusb, which must take the USB interface from the system "
"UVC driver; this requires root privileges. If this is a USB access error "
"(e.g. \"uvc_open failed ... Return Code: -3\"), run the application with sudo.",
e.what());
#else
UERROR("Failed to initialize Orbbec camera: %s", e.what());
#endif
this->close();
return false;
}
+12
View File
@@ -508,7 +508,14 @@ bool CameraRealSense2::init(const std::string & calibrationFolder, const std::st
rs2::device_list list = ctx_.query_devices();
if (0 == list.size())
{
#ifdef __APPLE__
UERROR("No RealSense2 devices were found! On macOS the RealSense SDK accesses "
"the camera through libusb, which must take the USB interface from the "
"system driver; this requires root privileges. If a device is connected "
"but not detected, run the application with sudo.");
#else
UERROR("No RealSense2 devices were found!");
#endif
return false;
}
@@ -546,7 +553,12 @@ bool CameraRealSense2::init(const std::string & calibrationFolder, const std::st
}
catch(const rs2::error & error)
{
#ifdef __APPLE__
UWARN("%s. Is the camera already used with another app? On macOS, accessing a "
"RealSense camera requires root privileges, so try running with sudo.", error.what());
#else
UWARN("%s. Is the camera already used with another app?", error.what());
#endif
}
if (!found)