Using Embedded S camera from ARM with OpenNI

I have an ARM SoC that I’ve connected an Embedded S camera to. I can see the camera is connected:

$ lsusb
Bus 001 Device 006: ID 2bc5:050b
Bus 001 Device 007: ID 2bc5:060b

I downloaded http://dl.orbbec3d.com/dist/openni2/OpenNI_2.3.0.63.zip from Develop – Orbbec then copied the OpenNI-Linux-Arm64-2.3.0.63 directory to my device and ran install.sh. Now when I plug in the camera I get:

[ 5887.390778] hub 1-1:1.0: 2 ports detected
[ 5887.879656] usb 1-1.1: New USB device found, idVendor=2bc5, idProduct=050b
[ 5887.886538] usb 1-1.1: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[ 5887.894193] usb 1-1.1: Product: USB 2.0 Camera
[ 5887.898757] usb 1-1.1: Manufacturer: Sonix Technology Co., Ltd.
[ 5887.904814] usb 1-1.1: SerialNumber: SN0001
[ 5888.232284] usb 1-1.2: New USB device found, idVendor=2bc5, idProduct=060b
[ 5888.239161] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5888.246856] usb 1-1.2: Product: ORBBEC Depth Sensor
[ 5888.251853] usb 1-1.2: Manufacturer: Orbbec(R)
```
I cross-compiled a simple app:
```
    int main(int argc, char** argv)
    {
        const char* deviceURI = openni::ANY_DEVICE;
        Status result = STATUS_OK;
        result = OpenNI::initialize();
        cout << "OpenNI::initialize() = " << result << endl;
        openni::Array<openni::DeviceInfo> deviceList;
        openni::OpenNI::enumerateDevices(&deviceList);
        cout << "OpenNI::enumerateDevices() = " << deviceList.getSize() << endl;
        for (int i = 0; i < deviceList.getSize(); ++i)
        {
            cout << "Device " << deviceList[i].getUri() << " already connected" << endl;
        }
```

When I ran it first I got:
```
error while loading shared libraries: libOpenNI2.so: cannot open shared object file: No such file or director
```

So I copied libOpenNI2.so to /usr/lib. Now when I run it I get:
```
OpenNI::initialize() = 1
OpenNI::enumerateDevices() = 0
```

Why isn't the camera being seen? Is there something else I have to do to get it to work?

I turned on logging using:

OpenNI::setLogMinSeverity(0);
OpenNI::setLogConsoleOutput(true);

and saw:

3774       INFO            Log     XnLog.cpp       349     New log started on 2019-11-25 09:57:11
3864       INFO            Log     XnLog.cpp       322     --- Filter Info --- Minimum Severity: VERBOSE
4044       VERBOSE         OniContext      OniContext.cpp  165     OpenNI 2.3.0 (Build 63)-Linux-Arm (May 13 2019 17:45:57)
4089       VERBOSE         OniContext      OniContext.cpp  259     Using '/usr/lib/OpenNI2/Drivers' as driver path
4112       VERBOSE         OniContext      OniContext.cpp  267     Looking for drivers at '/usr/lib/OpenNI2/Drivers'
4167       ERROR           OniContext      OniContext.cpp  279     Found no drivers matching '/usr/lib/OpenNI2/Drivers/lib*.so'

So I copied the files from OpenNI-Linux-Arm64-2.3.0.63/Redist/OpenNI2/Drivers/ to /usr/lib/OpenNI2/Drivers/. The Readme also says:

*for using with Astra Embedded S/Stereo S, please change the resolution in 'orbbec.ini' to 'Resolution=17' for Depth and IR streams

So I edited this in /usr/lib/OpenNI2/Drivers/orbbec.ini. Now I get:

3924       INFO            Log     XnLog.cpp       349     New log started on 2019-11-25 10:23:55
4010       INFO            Log     XnLog.cpp       322     --- Filter Info --- Minimum Severity: VERBOSE
4185       VERBOSE         OniContext      OniContext.cpp  165     OpenNI 2.3.0 (Build 63)-Linux-Arm (May 13 2019 17:45:57)
4230       VERBOSE         OniContext      OniContext.cpp  259     Using '/usr/lib/OpenNI2/Drivers' as driver path
4254       VERBOSE         OniContext      OniContext.cpp  267     Looking for drivers at '/usr/lib/OpenNI2/Drivers'
4547       VERBOSE         OniContext      OniContext.cpp  309     Loading device driver 'libOniFile.so'...
4588       WARNING         xnOS    XnLinuxSharedLibs.cpp   107     loading lib from: /usr/lib/OpenNI2/Drivers/libOniFile.so

6199       VERBOSE         OniContext      OniContext.cpp  309     Loading device driver 'libPSLink.so'...
6240       WARNING         xnOS    XnLinuxSharedLibs.cpp   107     loading lib from: /usr/lib/OpenNI2/Drivers/libPSLink.so

11412       WARNING         DriverHandler   OniDriverHandler.cpp    85      LibraryHandler: Couldn't find function oniDriverStreamConvertC2DCoordinates in libPSLink.so. Stopping
11539       WARNING         OniContext      OniContext.cpp  313     Couldn't use file 'libPSLink.so' as a device driver
11626       VERBOSE         OniContext      OniContext.cpp  309     Loading device driver 'liborbbec.so'...
11675       WARNING         xnOS    XnLinuxSharedLibs.cpp   107     loading lib from: /usr/lib/OpenNI2/Drivers/liborbbec.so

15571       INFO            Log     XnLog.cpp       349     New log started on 2019-11-25 10:23:55
15615       INFO            Log     XnLog.cpp       322     --- Filter Info --- Minimum Severity: VERBOSE
15645       VERBOSE         xnUSB   XnLinuxUSB.cpp  383     Initializing USB...
19162       INFO            xnUSB   XnLinuxUSB.cpp  412     USB is initialized.
OpenNI::initialize() = 0
OpenNI::enumerateDevices() = 0

which is better but still not successful. I then realised that I hadn’t reconnected the camera after copying the driver files so I did that and it worked.