Permalink
Browse files

speed improvements (user tracking disabled)

  • Loading branch information...
jeffreylin committed Apr 27, 2011
1 parent 6e145b1 commit 00e06e1836d425e8cd54b2f71817f1f03d1e0d7f
Showing with 50 additions and 50 deletions.
  1. +44 −37 ntk/camera/nite_rgbd_grabber.cpp
  2. +6 −13 tests/test-nite.cpp
@@ -93,8 +93,10 @@ void NiteRGBDGrabber :: initialize()
status = m_ni_context.FindExistingNode(XN_NODE_TYPE_DEPTH, m_ni_depth_generator);
check_error(status, "Find depth generator");
- status = m_ni_context.FindExistingNode(XN_NODE_TYPE_USER, m_ni_user_generator);
- check_error(status, "Find user generator");
+ if(m_body_event_detector){
+ status = m_ni_context.FindExistingNode(XN_NODE_TYPE_USER, m_ni_user_generator);
+ check_error(status, "Find user generator");
+ }
status = m_ni_context.FindExistingNode(XN_NODE_TYPE_IMAGE, m_ni_rgb_generator);
check_error(status, "Find image generator");
@@ -121,23 +123,25 @@ void NiteRGBDGrabber :: initialize()
ntk_ensure(m_ni_depth_generator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT), "Cannot register images.");
m_ni_depth_generator.GetAlternativeViewPointCap().SetViewPoint(m_ni_rgb_generator);
- ntk_throw_exception_if(!m_ni_user_generator.IsCapabilitySupported(XN_CAPABILITY_SKELETON),
+ if(m_body_event_detector){
+ ntk_throw_exception_if(!m_ni_user_generator.IsCapabilitySupported(XN_CAPABILITY_SKELETON),
"Supplied user generator doesn't support skeleton.");
- XnCallbackHandle hUserCallbacks, hCalibrationCallbacks, hPoseCallbacks;
- m_ni_user_generator.RegisterUserCallbacks(User_NewUser, User_LostUser, this, hUserCallbacks);
- m_ni_user_generator.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, this, hCalibrationCallbacks);
+ XnCallbackHandle hUserCallbacks, hCalibrationCallbacks, hPoseCallbacks;
+ m_ni_user_generator.RegisterUserCallbacks(User_NewUser, User_LostUser, this, hUserCallbacks);
+ m_ni_user_generator.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, this, hCalibrationCallbacks);
- if (m_ni_user_generator.GetSkeletonCap().NeedPoseForCalibration())
- {
- m_need_pose_to_calibrate = true;
- if (!m_ni_user_generator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
- ntk_throw_exception("Pose required, but not supported\n");
- m_ni_user_generator.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, this, hPoseCallbacks);
- m_ni_user_generator.GetSkeletonCap().GetCalibrationPose(m_calibration_pose);
- }
+ if (m_ni_user_generator.GetSkeletonCap().NeedPoseForCalibration())
+ {
+ m_need_pose_to_calibrate = true;
+ if (!m_ni_user_generator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
+ ntk_throw_exception("Pose required, but not supported\n");
+ m_ni_user_generator.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, this, hPoseCallbacks);
+ m_ni_user_generator.GetSkeletonCap().GetCalibrationPose(m_calibration_pose);
+ }
- m_ni_user_generator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
+ m_ni_user_generator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
+ }
if (m_body_event_detector)
m_body_event_detector->initialize(m_ni_context, m_ni_depth_generator);
@@ -315,7 +319,8 @@ void NiteRGBDGrabber :: run()
m_body_event_detector->update();
m_ni_depth_generator.GetMetaData(depthMD);
m_ni_rgb_generator.GetMetaData(rgbMD);
- m_ni_user_generator.GetUserPixels(0, sceneMD);
+ if (m_body_event_detector)
+ m_ni_user_generator.GetUserPixels(0, sceneMD);
const XnDepthPixel* pDepth = depthMD.Data();
ntk_assert((depthMD.XRes() == m_current_image.rawDepth().cols)
@@ -347,27 +352,29 @@ void NiteRGBDGrabber :: run()
}
}
- uchar* user_mask_ptr = m_current_image.userLabelsRef().ptr<uchar>();
- const XnLabel* pLabel = sceneMD.Data();
- for (int i = 0; i < sceneMD.XRes()*sceneMD.YRes(); ++i)
- {
- user_mask_ptr[i] = pLabel[i];
- }
-
- XnUserID user_ids[15];
- XnUInt16 num_users = 15;
- m_ni_user_generator.GetUsers(user_ids, num_users);
-
- // FIXME: only one user supported.
- for (int i = 0; i < num_users; ++i)
- {
- XnUserID user_id = user_ids[i];
- if (m_ni_user_generator.GetSkeletonCap().IsTracking(user_id))
- {
- m_current_image.skeletonRef()->computeJoints(user_id, m_ni_user_generator, m_ni_depth_generator);
- break;
- }
- }
+ if(m_body_event_detector){
+ uchar* user_mask_ptr = m_current_image.userLabelsRef().ptr<uchar>();
+ const XnLabel* pLabel = sceneMD.Data();
+ for (int i = 0; i < sceneMD.XRes()*sceneMD.YRes(); ++i)
+ {
+ user_mask_ptr[i] = pLabel[i];
+ }
+
+ XnUserID user_ids[15];
+ XnUInt16 num_users = 15;
+ m_ni_user_generator.GetUsers(user_ids, num_users);
+
+ // FIXME: only one user supported.
+ for (int i = 0; i < num_users; ++i)
+ {
+ XnUserID user_id = user_ids[i];
+ if (m_ni_user_generator.GetSkeletonCap().IsTracking(user_id))
+ {
+ m_current_image.skeletonRef()->computeJoints(user_id, m_ni_user_generator, m_ni_depth_generator);
+ break;
+ }
+ }
+ }
{
QWriteLocker locker(&m_lock);
View
@@ -229,8 +229,7 @@ int main(int argc, char **argv)
grabber.setHighRgbResolution(true);
// Start the grabber
- //grabber.setMaxUsers(0);
- //grabber.setBodyEventDetector(false);
+ grabber.setBodyEventDetector(false); //modded nite_rgbd_grabber to gt this to work x.x
grabber.initialize();
grabber.start();
@@ -242,11 +241,9 @@ int main(int argc, char **argv)
namedWindow("depth");
namedWindow("color");
- namedWindow("users");
namedWindow("custom");
cvSetMouseCallback("depth", customWindowMouseCallback);
cvSetMouseCallback("color", customWindowMouseCallback);
- cvSetMouseCallback("users", customWindowMouseCallback);
cvSetMouseCallback("custom", customWindowMouseCallback);
while (true)
@@ -257,31 +254,27 @@ int main(int argc, char **argv)
// Setup color image
cv::Mat3b debug_color_img;
image.mappedRgb().copyTo(debug_color_img);
+ //cv::Mat3b debug_color_img = image.mappedRgb(); //this doesn't work
// Setup depth image
cv::Mat1b raw_depth_img;
image.depth().copyTo(raw_depth_img);
+ //cv::Mat3b raw_depth_img = image.depth(); //this doesn't work
cv::Mat1b debug_depth_img = normalize_toMat1b(raw_depth_img);
- // Setup users image
- //(this appears to be the built-in person detection in nite_rgbd_grabber.cpp)
- cv::Mat3b debug_users;
- image.fillRgbFromUserLabels(debug_users);
-
// Setup custom image
// We'll use this for our DoF processing =]
cv::Mat3b custom_img = customProcessing(debug_color_img, raw_depth_img);
- renderedGaussians.clear();
+ renderedGaussians.clear(); //meh, this shouldn't be done here... =/
// DEBUGGING / EXPERIMENTATION
- findMinAndMaxAndNumberOfUniques(raw_depth_img);
+ //findMinAndMaxAndNumberOfUniques(raw_depth_img);
// Show images =]
imshow("depth", debug_depth_img);
imshow("color", debug_color_img);
- imshow("users", debug_users);
imshow("custom", custom_img);
- if(cv::waitKey(10)==' '){
+ if(cv::waitKey(2)==' '){
cv::imwrite("color.tif", debug_color_img);
cv::imwrite("depth.tif", raw_depth_img);
cv::imwrite("custom.tif", custom_img);

0 comments on commit 00e06e1

Please sign in to comment.