From 802dc6bb418ac6a8dc8ed9750f898eb25b94c4f1 Mon Sep 17 00:00:00 2001 From: Russell Land Date: Tue, 26 Mar 2024 00:31:59 -0400 Subject: [PATCH 1/2] fix brightness levels and organize issues with run/stop scripts --- .gitignore | 2 +- README.md | 1 + app/collect_data.py | 1 + app/main.py | 1 + run.sh | 12 +++++++----- stop.sh | 31 +++++++++++++++++++++++++------ 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 7e16fcc..d07ab73 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ stream-*.ts *.plan data/ .process.pid -nohup.out +.log.out .stream_env ### Linux ### diff --git a/README.md b/README.md index 76b4787..9bd95e1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This application will ingest your computers camera feed, apply an object detecti * Docker and the compose plugin * At least 4GB of RAM * Camera, at least 720p recommended + * Your camera might require a driver installation before it can be used. If you have an ArduCam (I tested this on a IMX519 16MP ArduCam) the driver installation and camera packages can be installed [here](https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/Quick-Start-Guide/). # Prerequisites There are a couple of recommended and required steps before you can run this application. diff --git a/app/collect_data.py b/app/collect_data.py index 3464c2e..1fa4367 100644 --- a/app/collect_data.py +++ b/app/collect_data.py @@ -91,6 +91,7 @@ def main( transform=Transform(hflip=1, vflip=1), controls={"FrameDurationLimits": (duration, duration)} )) + camera.controls.Brightness = 0.2 camera.start() try: diff --git a/app/main.py b/app/main.py index d4511ae..5882f0a 100644 --- a/app/main.py +++ b/app/main.py @@ -308,6 +308,7 @@ def main( }, transform=Transform(hflip=1, vflip=1) )) + camera.controls.Brightness = 0.2 process = subprocess.Popen(command, stdin=subprocess.PIPE) diff --git a/run.sh b/run.sh index 534b484..f2d6e06 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,10 @@ if [ "${OBJECT_DETECTION}" == "True" ]; then response=$(curl --write-out "%{http_code}" --silent --output /dev/null "$url") if [ $response -eq 200 ]; then - echo "Triton is healthy, starting holly-stream." + echo "Triton is starting (STATUS: HEALTHY). Success!" break else - echo "Triton is not healthy yet, trying again in $INTERVAL seconds. Attempt $ATTEMPT/$RETRIES" + echo "Triton is starting (STATUS: UNHEALTHY). Trying again in $INTERVAL seconds. Attempt $ATTEMPT/$RETRIES" ATTEMPT=$((ATTEMPT + 1)) sleep $INTERVAL fi @@ -28,7 +28,8 @@ if [ "${OBJECT_DETECTION}" == "True" ]; then exit 120 fi - nohup $PWD/.stream_env/bin/python3 app/main.py & + echo "Holly-stream started." + nohup $PWD/.stream_env/bin/python3 app/main.py > .log.out & echo $! > .process.pid elif [ "${OBJECT_DETECTION}" == "False" ]; then @@ -52,6 +53,7 @@ elif [ "${OBJECT_DETECTION}" == "False" ]; then --width $CAMERA_WIDTH \ --height $CAMERA_HEIGHT \ --rotation 180 \ + --brightness 0.2 \ --listen -o - | \ ffmpeg \ -i - \ @@ -68,8 +70,8 @@ elif [ "${OBJECT_DETECTION}" == "False" ]; then EOF ) - nohup sh -c "$stream_command" & - echo $! > .process.pid + echo "Holly-stream started." + nohup sh -c "$stream_command" > .log.out & else echo "Invalid input for OBJECT_DETECTION. Expecting True or False; received ${OBJECT_DETECTION}." diff --git a/stop.sh b/stop.sh index ec027f9..6f61345 100755 --- a/stop.sh +++ b/stop.sh @@ -1,8 +1,27 @@ #!/bin/bash -docker compose down -echo "Stopped Triton and other Docker services if they were running." +source .env -pid=$(cat .process.pid) -kill "$(($pid + 3))" -rm .process.pid nohup.out -echo "Stopped holly-stream." +if [ -z $OBJECT_DETECTION ]; then echo "The environment variable OBJECT_DETECTION is required. This is a boolean value True/False."; fi + +if [ "${OBJECT_DETECTION}" == "True" ]; then + echo "Stopping holly-stream..." + pid=$(cat .process.pid) + kill "$pid" + rm .process.pid .log.out + echo "Complete" + + echo "Stopping Triton..." + docker compose down + echo "Complete" + + +elif [ "${OBJECT_DETECTION}" == "False" ]; then + echo "Stopping holly-stream..." + pkill ffmpeg + rm .log.out + echo "Complete" + +else + echo "Invalid input for OBJECT_DETECTION. Expecting True or False; received ${OBJECT_DETECTION}." + exit 120 +fi From 64eb5609ab7749fa4460dce51953395cab0f4945 Mon Sep 17 00:00:00 2001 From: Russell Land Date: Tue, 26 Mar 2024 00:32:43 -0400 Subject: [PATCH 2/2] remove Triton image from github actions, it is too big to run on github action servers --- .github/workflows/docker.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9e49f35..39239bb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,22 +5,6 @@ on: branches: [ raspbian ] jobs: - triton-image: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Docker login - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD && touch .env - - - name: Building and pushing images - run: docker compose build --push triton - nginx-image: runs-on: ubuntu-latest