Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:gimlids/BodyScanner

  • Loading branch information...
commit 45275bff5b6a8c3dcda2d8f4494753ee62c4db6e 2 parents 72607b3 + d3cc398
@markluffel markluffel authored
View
12 pcl-grabber/include/pcl_addons/io/openni_human_grabber.h
@@ -46,9 +46,12 @@ namespace BodyScanner
bool hasUserStream () const throw ();
+ static void __stdcall UserCalibration_CalibrationStart(xn::SkeletonCapability& capability, XnUserID nId, void* pCookie);
+ static void __stdcall UserCalibration_CalibrationComplete(xn::SkeletonCapability& capability, XnUserID nId, XnCalibrationStatus bStatus, void* pCookie);
+ static void __stdcall UserPose_PoseDetected(xn::PoseDetectionCapability& capability, XnChar const* strPose, XnUserID nId, void* pCookie);
static void __stdcall NewUserDataAvailable (xn::ProductionNode& node, void* cookie) throw ();
- //void __stdcall NewUserCallback(xn::UserGenerator& generator, XnUserID user, void* cookie) throw ();
- //void __stdcall LostUserCallback(xn::UserGenerator& generator, XnUserID user, void* cookie) throw ();
+ static void __stdcall NewUserCallback(xn::UserGenerator& generator, XnUserID user, void* cookie) throw ();
+ static void __stdcall LostUserCallback(xn::UserGenerator& generator, XnUserID user, void* cookie) throw ();
void imageForUserCallback(boost::shared_ptr<openni_wrapper::Image> image, void* cookie);
@@ -83,6 +86,11 @@ namespace BodyScanner
xn::UserGenerator user_generator_;
XnCallbackHandle user_callback_handle_;
+ XnCallbackHandle calibration_start_callback_handle_;
+ XnCallbackHandle calibration_complete_callback_handle_;
+ XnCallbackHandle user_pose_detected_callback_handle_;
+ bool need_pose_;
+ XnChar pose_[20];
//openni_wrapper::OpenNIDevice::CallbackHandle user_callback_handle_counter_;
pcl_addons::Synchronizer3<boost::shared_ptr<openni_wrapper::Image>,
View
71 pcl-grabber/src/pcl_addons/io/openni_human_grabber.cpp
@@ -26,20 +26,51 @@ void __stdcall OpenNIHumanGrabber::NewUserDataAvailable (xn::ProductionNode& nod
grabber->user_condition_.notify_all ();
}
-void __stdcall /*OpenNIHumanGrabber::*/NewUserCallback (xn::UserGenerator& generator, XnUserID user, void* cookie) throw ()
+void __stdcall OpenNIHumanGrabber::NewUserCallback (xn::UserGenerator& generator, XnUserID user, void* cookie) throw ()
{
OpenNIHumanGrabber* grabber = reinterpret_cast<OpenNIHumanGrabber*>(cookie);
PCL_INFO("new user\n");
//grabber->user_condition_.notify_all();
+ if (grabber->need_pose_)
+ grabber->user_generator_.GetPoseDetectionCap().StartPoseDetection(grabber->pose_, user);
+ else
+ grabber->user_generator_.GetSkeletonCap().RequestCalibration(user, TRUE);
}
-void __stdcall /*OpenNIHumanGrabber::*/LostUserCallback (xn::UserGenerator& generator, XnUserID user, void* cookie) throw ()
+void __stdcall OpenNIHumanGrabber::LostUserCallback (xn::UserGenerator& generator, XnUserID user, void* cookie) throw ()
{
OpenNIHumanGrabber* grabber = reinterpret_cast<OpenNIHumanGrabber*>(cookie);
PCL_INFO("lost user\n");
//grabber->user_condition_.notify_all();
}
+void __stdcall OpenNIHumanGrabber::UserCalibration_CalibrationStart(xn::SkeletonCapability& capability, XnUserID nId, void* pCookie) {
+ PCL_INFO("Calibration started for user %d\n", nId);
+}
+
+void __stdcall OpenNIHumanGrabber::UserCalibration_CalibrationComplete(xn::SkeletonCapability& capability, XnUserID nId, XnCalibrationStatus bStatus, void* pCookie) {
+ OpenNIHumanGrabber* grabber = (OpenNIHumanGrabber*) pCookie;
+
+ if (bStatus == XN_CALIBRATION_STATUS_OK) {
+ PCL_INFO("Calibration complete, start tracking user %d\n", nId);
+ grabber->user_generator_.GetSkeletonCap().StartTracking(nId);
+ }
+ else {
+ PCL_INFO("Calibration failed for user %d\n", nId);
+ if (grabber->need_pose_)
+ grabber->user_generator_.GetPoseDetectionCap().StartPoseDetection(grabber->pose_, nId);
+ else
+ grabber->user_generator_.GetSkeletonCap().RequestCalibration(nId, TRUE);
+ }
+}
+
+void __stdcall OpenNIHumanGrabber::UserPose_PoseDetected(xn::PoseDetectionCapability& capability, XnChar const* strPose, XnUserID nId, void* pCookie) {
+ OpenNIHumanGrabber* grabber = (OpenNIHumanGrabber*) pCookie;
+
+ PCL_INFO("Pose %s detected for user %d", strPose, nId);
+ grabber->user_generator_.GetPoseDetectionCap().StopPoseDetection(nId);
+ grabber->user_generator_.GetSkeletonCap().RequestCalibration(nId, TRUE);
+}
OpenNIHumanGrabber::OpenNIHumanGrabber()
{
@@ -68,37 +99,37 @@ OpenNIHumanGrabber::OpenNIHumanGrabber()
quit_ = false;
- //user_callback_handle = registerUserCallback(&OpenNIHumanGrabber::userCallback, this);
-
- //XnCallbackHandle hUserCallbacks;
- //user_generator_.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
-
- /*
- XnCallbackHandle hCalibrationCallbacks;
- user_generator_.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, NULL, hCalibrationCallbacks);
+ //XnCallbackHandle hCalibrationCallbacks;
+ //user_generator_.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, NULL, /*TODO calibration_callback_handle_, shutdown, etc*/ hCalibrationCallbacks);
+ user_generator_.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, this, calibration_start_callback_handle_);
+ user_generator_.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, this, calibration_complete_callback_handle_);
if (user_generator_.GetSkeletonCap().NeedPoseForCalibration()) {
- g_bNeedPose = TRUE;
+ need_pose_ = TRUE;
if (!user_generator_.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION)) {
- ROS_INFO("Pose required, but not supported");
- return 1;
+ PCL_INFO("Pose required, but not supported");
+ //return 1;
}
XnCallbackHandle hPoseCallbacks;
- user_generator_.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, NULL, hPoseCallbacks);
+ //user_generator_.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, NULL, hPoseCallbacks);
+ user_generator_.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, this, user_pose_detected_callback_handle_);
- user_generator_.GetSkeletonCap().GetCalibrationPose(g_strPose);
+ user_generator_.GetSkeletonCap().GetCalibrationPose(pose_);
+ printf("Getting calibration pose %s\n", pose_);
}
user_generator_.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
- */
+
image_for_user_callback_handle = getDevice()->registerImageCallback(&OpenNIHumanGrabber::imageForUserCallback, *this);
depth_for_user_callback_handle = getDevice()->registerDepthCallback(&OpenNIHumanGrabber::depthForUserCallback, *this);
+
+
}
void OpenNIHumanGrabber::checkImageStreamRequired()
@@ -133,6 +164,11 @@ void OpenNIHumanGrabber::start () throw (pcl::PCLIOException)
pcl::OpenNIGrabber::start();
startUserStream();
+
+ // debug FIXME remove
+ //BodyScanner::OpenNIDriverNITE& driver = (BodyScanner::OpenNIDriverNITE&) openni_wrapper::OpenNIDriver::getInstance();
+ //xn::Context* context = driver.getOpenNIContext();
+ //context->StartGeneratingAll();
}
@@ -155,6 +191,7 @@ void OpenNIHumanGrabber::startUserStream () throw (openni_wrapper::OpenNIExcepti
{
printf("started user stream\n");
user_thread_ = boost::thread (&OpenNIHumanGrabber::UserDataThreadFunction, this);
+
}
}
}
@@ -227,7 +264,7 @@ void OpenNIHumanGrabber::imageForUserCallback(boost::shared_ptr<openni_wrapper::
void OpenNIHumanGrabber::depthForUserCallback(boost::shared_ptr<openni_wrapper::DepthImage> depth_image, void* cookie)
{
- printf("depth for user callback\n");
+ //printf("depth for user callback\n");
if (num_slots<sig_cb_openni_user_skeleton_and_point_cloud_rgb > () > 0 //||
/*num_slots<sig_cb_openni_image_depth_image > () > 0*/)
rgb_depth_user_sync_.add1(depth_image, depth_image->getTimeStamp());
View
24 segmentation/segmentation2.cpp
@@ -143,7 +143,7 @@ int argmin(std::vector<double> vec)
}
-void assignPoints(std::vector<pcl::PointXYZ> bones, std::vector<pcl::PointXYZ> joints, std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> *limbs_clouds)
+void assignPoints(std::vector<pcl::PointXYZ> bones, std::vector<pcl::PointXYZ> joints, std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> *limbs_clouds,int vizindex)
{
@@ -154,6 +154,7 @@ void assignPoints(std::vector<pcl::PointXYZ> bones, std::vector<pcl::PointXYZ> j
int j = 0;
+ int temparg;
//input->points.resize(cloud->points.size());
@@ -185,9 +186,18 @@ void assignPoints(std::vector<pcl::PointXYZ> bones, std::vector<pcl::PointXYZ> j
// Add point to argmin bone
- (*limbs_clouds)[argmin(distances)]->push_back(c);
+ // (*limbs_clouds)[argmin(distances)]->push_back(c);
+
+ temparg = argmin(distances);
+ if (temparg == vizindex){
+ cloud->points[i].x = 0;
+ cloud->points[i].y = 0;
+ cloud->points[i].z = 0;
+ }
+ (*limbs_clouds)[temparg]->points[i] = c;
+
}
@@ -250,6 +260,7 @@ int segmentation (string filename , int index)
{
limbs_clouds[k] = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
+ limbs_clouds[k]->resize(cloud->size());
}
@@ -317,7 +328,7 @@ joints[RHI] = pcl::PointXYZ(2.3326878762, 0.0827771917936, -0.0142110859517);
// Compute 1st method bone ownership
- assignPoints(bones,joints,&limbs_clouds);
+ assignPoints(bones,joints,&limbs_clouds,index);
// Check bones clouds size and output
@@ -345,13 +356,14 @@ joints[RHI] = pcl::PointXYZ(2.3326878762, 0.0827771917936, -0.0142110859517);
//pcl::visualization::CloudViewer viewer("Cloud Viewer");
-boost::shared_ptr<pcl::visualization::PCLVisualizer> view (new pcl::visualization::PCLVisualizer ("3D Viewer"));
-
+// Visualization stuff
+boost::shared_ptr<pcl::visualization::PCLVisualizer> view (new pcl::visualization::PCLVisualizer ("3D Viewer"));
view->addCoordinateSystem (1.0);
view->initCameraParameters ();
+// Visualizasion of the joints position
for (int m = LH2E; m<= RK2F; m++){
std::stringstream s;
@@ -395,7 +407,7 @@ int main (int argc , char** argv)
{
if(argc != 3)
{
- std::cout<< "Usage: segmentation <file_name> " << std::endl;
+ std::cout<< "Usage: segmentation2 <file_name> <number between 0 and 8>" << std::endl;
exit(0);
}
View
2  surface-reconstructor/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(surface-reconstructor)
-find_package(PCL 1.1 REQUIRED)
+find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
View
4 surface-reconstructor/surface-reconstructor.cpp
@@ -228,7 +228,7 @@ void recons(std::string infile, std::string outfile) {
// Set typical values for the parameters
gp3.setMu (2.5);
gp3.setMaximumNearestNeighbors (100);
- gp3.setMaximumSurfaceAgle(M_PI/4); // 45 degrees
+ gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
gp3.setMinimumAngle(M_PI/18); // 10 degrees
gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
gp3.setNormalConsistency(false);
@@ -366,7 +366,7 @@ void colorRecons(std::string infile, std::string outfile) {
// Set typical values for the parameters
gp3.setMu(2.5);
gp3.setMaximumNearestNeighbors(50); // reducing this didn't fix flips
- gp3.setMaximumSurfaceAgle(M_PI/4); // 45 degrees
+ gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
gp3.setMinimumAngle(M_PI/18); // 10 degrees
gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
gp3.setNormalConsistency(true); // changing this didn't fix flips
Please sign in to comment.
Something went wrong with that request. Please try again.