Skip to content

Commit

Permalink
Merge pull request #24 from rcland12/raspbian_develop
Browse files Browse the repository at this point in the history
Raspbian develop
  • Loading branch information
rcland12 authored Mar 26, 2024
2 parents a370229 + 64eb560 commit 7a7c845
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 28 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stream-*.ts
*.plan
data/
.process.pid
nohup.out
.log.out
.stream_env

### Linux ###
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions app/collect_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def main(
transform=Transform(hflip=1, vflip=1),
controls={"FrameDurationLimits": (duration, duration)}
))
camera.controls.Brightness = 0.2
camera.start()

try:
Expand Down
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def main(
},
transform=Transform(hflip=1, vflip=1)
))
camera.controls.Brightness = 0.2

process = subprocess.Popen(command, stdin=subprocess.PIPE)

Expand Down
12 changes: 7 additions & 5 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -52,6 +53,7 @@ elif [ "${OBJECT_DETECTION}" == "False" ]; then
--width $CAMERA_WIDTH \
--height $CAMERA_HEIGHT \
--rotation 180 \
--brightness 0.2 \
--listen -o - | \
ffmpeg \
-i - \
Expand All @@ -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}."
Expand Down
31 changes: 25 additions & 6 deletions stop.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7a7c845

Please sign in to comment.