Skip to content
Browse files

Implemented more features!!

 * The following callbacks are now implemented:
    PoseDetectionCapability.pose_detected
    PoseDetectionCapability.out_of_pose

 * The following methods are now exposed:
    PoseDetectionCapability.register_pose_detected_cb(...)
    PoseDetectionCapability.unregister_pose_detected_cb(...)
    PoseDetectionCapability.register_out_of_pose_cb(...)
    PoseDetectionCapability.unregister_out_of_pose_cb(...)
    PoseDetectionCapability.start_detection(...)
    PoseDetectionCapability.stop_detection(...)

 * The following properties are now exposed:
    DepthMetaData.z_res

 * Removed completed task.
 * Removed debugging code at wrapNode(...)
 * Updated wrapper definition to reflect changes.
 * Tested the new features.
  • Loading branch information...
1 parent 0bf457c commit 46a23e435e5d9325778a8c6a945faca204a550eb @jmendeth committed
View
4 src/DepthMetaDataWrapper.cpp
@@ -27,4 +27,6 @@
#include "wrapperTypes.h"
#include "wrapperExceptions.h"
-//Currently empty
+XnDepthPixel DepthMetaData_ZRes(xn::DepthMetaData& self) {
+ return self.ZRes();
+}
View
2 src/DepthMetaDataWrapper.h
@@ -27,6 +27,6 @@
#include <XnCppWrapper.h>
#include "wrapperTypes.h"
-//Currently empty
+XnDepthPixel DepthMetaData_ZRes(xn::DepthMetaData& self);
#endif /* DEPTH_META_DATA_WRAPPER_H */
View
44 src/PoseDetectionCapabilityWrapper.cpp
@@ -27,4 +27,46 @@
#include "wrapperTypes.h"
#include "wrapperExceptions.h"
-//Currently empty
+void PoseDetectionCapability_StartPoseDetection_wrapped(xn::PoseDetectionCapability& self, std::string pose, XnUserID user) {
+ check( self.StartPoseDetection(pose.c_str(), user) );
+}
+
+void PoseDetectionCapability_StopPoseDetection_wrapped(xn::PoseDetectionCapability& self, XnUserID user) {
+ check( self.StopPoseDetection(user) );
+}
+
+XnCallbackHandle PoseDetectionCapability_RegisterPoseDetectedCallback(xn::PoseDetectionCapability& self, BP::object callback) {
+ XnCallbackHandle handle;
+
+ BP::object* cookie = new BP::object;
+ *cookie = callback;
+
+ check( self.RegisterToPoseDetected(&PoseDetectionCapability_PoseDetection_cb, cookie, handle) );
+
+ return handle;
+}
+void PoseDetectionCapability_UnregisterPoseDetectedCallback(xn::PoseDetectionCapability& self, XnCallbackHandle handle) {
+ self.UnregisterFromPoseDetected(handle);
+}
+
+XnCallbackHandle PoseDetectionCapability_RegisterOutOfPoseCallback(xn::PoseDetectionCapability& self, BP::object callback) {
+ XnCallbackHandle handle;
+
+ BP::object* cookie = new BP::object;
+ *cookie = callback;
+
+ check( self.RegisterToOutOfPose(&PoseDetectionCapability_PoseDetection_cb, cookie, handle) );
+
+ return handle;
+}
+void PoseDetectionCapability_UnregisterOutOfPoseCallback(xn::PoseDetectionCapability& self, XnCallbackHandle handle) {
+ self.UnregisterFromOutOfPose(handle);
+}
+
+
+/** Internal callback implementations **/
+void PoseDetectionCapability_PoseDetection_cb(xn::PoseDetectionCapability& src, const XnChar* pose, XnUserID user, void* cookie) {
+ BP::object& func = *((BP::object*)cookie);
+
+ func(src, std::string(pose), user);
+}
View
14 src/PoseDetectionCapabilityWrapper.h
@@ -27,6 +27,18 @@
#include <XnCppWrapper.h>
#include "wrapperTypes.h"
-//Currently empty
+void PoseDetectionCapability_StartPoseDetection_wrapped(xn::PoseDetectionCapability& self, std::string pose, XnUserID user);
+
+void PoseDetectionCapability_StopPoseDetection_wrapped(xn::PoseDetectionCapability& self, XnUserID user);
+
+XnCallbackHandle PoseDetectionCapability_RegisterPoseDetectedCallback(xn::PoseDetectionCapability& self, BP::object callback);
+void PoseDetectionCapability_UnregisterPoseDetectedCallback(xn::PoseDetectionCapability& self, XnCallbackHandle handle);
+
+XnCallbackHandle PoseDetectionCapability_RegisterOutOfPoseCallback(xn::PoseDetectionCapability& self, BP::object callback);
+void PoseDetectionCapability_UnregisterOutOfPoseCallback(xn::PoseDetectionCapability& self, XnCallbackHandle handle);
+
+
+/** Internal callback implementations **/
+void PoseDetectionCapability_PoseDetection_cb(xn::PoseDetectionCapability& src, const XnChar* pose, XnUserID user, void* cookie);
#endif /* POSE_DETECTION_CAPABILITY_WRAPPER_H */
View
4 src/UserGeneratorWrapper.cpp
@@ -69,9 +69,9 @@ BP::list UserGenerator_GetCoM_wrapped(xn::UserGenerator& self, XnUserID user) {
XnCallbackHandle UserGenerator_RegisterUserCallbacks_wrapped(xn::UserGenerator& self, BP::object newUser, BP::object lostUser) {
checkValid(self);
- XnCallbackHandle handle; //TODO: test this
+ XnCallbackHandle handle;
- BP::object* cookie = new BP::object [2];//FIXME: fix cookie
+ BP::object* cookie = new BP::object [2]; //FIXME: fix cookie
cookie[0] = newUser;
cookie[1] = lostUser;
View
16 src/wrapper.cpp
@@ -251,9 +251,9 @@ BOOST_PYTHON_MODULE(openni) {
.add_property("pixel_format", &xn::MapMetaData::PixelFormat)
.add_property("fps", &MapMetaData_FPS_wrapped)
- .add_property("res", make_function(&MapMetaData_Res))
- .add_property("offset", make_function(&MapMetaData_Offset))
- .add_property("full_res", make_function(&MapMetaData_FullRes))
+ .add_property("res", &MapMetaData_Res)
+ .add_property("offset", &MapMetaData_Offset)
+ .add_property("full_res", &MapMetaData_FullRes)
;
@@ -270,6 +270,9 @@ BOOST_PYTHON_MODULE(openni) {
class_< xn::DepthMetaData,
bases<xn::MapMetaData>, boost::noncopyable> ("DepthMetaData", no_init)
+
+ .add_property("z_res", &DepthMetaData_ZRes )
+
;
@@ -319,6 +322,13 @@ BOOST_PYTHON_MODULE(openni) {
bases<xn::Capability> > ("PoseDetectionCapability", no_init)
.def("count_poses", &xn::PoseDetectionCapability::GetNumberOfPoses)
+ .def("start_detection", &PoseDetectionCapability_StartPoseDetection_wrapped)
+ .def("stop_detection", &PoseDetectionCapability_StopPoseDetection_wrapped)
+
+ .def("register_pose_detected_cb", &PoseDetectionCapability_RegisterPoseDetectedCallback, return_value_policy<return_opaque_pointer>())
+ .def("unregister_pose_detected_cb", &PoseDetectionCapability_UnregisterPoseDetectedCallback)
+ .def("register_out_of_pose_cb", &PoseDetectionCapability_RegisterOutOfPoseCallback, return_value_policy<return_opaque_pointer>())
+ .def("unregister_out_of_pose_cb", &PoseDetectionCapability_UnregisterOutOfPoseCallback)
;
View
5 src/wrapperTypes.cpp
@@ -29,8 +29,6 @@
#include "wrapperExceptions.h"
-#include <iostream>
-
// One of the core methods of PyOpenNI:
// It tries to find the exposed class that best matches the given node.
BP::object wrapNode(XnNodeHandle node) {
@@ -42,8 +40,6 @@ BP::object wrapNode(XnNodeHandle node) {
const XnProductionNodeDescription* desc = xnNodeInfoGetDescription(info);
XnProductionNodeType original = desc->Type;
- std::cout << "Type is " << original << std::endl;
-
if (isInstanceOf(original, XN_NODE_TYPE_PRODUCTION_NODE)) {
if (isInstanceOf(original, XN_NODE_TYPE_GENERATOR)) {
if (isInstanceOf(original, XN_NODE_TYPE_MAP_GENERATOR)) {
@@ -66,6 +62,7 @@ BP::object wrapNode(XnNodeHandle node) {
return BP::object(xn::ProductionNode(node));
}
+ //This should never happen
PyErr_SetString(PyExc_TypeError, "Couldn't find appropiate type to wrap node.");
throw BP::error_already_set();
}

0 comments on commit 46a23e4

Please sign in to comment.
Something went wrong with that request. Please try again.