This repository was archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 630
Fixing point cloud transformation bug with using uint16 when int16 sh… #1568
Merged
jaygullapalli
merged 4 commits into
microsoft:develop
from
JonathanESantos:FixPointCloudTransformationBug1556
Apr 27, 2021
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
027a12b
Fixing point cloud transformation bug with using uint16 when int16 sh…
JonathanESantos 8e39a7d
Adding a newline to avoid a warning or no new line at the end of the …
JonathanESantos 5f33e61
Replacing point cloud example to use numpy reshape.
JonathanESantos 25c8748
Fixing example point_cloud_capture.py with getting the numpy array sh…
JonathanESantos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Fixing point cloud transformation bug with using uint16 when int16 sh…
…ould be used because the X and Y images are centered around 0 and can take on negative values. Adding point_cloud_capture.py example to capture depth data, transform to point cloud, and write to text file which can then be opened with a 3D modeling application like MeshLab.
- Loading branch information
commit 027a12b6d7dcb9357c6078c88569172bc0b6e59f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import numpy as np | ||
| import k4a | ||
|
|
||
| if __name__ == '__main__': | ||
| # Open Device | ||
| device = k4a.Device.open() | ||
|
|
||
| # Start Cameras | ||
| device_config = k4a.DEVICE_CONFIG_BGRA32_1080P_NFOV_UNBINNED_FPS15 | ||
| device.start_cameras(device_config) | ||
|
|
||
| # Get Calibration | ||
| calibration = device.get_calibration( | ||
| depth_mode=device_config.depth_mode, | ||
| color_resolution=device_config.color_resolution) | ||
|
|
||
| # Create Transformation | ||
| transformation = k4a.Transformation(calibration) | ||
|
|
||
| # Capture One Frame | ||
| capture = device.get_capture(-1) | ||
|
|
||
| # Get Point Cloud | ||
| xyz_image = transformation.depth_image_to_point_cloud(capture.depth, k4a.ECalibrationType.DEPTH) | ||
|
|
||
| # Save Point Cloud To Ascii Format File. Interleave the [X, Y, Z] channels into [x0, y0, z0, x1, y1, z1, ...] | ||
| width, height, channels = xyz_image.data.shape | ||
| xyz_data = np.empty((width * height, channels,), dtype=xyz_image.data.dtype) | ||
JonathanESantos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| xyz_data[:,0] = xyz_image.data[:,:,0].reshape(width*height) | ||
| xyz_data[:,1] = xyz_image.data[:,:,1].reshape(width*height) | ||
| xyz_data[:,2] = xyz_image.data[:,:,2].reshape(width*height) | ||
|
|
||
| np.savetxt('data.txt', xyz_data, delimiter=' ', fmt='%u') # save ascii format (x y z\n x y z\n x y z\n ...) | ||
|
|
||
| # Stop Cameras | ||
| device.stop_cameras() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| setup( | ||
| name='k4a', | ||
| version='0.0.1', | ||
| version='0.0.2', | ||
| author='Jonathan Santos', | ||
| author_email='[email protected]', | ||
| description='Python interface to Azure Kinect API.', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.