Vectorizing the Kinect real-world coordinate processing algorithm for speed

前端 未结 1 1918
误落风尘
误落风尘 2021-02-02 17:45

I recently started working with the Kinect V2 on Linux with pylibfreenect2.

When I first was able to show the depth frame data in a scatter plot I was disappointed to se

相关标签:
1条回答
  • 2021-02-02 18:02

    This isn't intended to be a complete answer... I just wanted to point out that you are creating a lot of temporary arrays, where you could do more of the operations in-place:

    def depthMatrixToPointCloudPos2(z, scale=1000):
    
        R, C = numpy.indices(z.shape)
    
        R -= CameraParams['cx'])
        R *= z
        R /= CameraParams['fx'] * scale
    
        C -= CameraParams['cy']
        C *= z
        C /= CameraParams['fy'] * scale
    
        return np.column_stack((z.ravel() / scale, R.ravel(), -C.ravel()))
    

    (If I read your code correctly.)

    Also, note the data types, which if you are on a 64-bit machine, will be 64-bit by default. Can you get away with smaller types, to cut down on the amount of data to crunch?

    0 讨论(0)
提交回复
热议问题