-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Replace {issue_number} with the issue that will be closed after merging this PR --> Fixes #23 ## Type of change <!-- Write an `x` in all the boxes that apply --> - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
- Loading branch information
1 parent
14724a3
commit cfb59f7
Showing
11 changed files
with
1,264 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains 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 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 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,11 @@ | ||
# Holoscan utility scripts | ||
|
||
We have few examples on how to use `convert_video_to_gxf_entities.py` [here](../../data/polyp-dataset/README.md). | ||
For further details see references. | ||
|
||
## References | ||
https://github.com/nvidia-holoscan/holoscan-sdk/tree/main/scripts#convert_video_to_gxf_entitiespy | ||
https://docs.nvidia.com/holoscan/sdk-user-guide/gxf/gxf_by_example.html | ||
https://docs.nvidia.com/clara-holoscan/archive/clara-holoscan-0.3.0/gxf/index.html | ||
|
||
|
62 changes: 62 additions & 0 deletions
62
nvidia-clara-agx/holoscan-sdk-scripts/convert_video_to_gxf_entities.py
This file contains 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,62 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import sys | ||
|
||
import numpy as np | ||
from gxf_entity_codec import EntityWriter | ||
|
||
|
||
def iter_input_frames(f, width, height, channels): | ||
frame_byte_count = width * height * channels | ||
while True: | ||
frame_bytes = f.read(frame_byte_count) | ||
if len(frame_bytes) != frame_byte_count: | ||
break | ||
array = np.frombuffer(frame_bytes, np.uint8) | ||
frame = array.reshape(height, width, channels) | ||
yield frame | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description=( | ||
"Command line utility for writing raw video frames in GXF Tensors for " | ||
"stream playback." | ||
) | ||
) | ||
parser.add_argument("--width", required=True, type=int, help="Input width in pixels") | ||
parser.add_argument("--height", required=True, type=int, help="Input height in pixels") | ||
parser.add_argument("--channels", default=3, type=int, help="Channel count") | ||
parser.add_argument("--framerate", default=30, type=int, help="Output frame rate") | ||
parser.add_argument("--basename", default="tensor", help="Basename for gxf entities to write") | ||
parser.add_argument("--directory", default="./", help="Directory for gxf entities to write") | ||
args = parser.parse_args() | ||
|
||
with EntityWriter( | ||
directory=args.directory, basename=args.basename, framerate=args.framerate | ||
) as recorder: | ||
for frame in iter_input_frames( | ||
sys.stdin.buffer, | ||
width=args.width, | ||
height=args.height, | ||
channels=args.channels, | ||
): | ||
recorder.add(frame) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.