Skip to content

Commit

Permalink
Updating to the latest release (#65)
Browse files Browse the repository at this point in the history
* Adding 3.30 Tappas
Added CI Fix

* Add Rpi Check Test

* Documentation Update
  • Loading branch information
OmriAx authored Nov 18, 2024
1 parent fb222cc commit 1da9f97
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 15 deletions.
4 changes: 4 additions & 0 deletions doc/install-raspberry-pi5.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ sudo apt update
sudo apt full-upgrade
```
This will update your system to the latest Raspberry Pi kernel, which includes Hailo driver support.
If you get errors from the `apt full-upgrade` command try running this and retry.
```bash
sudo apt --fix-broken install
```

### Set PCIe to Gen3
To achieve optimal performance from the Hailo device, it is necessary to set PCIe to Gen3. While using Gen2 is an option, it will result in lower performance.
Expand Down
21 changes: 9 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/bin/bash

# Ensure the repository is cloned and you're in the correct directory
# Uncomment if you haven't cloned it yet
#git clone https://github.com/hailo-ai/hailo-rpi5-examples.git

# Enter the repository directory
#cd hailo-rpi5-examples || exit

# Source environment variables and activate virtual environment
source setup_env.sh

Expand All @@ -16,12 +9,16 @@ pip install -r requirements.txt
pip install -r tests/test_resources/requirements.txt

# Install additional system dependencies (if needed)
sudo apt install -y rapidjson-dev v4l-utils
sudo apt install -y rapidjson-dev

# Check if the --all flag is provided
DOWNLOAD_RESOURCES_FLAG=""
if [[ "$1" == "--all" ]]; then
DOWNLOAD_RESOURCES_FLAG="--all"
fi

# Download resources needed for the pipelines
./download_resources.sh
./download_resources.sh $DOWNLOAD_RESOURCES_FLAG

# Optional: Post-process compilation (Only for older TAPPAS versions)
./compile_postprocess.sh


./compile_postprocess.sh
4 changes: 2 additions & 2 deletions setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# TAPPAS CORE Definitions
CORE_VENV_NAME="venv_hailo_rpi5_examples"
CORE_REQUIRED_VERSION=("3.28.2" "3.29.1")
CORE_REQUIRED_VERSION=("3.29.1" "3.30.0")

# TAPPAS Definitions
TAPPAS_VENV_NAME="hailo_tappas_venv"
TAPPAS_REQUIRED_VERSION=("3.28.0" "3.28.1" "3.28.2" "3.29.0" "3.29.1")
TAPPAS_REQUIRED_VERSION=("3.29.0" "3.29.1" "3.30.0")

# Function to check if the script is being sourced
is_sourced() {
Expand Down
95 changes: 94 additions & 1 deletion tests/test_hailo_rpi5_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@

TEST_RUN_TIME = 10

def test_rpi_camera_connection():
"""Test if RPI camera is connected by running rpicam-hello."""
log_dir = "logs"
os.makedirs(log_dir, exist_ok=True)
log_file_path = os.path.join(log_dir, "rpi_camera_test.log")

with open(log_file_path, "w") as log_file:
process = subprocess.Popen(
['rpicam-hello', '-t', '0', '--post-process-file', '/usr/share/rpi-camera-assets/hailo_yolov6_inference.json'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

try:
time.sleep(TEST_RUN_TIME)
process.send_signal(signal.SIGTERM)
process.wait(timeout=5)
except subprocess.TimeoutExpired:
process.kill()
pytest.fail(f"RPI camera connection test could not be terminated within 5 seconds after running for {TEST_RUN_TIME} seconds")

stdout, stderr = process.communicate()
log_file.write(f"rpi_camera stdout:\n{stdout.decode()}\n")
log_file.write(f"rpi_camera stderr:\n{stderr.decode()}\n")

# Check for the specific error message
if "ERROR: *** no cameras available ***" in stderr.decode():
pytest.fail("RPI camera is not connected")
else:
log_file.write("RPI camera is connected and working.\n")
log_file.write("Test completed successfully.\n")



def get_device_architecture():
"""Get the device architecture from hailortcli."""
try:
Expand Down Expand Up @@ -308,5 +340,66 @@ def test_detection_retraining():
assert "Traceback" not in stderr.decode(), f"Detection with retrained model (video input) encountered an exception: {stderr.decode()}"
assert "Error" not in stderr.decode(), f"Detection with retrained model (video input) encountered an error: {stderr.decode()}"

# def test_pipeline_with_use_frame():
# """
# Combined test function for pipelines with the --use-frame flag, using a camera as the input source.
# """
# TEST_RUN_TIME = 10 # Run time set to 10 seconds
# log_dir = "logs"
# os.makedirs(log_dir, exist_ok=True)
# pipeline_list = get_pipelines_list()

# # Set the camera input source (update this based on your camera type)
# camera_input = "/dev/video0" # USB camera example; use "rpi" if it's a Raspberry Pi camera

# for pipeline in pipeline_list:
# # Set up logging for each pipeline
# log_file_path = os.path.join(log_dir, f"{pipeline}_use_frame_camera_test.log")
# with open(log_file_path, "w") as log_file:
# cmd = ['python', f'basic_pipelines/{pipeline}', '--use-frame', '--input', camera_input]

# # Start the process
# process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# logging.info(f"Running {pipeline} with --use-frame flag using camera input")

# try:
# # Let the process run for the specified test time
# time.sleep(TEST_RUN_TIME)

# # Attempt to terminate the process
# process.send_signal(signal.SIGTERM)

# try:
# # Wait for process to exit and capture output within a timeout
# stdout, stderr = process.communicate(timeout=5)
# except subprocess.TimeoutExpired:
# # If process does not terminate, kill it
# process.kill()
# stdout, stderr = process.communicate()
# pytest.fail(f"{pipeline} with --use-frame flag could not be terminated within 5 seconds after running for {TEST_RUN_TIME} seconds")

# # Decode outputs
# stdout_str, stderr_str = stdout.decode(), stderr.decode()

# # Write output to log file
# log_file.write(f"{pipeline} with --use-frame flag stdout:\n{stdout_str}\n")
# log_file.write(f"{pipeline} with --use-frame flag stderr:\n{stderr_str}\n")

# # Assertions to check for errors in stderr and expected output in stdout
# assert "Traceback" not in stderr_str, f"{pipeline} with --use-frame flag encountered an exception: {stderr_str}"
# assert "Error" not in stderr_str, f"{pipeline} with --use-frame flag encountered an error: {stderr_str}"
# assert "frame" in stdout_str.lower(), f"{pipeline} with --use-frame flag did not process any frames"
# assert "detection" in stdout_str.lower(), f"{pipeline} with --use-frame flag did not make any detections"

# # Log that the test completed successfully for this pipeline
# log_file.write(f"{pipeline} with --use-frame flag test passed: completed without errors.\n")
# logging.info(f"{pipeline} with --use-frame flag test completed successfully.")

# except Exception as e:
# # Ensure any exceptions are logged before failing
# logging.error(f"Error occurred in test for {pipeline} with --use-frame flag: {e}")
# pytest.fail(f"Test for {pipeline} with --use-frame flag failed due to unexpected error: {e}")


if __name__ == "__main__":
pytest.main(["-v", __file__])
pytest.main(["-v", __file__])

0 comments on commit 1da9f97

Please sign in to comment.