← Back

ofxOrbbec

github.com/danzeeeman/ofxOrbbec · @danzeeeman
OF 0.12 Hardware Interface Depth Sensing Video/Camera

openFrameworks addon for Orbbec Femto Mega depth cameras on OrbbecSDK_v2: colour/depth capture, hardware sync, recording and playback.

0 0 Last commit 3d ago Created 1mo ago

README

ofxOrbbec



An openFrameworks addon for Orbbec Femto Mega depth cameras, on OrbbecSDK_v2. It provides:

It is used by FemtoMegaSkeletonTracking (femtoSkeletonOsc).

Install



Clone it into <openFrameworks>/addons/ofxOrbbec. The Orbbec SDK is not in this repository (libs/OrbbecSDK/ is git-ignored). Put it there yourself.

macOS



scripts/install_sdk.sh            # fetches OrbbecSDK_v2 v2.10.6 into libs/OrbbecSDK
scripts/install_sdk.sh --force    # replaces an SDK already there


FemtoMegaSkeletonTracking's get_addons.sh runs it for you. To do it by hand:

1. Download the macOS release of OrbbecSDK_v2 v2.10.6 from its releases. 2. Lay it out like this:

   libs/OrbbecSDK/
       include/libobsensor/...
       lib/macos/libOrbbecSDK.dylib
       extensions/            (from the release's lib/extensions)
       OrbbecSDKConfig.xml
       LICENSE.txt
   


extensions/ stays outside lib/ on purpose. openFrameworks links every dylib under libs/
/lib/macos, but these are plugins the SDK loads itself at runtime.

After the build, addon_config.mk copies the dylibs and extensions/ into bin/<app>.app/Contents/MacOS/, next to the executable. It uses rsync --ignore-existing, so an app that copied (and signed) them itself keeps its copies.

Cameras on the network need two more things from the app:

  PROJECT_AFTER += codesign --force --deep --sign - --entitlements of.entitlements bin/$(BIN_NAME).app ;
  


Windows



addon_config.mk expects an extracted OrbbecSDK_v2 release at C:/src/OrbbecSDK (include/, lib/OrbbecSDK.lib). Copy bin/OrbbecSDK.dll and its bin/extensions/ folder next to the built .exe. Change the paths in addon_config.mk if your SDK is somewhere else.

Without the SDK



When OFX_ORBBEC_HAVE_SDK is not defined, the addon still compiles, against stubs: nothing opens and the finder finds nothing. The macOS section of addon_config.mk defines it.

Use



One camera



// ofApp.h

include "ofxOrbbecDevice.h"

ofxOrbbecDevice cam; ofTexture colorTex; // setup() ofxOrbbecDevice::Options opt; opt.alignDepthToColor = true; // depth the same size as colour: colour pixel (u,v) indexes depth opt.netAddress = "192.168.1.10"; // a camera on the network; leave empty for USB cam.open("", ofxOrbbecDevice::SyncMode::Standalone, opt); // on USB, open by serial number instead: cam.open("CL2H84100LE"); // update() cam.update(); const ofxOrbbecFrame& f = cam.getFrame(); if (f.isNew) { colorTex.loadData(f.color); // RGB uint16_t mm = f.depth[f.depth.getPixelIndex(320, 240)]; // depth in millimetres, 0 = none } glm::vec3 up; if (cam.getUp(up)) { / up in the colour camera's frame: x right, y down, z forward / }


Finding cameras



#include "ofxOrbbecFinder.h"
ofxOrbbecFinder finder;

finder.start(3.f);                     // look every 3 s, on a thread of its own
for (auto& c : finder.getFound()) {    // safe from any thread
    // c.serial, c.name, c.connection ("USB", "Ethernet", ...), c.ip (empty on USB)
}


Network discovery only finds cameras on the computer's own subnet. Each Femto needs an address of its own; the factory address is 192.168.1.10, and Orbbec Viewer can change it.

Several cameras in sync



#include "ofxOrbbecManager.h"
ofxOrbbecManager rig;

rig.openAll();                         // every connected camera; the first is sync primary, the rest secondary
// update()
rig.update();
for (size_t i = 0; i < rig.deviceCount(); i++) { auto& f = rig.device(i).getFrame(); }


This needs the cameras joined by the sync cable. Without one, open each camera on its own with SyncMode::Standalone.

Recording and playback



#include "ofxOrbbecRecording.h"
ofxOrbbecRecorder rec;
ofxOrbbecPlayer player;

// record
rec.start(ofToDataPath("take.femto", true), cam.getSerial(), cam.getColorIntrinsics());
glm::vec3 up; bool hasUp = cam.getUp(up);
if (cam.getFrame().isNew) rec.add(cam.getFrame().color, cam.getFrame().depth, hasUp, up);
rec.stop();

// play back: the same calls as a live camera
player.open(ofToDataPath("take.femto", true));
player.loop = true; player.speed = 1.f;
player.update();
const ofxOrbbecFrame& f = player.getFrame();


Files



file
ofxOrbbecDeviceone camera: open, threaded capture, depth registered to colour, accelerometer
ofxOrbbecFinderfinds cameras on USB and on the network, on its own thread
ofxOrbbecManagerseveral cameras with trigger-cable sync
ofxOrbbecRecordingofxOrbbecRecorder and ofxOrbbecPlayer, the .femto format
ofxOrbbecTypes.hofxOrbbecFrame (depth in mm, RGB colour, timestamp) and ofxOrbbecIntrinsics

License



The Orbbec SDK has its own license (libs/OrbbecSDK/LICENSE.txt, from its release).

Get this addon

HTTPS
SSH