Ask Your Question
-2

Kinect Depth calculation [closed]

asked 2011-06-07 20:44:06 -0500

lakshmen gravatar image

updated 2016-10-24 09:03:01 -0500

ngrennan gravatar image

Sorry guys, i am desperate for answer. That is why i didn't follow the rules of this website. I sincerly apologise. For this code, i have come up with a better one. float cx = 320.0; float cy = 240.0; float minDistance = -10; float scaleFactor = 0.0021;

for (int v=0, n=0 ; v<480 ; v++) 
    {
        for (int u=0 ; u<640 ; u++, n++)
        {
                Vec3f result;
                result.x = float(((u - cx) * t_gamma[depth[n]]+ minDistance)   * scaleFactor * (cx/cy));
                result.y = float(((v - cy) * t_gamma[depth[n]]+ minDistance)   * scaleFactor);
                result.z = float(t_gamma[depth[n]]);


        }

    }   


// OS X requires GLUT to run on the main thread
gl_threadfunc(NULL);


return 0;

} is this code better? i have tried to save the depth data but all the data is zero. I don't know where is the problem?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by Wim
close date 2011-08-02 11:26:49

Comments

Why do you want to do this yourself? Is it an exercise or are you interested in the results. For the latter I would highly recommend using the openni_camera node as it already gives your 3D data.
dornhege gravatar image dornhege  ( 2011-06-08 22:59:27 -0500 )edit
I am an intern in a company and i was asked to do this... Using the OpenKinect.
lakshmen gravatar image lakshmen  ( 2011-06-09 10:08:18 -0500 )edit
I would really appreciate any help provided...
lakshmen gravatar image lakshmen  ( 2011-06-09 10:15:37 -0500 )edit
If your depth data is zero, the code above is probably not the problem. Does OpenKinect provide samples? Then use those, otherwise you can still use the ROS node, remove the ROS stuff and use it for yourself (respecting the license of course).
dornhege gravatar image dornhege  ( 2011-06-09 23:14:38 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-06-08 00:08:21 -0500

KoenBuys gravatar image

This message is double posted see original one HERE

edit flag offensive delete link more

Comments

It's not really the original. That link was another question before (and should probably be returned to its original question).
dornhege gravatar image dornhege  ( 2011-06-08 00:39:46 -0500 )edit
0

answered 2011-06-10 00:11:00 -0500

dornhege gravatar image

As I was just skimming through the code. This is what openni_camera does:

for (int v = 0; v < (int)cloud_msg->height; ++v, depth_idx += depthSkip)
{
  for (int u = 0; u < (int)cloud_msg->width; ++u, depth_idx += depthStep, ++pt_iter)
  {
    pcl::PointXYZ& pt = *pt_iter;

    // Check for invalid measurements
    if (depth_md[depth_idx] == 0 ||
        depth_md[depth_idx] == depth.getNoSampleValue () ||
        depth_md[depth_idx] == depth.getShadowValue ())
    {
      // not valid
      pt.x = pt.y = pt.z = bad_point;
      continue;
    }

    // Fill in XYZ
    pt.x = (u - centerX) * depth_md[depth_idx] * constant;
    pt.y = (v - centerY) * depth_md[depth_idx] * constant;
    pt.z = depth_md[depth_idx] * 0.001;
  }
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-06-07 20:44:06 -0500

Seen: 493 times

Last updated: Jun 10 '11