Jump to content

A minimal working example for the C++ API


pfp
 Share

Recommended Posts

Could anyone please provide a minimal working example for the C++ API?

In my implementation StartGestureDetection() fails with GestureFailureCamera. The prebuilt examples are working fine, so the camera configuration in SteamVR is fine.

I've tried the following (based on the documentaion):

#include "include/interface_gesture.hpp"
#include <iostream>


int main()
{
    GestureOption option;

    // Start detection and check result
    GestureFailure result = StartGestureDetection(&option);
    if (result != GestureFailureNone) {
        std::cout << "Detection start failed with error: " << result << std::endl;
        return 1;
    }
    std::cout << "Detection started" << std::endl;

    const GestureResult* points = NULL;
    int lastFrameIndex = -1;

    // pseudo game loop
    while (true) {
        int frameIndex = -1;
        int size = GetGestureResult(&points, &frameIndex);
        if (frameIndex < 0) {
            std::cout << "Gesture detection start failed with error: " << result << std::endl;
            break;
        } else if (frameIndex == lastFrameIndex)
            continue;

        lastFrameIndex = frameIndex;
        // do stuffs with points
        for (int i = 0; i < size; i++)
            std::cout << "Hand " << i << " is " << (points[i].isLeft ? "left" : "right") << " hand" << std::endl;
    }

    return 0;
}

Thanks. @zzy

Link to comment
Share on other sites

  • 2 weeks later...

Found the solution. In "%APPDATA%\..\Local\Aristo\Aristo.log" there was this line: "Unable to load OpenVR library"

So I copied "Prebuilt samples\Windows\ViveHandTrackingUISample_Win64\UISample_Data\Plugins\openvr_api.dll" next to the built exe (same as aristo_interface.dll) and now it works.

(The exact error message was "Detection start failed with error: -2" in case someone later needs this info.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...