LeiaSR SDK
720218b2 v1.32.7.6322 2025-02-13T14:55:38Z
Stable
Example C++
1
5
#include "
sr/types.h
"
6
#include "
sr/sense/core/inputstream.h
"
7
#include "
sr/management/srcontext.h
"
8
#include "
sr/sense/handtracker/handtracker.h
"
9
#include <iostream>
10
11
SR_point3d
myPoint{ 0.0, 1.0, 2.0 };
12
13
class
MyListener :
public
SR::HandPoseListener
{
14
public
:
15
SR::InputStream<SR::HandPoseStream>
inputStream;
16
// Inherited via HandPoseListener
17
virtual
void
accept
(
const
SR_handPose
& handpose)
override
18
{
19
std::cout << handpose.
palm
.
x
<<
"\n"
;
20
}
21
};
22
23
int
main() {
24
SR::SRContext
context;
25
SR::HandTracker
* handTracker =
SR::HandTracker::create
(context);
26
MyListener listener;
27
listener.inputStream.set(handTracker->
openHandPoseStream
(&listener));
28
context.
initialize
();
29
30
char
c;
31
std::cin >> c;
32
}
SR::HandPoseListener
Interface for listening to SR_handPose updates.
Definition:
handposelistener.h:34
SR::HandPoseListener::accept
virtual void accept(const SR_handPose &handPose)=0
Accept an SR_handPose frame.
SR::HandTracker
Sense class which provides hand tracking functionality to the SR system.
Definition:
handtracker.h:41
SR::HandTracker::openHandPoseStream
virtual std::shared_ptr< HandPoseStream > openHandPoseStream(HandPoseListener *listener)=0
Creates a HandPoseStream for listener to be connected to.
SR::HandTracker::create
static HandTracker * create(SRContext &context)
Creates a functional HandTracker instance.
SR::InputStream
Template class to wrap data stream to a listener object.
Definition:
inputstream.h:20
SR::SRContext
Maintains WorldObject and Sense objects during the application lifetime.
Definition:
srcontext.h:75
SR::SRContext::initialize
void initialize()
Initialize all senses.
handtracker.h
inputstream.h
srcontext.h
SR_handPose
C-compatible struct containing the pose of a hand.
Definition:
handpose.h:119
SR_handPose::palm
SR_point3d palm
Absolute position of the center of the palm.
Definition:
handpose.h:127
types.h
SR_vector3d
C-compatible 3d double vector representation.
Definition:
types.h:73
SR_vector3d::x
double x
First value in the 3d vector.
Definition:
types.h:76
Generated by
1.9.2