Skip to content

Commit

Permalink
renamed container folder, WIP devcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan-Datta committed Oct 18, 2024
1 parent 9b7b324 commit 15596cd
Show file tree
Hide file tree
Showing 36 changed files with 195 additions and 46 deletions.
52 changes: 52 additions & 0 deletions .devcontainer/ROS/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive \
LANGUAGE=en_US:en \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8

RUN apt-get update && apt-get install -y \
sudo \
python3.10 \
dos2unix \
git \
python3-pip \
xauth \
apt-utils \
dialog \
libnss3-tools \
libx11-dev \
git \
xz-utils \
zip \
unzip \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY ./scripts /scripts

RUN dos2unix /scripts/*.sh

RUN /scripts/install-build-essential.sh
RUN /scripts/install-cmake.sh
RUN /scripts/install-ros2.sh

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create and switch to user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME --shell /bin/bash \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Set the default user to vscode
USER $USERNAME

# Create workspace so that user own this directory
RUN mkdir -p /home/$USERNAME/workspace
WORKDIR /home/$USERNAME/workspace

ENTRYPOINT ["/bin/bash"]

28 changes: 28 additions & 0 deletions .devcontainer/ROS/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "ROS2 Dev Container",
"remoteUser": "vscode",
"build": {
"dockerfile": "Dockerfile",
"args": {
"USERNAME": "vscode",
"USER_GID": "1000",
"USER_UID": "1000"
}
},
// "image": "agrobotappliedai/devcontainers:ros2",
"customizations":{
"settings": {
"terminal.integrated.shell.linux": "bash"
}
},
"workspaceFolder": "/home/vscode/workspace",
"workspaceMount": "source=.,target=/home/vscode/workspace,type=bind,consistency=cached",
"mounts": [],
"runArgs": [
"--net=host",
"-it"
// "--privileged"
// "--display later"
],
"postCreateCommand": "bash -c 'echo source /opt/ros/humble/setup.bash >> ~/.bashrc && source /opt/ros/humble/setup.bash'"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions Containers/Jetson-Main.Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions Containers/ROS-Base.Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions actions_scripts/Python Unit Tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import numpy as np
from my_package.bbox_node import BBoxNode

# get outputs of ultralytics and assert function diff between ultralytics and module vlaue is less than 0.5%
# unit tests for also length of list (object count)

def calculate_iou(boxA, boxB):
"""
Calculate the Intersection over Union (IoU) between two bounding boxes.
Expand Down
8 changes: 4 additions & 4 deletions calibration_tools/roi_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def print_camera_information(cam):
print("Serial number: {0}.\n".format( cam.get_camera_information().serial_number))

def initialize_image_source(source_type="static_image", image_path='C:/Users/ishaa/Coding Projects/Applied-AI/ROS/assets/maize'):
def initialize_image_source(source_type="static_image", image_path='C:/Users/ishaa/Coding Projects/ROS/assets/maize'):
if source_type == "static_image":
if not os.path.exists(image_path):
raise ValueError(f"Images folder not found at {image_path}")
Expand Down Expand Up @@ -120,7 +120,7 @@ def retrieve_zed_image(cam, orientation="left"):

return image, velocity[0]

def roi_calibrator(source_type="static_image", images_path='C:/Users/ishaa/Coding Projects/Applied-AI/ROS/assets/maize'):
def roi_calibrator(source_type="static_image", images_path='C:/Users/Ishaan/Coding Projects/Applied-AI/ROS/assets/maize'):
global roi_x, roi_y, roi_w, roi_h, shift_constant, velocity
image_source = initialize_image_source(source_type, images_path)
if source_type == "zed_double":
Expand Down Expand Up @@ -233,5 +233,5 @@ def onTrack6(val):
parser.add_argument('--source_type', type=str, required=False, help='Type of image source (static_image, zed_single, zed_double)')
parser.add_argument('--images_path', type=str, required=False, help='Path to the folder of calibration images')
args = parser.parse_args()
# roi_calibrator(args.source_type, args.images_path)
roi_calibrator()
roi_calibrator(args.source_type, args.images_path)
# roi_calibrator()
7 changes: 0 additions & 7 deletions Containers/CPU.Dockerfile → instrumentation/CPU.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Use an official Python runtime as a parent image
FROM python:3.10-slim-buster

# Set environment variables to prevent prompts during package installations
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
Expand All @@ -22,10 +19,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Upgrade pip
RUN python3 -m pip install --upgrade pip

# Install CPU-only Python packages
RUN pip3 install --upgrade --no-cache-dir --verbose \
numpy \
wandb \
Expand All @@ -40,8 +35,6 @@ RUN pip3 install --upgrade --no-cache-dir --verbose \
tensorflow-cpu-aws \
torch --extra-index-url https://download.pytorch.org/whl/cpu

# Expose port for Jupyter Notebook
EXPOSE 8888

# Set the default command to run jupyter notebook
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"]
9 changes: 1 addition & 8 deletions Containers/GPU.Dockerfile → instrumentation/GPU.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Use an official NVIDIA runtime image with CUDA
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu20.04

# Set environment variables to prevent prompts during package installations
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
Expand All @@ -27,11 +24,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Upgrade pip
RUN python3 -m pip install --upgrade pip

# Install CUDA-enabled Python packages
RUN pip install --no-cache-dir \
RUN pip install --upgrade --no-cache-dir --verbose \
numpy \
scipy \
scikit-learn \
Expand All @@ -53,8 +48,6 @@ RUN pip install --no-cache-dir \
torch-tensorrt \
tensorrt

# Expose port for Jupyter Notebook
EXPOSE 8888

# Set the default command to run shell
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions instrumentation/scripts/install-build-essential.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -ex

echo 'installing build-essential'

apt -y update && apt -y upgrade
apt-get install -y --no-install-recommends \
build-essential \
software-properties-common \
apt-transport-https \
ca-certificates \
lsb-release \
pkg-config \
gnupg \
git \
gdb \
wget \
curl \
nano \
zip \
unzip \
time \
sshpass \
ssh-client
apt-get clean
rm -rf /var/lib/apt/lists/*
gcc --version
g++ --version
15 changes: 15 additions & 0 deletions instrumentation/scripts/install-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -ex

echo 'installing cmake'

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null
apt-get update
rm /usr/share/keyrings/kitware-archive-keyring.gpg
apt-get install -y --no-install-recommends kitware-archive-keyring
apt-cache policy cmake
apt-get install -y --no-install-recommends cmake
rm -rf /var/lib/apt/lists/*
apt-get clean
cmake --version
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions instrumentation/scripts/install-ros2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -ex

echo 'installing ros2'

locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

apt-get update
apt-get install -y --no-install-recommends \
gnupg2 \
lsb-release \
ca-certificates \
locales \
software-properties-common \

add-apt-repository universe
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
apt-get update && apt upgrade -y
apt install ros-humble-ros-base python3-argcomplete ros-dev-tools -y
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source /opt/ros/humble/setup.bash
printenv | grep -i ROS

apt-get install -y --no-install-recommends \

rm -rf /var/lib/apt/lists/*
apt-get clean
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions python_wip/ultralytics_poc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from ultralytics import YOLO
import cv2

# Define ROI (Region of Interest) as (x_min, y_min, x_max, y_max)
roi = (100, 100, 800, 800)
roi_x1, roi_y1, roi_x2, roi_y2 = roi

# Load the pre-trained YOLO model
model = YOLO('C:/Users/ishaa/Coding Projects/ROS/models/maize/Maize.pt')

# Load the image
image = cv2.imread('C:/Users/ishaa/Coding Projects/ROS/assets/maize/IMG_1822_14.JPG')

# Make predictions on the image
results = model(image)
result = results[0]

print("Bounding boxes:")
boxes = result.boxes.xyxy # xyxy format: [x_min, y_min, x_max, y_max]

for box in boxes:
print(box)
x_min, y_min, x_max, y_max = box.tolist()

if x_min >= roi_x1 and x_max <= roi_x2 and y_min >= roi_y1 and y_max <= roi_y2:
print(1)

cv2.rectangle(image, (int(x_min), int(y_min)), (int(x_max), int(y_max)), (0, 255, 0), 2)

cv2.rectangle(image, (roi_x1, roi_y1), (roi_x2, roi_y2), (255, 0, 0), 2)

cv2.imshow("Image with ROI", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

# scaling color filter bbox output -> can get cropped images from ultralytics API

0 comments on commit 15596cd

Please sign in to comment.