Skip to content

Instantly share code, notes, and snippets.

@calexandre
Forked from nunofgs/README.md
Last active May 13, 2024 21:55
Show Gist options
  • Save calexandre/489f7b41b9af57f27570bcae34f9f868 to your computer and use it in GitHub Desktop.
Save calexandre/489f7b41b9af57f27570bcae34f9f868 to your computer and use it in GitHub Desktop.
Use any RTSP camera with Prusa Connect

I use a cheap Tapo C100 webcam to monitor my 3D prints. It supports RTSP.

Screenshot 2023-07-17 at 23 26 34

Instructions

  1. Go to the Cameras section at https://connect.prusa3d.com
  2. Add a new camera.
  3. Click the QR code link
  4. Click "Start Camera"
  5. Open your browser's inspector window and look for the "/snapshot" request.
  6. Copy the "Fingerprint" and "Token" headers into the docker-compose below.

The end result!

Screenshot 2023-07-17 at 23 13 10

[Unit]
Description=Prusa Connect Camera Streamer
After=network.target
[Service]
ExecStart=/home/pi/prusaconnect-camera-streamer.sh
Restart=always
User=pi
Group=pi
WorkingDirectory=/home/pi/
[Install]
WantedBy=multi-user.target
#!/bin/bash
TOKEN=<token>
FINGERPRINT=<fingerprint>
CAMERA_SNAPSHOT_URL=http://<octopi-url>/webcam/snapshot
# Set default values for environment variables
: "${HTTP_URL:=https://webcam.connect.prusa3d.com/c/snapshot}"
: "${DELAY_SECONDS:=1}"
: "${LONG_DELAY_SECONDS:=60}"
while true; do
# Grab a frame from the rpi camera snapshot url
curl -sS -X GET "$CAMERA_SNAPSHOT_URL" -o output.jpg
# If no error, upload it.
if [ $? -eq 0 ]; then
# POST the image to the HTTP URL using curl
curl -sS -X PUT "$HTTP_URL" \
-H "accept: */*" \
-H "content-type: image/jpg" \
-H "fingerprint: $FINGERPRINT" \
-H "token: $TOKEN" \
--data-binary "@output.jpg" \
--no-progress-meter \
--compressed > /dev/null
# Reset delay to the normal value
DELAY=$DELAY_SECONDS
else
echo "Error... Retrying after ${LONG_DELAY_SECONDS}s..."
# Set delay to the longer value
DELAY=$LONG_DELAY_SECONDS
fi
sleep "$DELAY"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment