Driver issues with ofxNI2 on Mac M1 Monterey

Hello!

I’m using @roymacdonald’s addon ofxNI2 for a Kinect project. Right now I’m just trying to get the example-user-tracking example working. I followed the README instructions for getting set up on OSX which includes adding a Run Script in XCode. The example project builds successfully but I get the following errors:

[ error ] ofAppGLFWWindow: 65544: Cocoa: Failed to find service port for display
[ error ] ofAppGLFWWindow: 65544: Cocoa: Failed to find service port for display
2022-11-02 10:36:59.186920-0400 example-user-trackerDebug[91258:2957161] Metal API Validation Enabled
   904621 INFO       New log started on 2022-11-02 10:36:59
   904682 INFO       --- Filter Info --- Minimum Severity: VERBOSE
   904710 VERBOSE    No override device in configuration file
   904738 VERBOSE    Configuration has been read from '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI.ini'
   904740 VERBOSE    OpenNI 2.2.0 (Build 33)-MacOSX (Nov 12 2013 16:14:14)
   904741 VERBOSE    Extending the driver path by './OpenNI2/Drivers', as configured in file '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI.ini'
   904743 VERBOSE    Using '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/./OpenNI2/Drivers' as driver path
   904745 VERBOSE    Looking for drivers in drivers repository '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/./OpenNI2/Drivers'
   930376 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libFreenectDriver.0.6.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libFreenectDriver.0.6.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

   930562 VERBOSE    Couldn't use file 'libFreenectDriver.0.6.0.dylib' as a device driver
   931116 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libFreenectDriver.0.6.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libFreenectDriver.0.6.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

   931123 VERBOSE    Couldn't use file 'libFreenectDriver.0.6.dylib' as a device driver
   931543 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libFreenectDriver.0.6.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libFreenectDriver.0.6.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

   931549 VERBOSE    Couldn't use file 'libFreenectDriver.dylib' as a device driver
  1284781 WARNING    LibraryHandler: Couldn't find function oniDriverStreamSetServices in libPS1080.dylib. Stopping
  1284800 VERBOSE    Couldn't use file 'libPS1080.dylib' as a device driver
  1375497 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libfreenect2-openni2.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libfreenect2-openni2.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

  1375525 VERBOSE    Couldn't use file 'libfreenect2-openni2.0.dylib' as a device driver
  1376657 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libfreenect2-openni2.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libfreenect2-openni2.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

  1376676 VERBOSE    Couldn't use file 'libfreenect2-openni2.dylib' as a device driver
  1419529 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libfreenect2.0.2.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libfreenect2.0.2.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

  1419546 VERBOSE    Couldn't use file 'libfreenect2.0.2.0.dylib' as a device driver
  1420062 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libfreenect2.0.2.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libfreenect2.0.2.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

  1420074 VERBOSE    Couldn't use file 'libfreenect2.0.2.dylib' as a device driver
  1420478 WARNING    Failed loading lib: dlopen(/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI2/Drivers/libfreenect2.0.2.0.dylib, 0x0002): Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: /Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libfreenect2.0.2.0.dylib
  Reason: tried: '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (no such file), '/usr/lib/system/introspection/libusb-1.0.0.dylib' (no such file), '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/local/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file)

  1420487 VERBOSE    Couldn't use file 'libfreenect2.dylib' as a device driver
[notice ] OpenNI initialised. Version: 2.2.0.33
[notice ] List devices:
[ fatal ] ofxNI2::Device: invalid device id
[notice ] List devices:

In this earlier post, I saw someone say they fixed this issue by installing libusb, so I tried that but still getting the same error.

Another thing I tried was adding arm64 to the Excluded Architectures in my Build Settings.

I’m using a mac with an M1 Max chip running Monterey 12.2.1. Any suggestions?

Hi @thisisthais ,
Welcome to the OF forum.

That addon is super old and I have not used it for quite a while, but also it might be that the libraries have not been compiled for the arm64 architechture.
But more important it is that the path to libusb is wrong. I dont know why it changes with each architecture.
so, find where the libusb file is and link it properly.
THe easiest way would be use the install_name_tool command.

Thanks @roymacdonald!

I couldn’t quite figure out how to use install_name_tool but I did find where libusb was installed and copied it into one of the folders that that libfreenect looks for and got a new type of error:

'/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/libusb-1.0.0.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),

It seems even if I fixed the linking properly I would have architecture issues. I’ll look into other kinect + skeleton options for now.

libusb and libfreenect are available with brew and support M1/M2

you can install the packages with brew and copy the .dylibs over it as you did.

a quick guess (without digging too much into this) is that ofxNI2 has intel compiled libs, which necessitates compiling the app for intel (ie, excluding arm64) but perhaps brew is installing arm specific dylibs? so this error is occuring

mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')

It’s a kind of guess based on some other issues I’ve had with older addons / m1 Macs. There’s probably some solution which may involve finding another set of dylibs or some brew incantation, etc…

I’m definitely in unfamiliar territory here so I appreciate the suggestions!

I followed the instructions here on building libusb for both x86_64 and arm64. The good news is I’m getting a new runtime output now:

[ error ] ofAppGLFWWindow: 65544: Cocoa: Failed to find service port for display
2022-11-02 17:02:49.196775-0400 example-user-trackerDebug[44593:3219153] Metal API Validation Enabled
  1013534 INFO       New log started on 2022-11-02 17:02:49
  1013591 INFO       --- Filter Info --- Minimum Severity: VERBOSE
  1013619 VERBOSE    No override device in configuration file
  1013646 VERBOSE    Configuration has been read from '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI.ini'
  1013648 VERBOSE    OpenNI 2.2.0 (Build 33)-MacOSX (Nov 12 2013 16:14:14)
  1013649 VERBOSE    Extending the driver path by './OpenNI2/Drivers', as configured in file '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/OpenNI.ini'
  1013651 VERBOSE    Using '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/./OpenNI2/Drivers' as driver path
  1013653 VERBOSE    Looking for drivers in drivers repository '/Users/thais/Documents/drawing++/of_v0.11.2_osx_release/addons/ofxNI2/example-user-tracker/bin/example-user-trackerDebug.app/Contents/MacOS/./OpenNI2/Drivers'
OpenNI2-FreenectDriver: Using libfreenect v0.6.0
OpenNI2-FreenectDriver: Using libfreenect v0.6.0
OpenNI2-FreenectDriver: Using libfreenect v0.6.0
  1492107 WARNING    LibraryHandler: Couldn't find function oniDriverStreamSetServices in libPS1080.dylib. Stopping
  1492141 VERBOSE    Couldn't use file 'libPS1080.dylib' as a device driver
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 0 usb devices connected
[Info] [Freenect2Impl] found 0 devices
  1690587 INFO       Using libfreenect2
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 0 usb devices connected
[Info] [Freenect2Impl] found 0 devices
  1857961 WARNING    LibraryHandler: Couldn't find function oniDriverCreate in libfreenect2.0.2.0.dylib. Stopping
  1857987 VERBOSE    Couldn't use file 'libfreenect2.0.2.0.dylib' as a device driver
  1858219 WARNING    LibraryHandler: Couldn't find function oniDriverCreate in libfreenect2.0.2.dylib. Stopping
  1858227 VERBOSE    Couldn't use file 'libfreenect2.0.2.dylib' as a device driver
  1858357 WARNING    LibraryHandler: Couldn't find function oniDriverCreate in libfreenect2.dylib. Stopping
  1858360 VERBOSE    Couldn't use file 'libfreenect2.dylib' as a device driver
[notice ] OpenNI initialised. Version: 2.2.0.33
[notice ] List devices:
[ fatal ] ofxNI2::Device: invalid device id
[notice ] List devices:

I also tried installing libfreenect and libusb for for x64_86 following these instructions but still get the above message.

I might just look at other ways to do skeleton tracking, maybe with MediaPipe

It looks like an issue about having the correct libraries.
Are you able to run openFrameworks included kinect examples? Those use libfreenect and libusb, so if those work you could just copy those libs into ofxNI2. (should be in OF_ROOT/addons/ofxKinect/libs/)

1 Like