MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / SetSelectors

Method SetSelectors

Samples/NiUserSelection/SampleManager.cpp:113–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113XnStatus DefaultInitializerWithCalibPose::SetSelectors()
114{
115 // get the user generator (required as an input).
116 xn::UserGenerator *pUserGenerator=m_pUserTracker->GetUserGenerator();
117
118 // make sure the user generator is good.
119 if(pUserGenerator->IsCapabilitySupported(XN_CAPABILITY_SKELETON)==FALSE)
120 {
121 RETURN_WITH_CLEANUP(XN_STATUS_ERROR, "User generator does not support skeleton!");
122 }
123
124 // tracking initializer to use is the default one.
125 m_pTrackingInitializer=XN_NEW(DefaultTrackingInitializer,pUserGenerator);
126 if(m_pTrackingInitializer->IsValid()==FALSE)
127 {
128 RETURN_WITH_CLEANUP(XN_STATUS_ERROR, "Failed to create tracking initializer");
129 }
130
131 // pick the user selector.
132
133
134 // figure out which type of user selection to use.
135 // Option 1: if we need calibration pose - that is the type to use (and exit if we can't support it)
136 // Option 2: if do not need calibration pose we choose the overridden selector
137 if(pUserGenerator->GetSkeletonCap().NeedPoseForCalibration()==TRUE)
138 {
139 // make sure we have a pose detection capability (which is what this selector is all about).
140 if(pUserGenerator->IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION)==FALSE)
141 {
142 RETURN_WITH_CLEANUP(XN_STATUS_ERROR, "User tracker invalid");
143
144 }
145 // first we get the pose from the skeleton capability
146 char poseString[50];
147 pUserGenerator->GetSkeletonCap().GetCalibrationPose(poseString);
148 // we now create the appropriate pose selector chooser
149 m_pUserSelector=XN_NEW(PoseUserSelector,pUserGenerator,m_pTrackingInitializer,poseString);
150 }
151 else
152 {
153 // get the overridden user selector
154 m_pUserSelector=CreateUserSelector(pUserGenerator,m_pTrackingInitializer);
155 }
156
157 // make sure the user selector is valid
158 if(m_pUserSelector->IsValid()==FALSE)
159 {
160 RETURN_WITH_CLEANUP(XN_STATUS_ERROR,"Failed to create user selector");
161 }
162
163 // initialize the tracking initializer with the relevant user selector.
164 m_pTrackingInitializer->SetUserTracker(m_pUserSelector);
165
166 // set the user selector and tracking initializer to the
167 m_pUserTracker->InitUserSelection(m_pUserSelector,m_pTrackingInitializer);
168
169 return XN_STATUS_OK;
170}

Callers

nothing calls this directly

Calls 6

GetUserGeneratorMethod · 0.80
GetSkeletonCapMethod · 0.80
SetUserTrackerMethod · 0.80
InitUserSelectionMethod · 0.80
IsCapabilitySupportedMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected