Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
hilary-luo committed Oct 5, 2024
1 parent 170ab9f commit a0494cc
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 272 deletions.
23 changes: 2 additions & 21 deletions turtlebot4_vision_tutorials/launch/pose_detection.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#
# @author Hilary Luo ([email protected])

# from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions.declare_launch_argument import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
Expand All @@ -25,38 +24,20 @@

def generate_launch_description():
namespace = LaunchConfiguration('namespace')
# ffmpeg_param_file = LaunchConfiguration('ffmpeg_param_file')

# turtlebot4_vision_tutorials = get_package_share_directory('turtlebot4_vision_tutorials')

# arg_parameters = DeclareLaunchArgument(
# 'ffmpeg_param_file',
# default_value=PathJoinSubstitution(
# [turtlebot4_vision_tutorials, 'config', 'ffmpeg.yaml']),
# description='Turtlebot4 ffmpeg compression param file'
# )

arg_namespace = DeclareLaunchArgument(
'namespace',
default_value='')

# parameters = RewrittenYaml(
# source_file=ffmpeg_param_file,
# root_key=namespace,
# param_rewrites={},
# convert_types=True)

ffmpeg_node = Node(
pose_node = Node(
package='turtlebot4_vision_tutorials',
executable='pose_detection',
namespace=namespace,
name='pose_detection',
# parameters=[parameters],
)

ld = LaunchDescription()
# ld.add_action(arg_parameters)
ld.add_action(arg_namespace)
ld.add_action(ffmpeg_node)
ld.add_action(pose_node)

return ld
17 changes: 0 additions & 17 deletions turtlebot4_vision_tutorials/launch/video_decode.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ def generate_launch_description():
'namespace',
default_value='')

parameters = {
"/cpr_donatello/ffmpeg_decoder": {
"ros__parameters": {
"qos_overrides": {
"/cpr_donatello/oakd/rgb/preview/encoded/ffmpeg": {
"subscriber": {
"reliability": "best_effort",
"depth": 10,
"history": "keep_last"
}
}
}
}
}
}

ffmpeg_node = Node(
package='image_transport',
executable='republish',
Expand All @@ -55,7 +39,6 @@ def generate_launch_description():
('out', "oakd/rgb/preview/ffmpeg_decoded"),
],
arguments=['ffmpeg', 'raw'],
parameters=[parameters],
)

ld = LaunchDescription()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Source: https://github.com/geaxgx/depthai_movenet/
# Adapted by: Hilary Luo ([email protected])

# Original source license:

# MIT License

# Copyright (c) [2021] [geax]

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
This file is the template of the scripting node source code in edge mode
Substitution is made in MovenetDepthaiEdge.py
Expand Down
56 changes: 0 additions & 56 deletions turtlebot4_vision_tutorials/turtlebot4_vision_tutorials/FPS.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Source: https://github.com/geaxgx/depthai_movenet/
# Adapted by: Hilary Luo ([email protected])

# Original source license:

# MIT License

# Copyright (c) [2021] [geax]

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from collections import namedtuple
from math import gcd
import numpy as np
Expand All @@ -8,8 +35,6 @@
import depthai as dai
import marshal

from turtlebot4_vision_tutorials.FPS import FPS

from ament_index_python.packages import get_package_share_directory

SHARE_DIR = get_package_share_directory('turtlebot4_vision_tutorials')
Expand Down Expand Up @@ -138,7 +163,6 @@ class MovenetDepthai:
- internal_frame_height : when using the internal color camera, set the frame height
(calling setIspScale()). The width is calculated accordingly to
height and depends on value of 'crop'
- stats : True or False, when True, display the global FPS when exiting.
"""
def __init__(self,
input_src="rgb",
Expand All @@ -147,8 +171,7 @@ def __init__(self,
crop=False,
smart_crop=True,
internal_fps=None,
internal_frame_height=640,
stats=True):
internal_frame_height=640):

self.model = model

Expand All @@ -166,14 +189,12 @@ def __init__(self,
self.pd_input_length = 256
print(f"Using blob file : {self.model}")

print(f"MoveNet imput size : {self.pd_input_length}x{self.pd_input_length}x3")
print(f"MoveNet input size : {self.pd_input_length}x{self.pd_input_length}x3")

self.score_thresh = score_thresh

self.crop = crop
self.smart_crop = smart_crop
self.internal_fps = internal_fps
self.stats = stats

if input_src is None or input_src == "rgb" or input_src == "rgb_laconic":
self.input_type = "rgb" # OAK* internal color camera
Expand Down Expand Up @@ -223,15 +244,8 @@ def __init__(self,
if not self.laconic:
self.q_video = self.device.getOutputQueue(name="cam_out", maxSize=1, blocking=False)
self.q_processing_out = self.device.getOutputQueue(name="processing_out",
maxSize=4,
maxSize=1,
blocking=False)
# For debugging
# self.q_manip_out=self.device.getOutputQueue(name="manip_out", maxSize=1, blocking=False)

self.fps = FPS()

self.nb_frames = 0
self.nb_pd_inferences = 0

def create_pipeline(self):
print("Creating pipeline...")
Expand Down Expand Up @@ -349,14 +363,11 @@ def pd_postprocess(self, inference):
return body

def next_frame(self):
self.fps.update()

# Get the device camera frame if wanted
if self.laconic:
frame = np.zeros((self.frame_size, self.frame_size, 3), dtype=np.uint8)
else:
in_video = self.q_video.get()
frame = in_video.getCvFrame()
frame = self.q_video.get().getCvFrame()

# For debugging
# manip = self.q_manip_out.get().getCvFrame()
Expand All @@ -367,16 +378,4 @@ def next_frame(self):
body = self.pd_postprocess(inference)
self.crop_region = body.next_crop_region

size = (in_video.getWidth(), in_video.getHeight())

# Statistics
if self.stats:
self.nb_frames += 1
self.nb_pd_inferences += 1

return frame, body, size

def exit(self):
# Print some stats
if self.stats:
print(f"FPS: {self.fps.global_duration():.1f} f/s (# frames = {self.fps.nb_frames()})")
return frame, body

This file was deleted.

Loading

0 comments on commit a0494cc

Please sign in to comment.