-
Notifications
You must be signed in to change notification settings - Fork 64
RSDK-1623 - decode custom depth mime type #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
purplenicole730
merged 11 commits into
viamrobotics:main
from
purplenicole730:RSDK-1623-decode-custom-depth-mime-type
May 12, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8fc4b0d
add bytes_to_depth_array function
purplenicole730 a63c1db
add tests
purplenicole730 f29be26
Add documentation
purplenicole730 847fdef
make comment clearer
purplenicole730 b878bb2
clean test
purplenicole730 c7d9f7d
Clean up function comment
purplenicole730 5c556e2
move fake image into a data folder
purplenicole730 8e6680a
Update src/viam/components/camera/camera.py
purplenicole730 7634f9a
move test to new test_media.py
purplenicole730 8cdfaf8
return a list of lists
purplenicole730 93e45c6
make tests more explicit
purplenicole730 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
There are no files selected for viewing
Binary file not shown.
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
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,23 @@ | ||
from array import array | ||
import os | ||
import pytest | ||
|
||
from viam.media.video import RawImage | ||
|
||
|
||
class TestRawImage: | ||
@pytest.mark.asyncio | ||
async def test_bytes_to_depth_array(self): | ||
with open(f"{os.path.dirname(__file__)}/../data/fakeDM.vnd.viam.dep", "rb") as depth_map: | ||
image = RawImage(depth_map.read(), "image/vnd.viam.dep") | ||
assert isinstance(image, RawImage) | ||
standard_data = image.bytes_to_depth_array() | ||
assert len(standard_data) == 10 | ||
assert len(standard_data[0]) == 20 | ||
data_arr = array("H", image.data[24:]) | ||
data_arr.byteswap() | ||
assert len(data_arr) == 200 | ||
assert standard_data[0][0] == data_arr[0] | ||
assert standard_data[-1][3] == data_arr[183] | ||
assert standard_data[-1][3] == 9 * 3 | ||
assert standard_data[4][4] == 4 * 4 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised you dont specify the endianness of these unsigned shorts but you do for the other values.