/dev/video0 camera

This commit is contained in:
paukstelis
2022-11-08 13:03:56 -05:00
parent ea25d783fc
commit 95a90a0c12
2 changed files with 54 additions and 33 deletions

View File

@@ -26,10 +26,10 @@ These files provide a bash script for quickly deploying multiple octoprint insta
* To add more printers at a later date, just run the script again!
* General Linux (Ubuntu/Mint/RPiOS/Debian/Fedora/Arch/etc.)
* __You do not need to install OctoPrint using any Wiki instructions, snap, etc. The script will do it for you.__
* octoprint_deploy uses systemd services, so avoid distros that do not use systemd by default (MX Linux)
* octoprint_deploy uses systemd services, so avoid distros that do not use systemd by default (MX Linux or chroot based systems like Chrome+crouton)
* Basic guide video here: https://youtu.be/1YINWQ5fNn0
* All commands assume you are operating out of your home directory.
* Install Ubuntu 18-22.X, Mint 20.3+, Debian, DietPi, RPiOS, Armbian, Fedora35+, or ArchLinux on your system (make sure your user is admin for sudo).
* Install Ubuntu 20+, Mint 20.3+, Debian, DietPi, RPiOS, Armbian, Fedora35+, or ArchLinux on your system (make sure your user is admin for sudo).
* Install git if it isn't already: `sudo apt install git` or `sudo dnf install git` or `sudo pacman -S git`.
* run the command `git clone https://github.com/paukstelis/octoprint_deploy.git`.
* run the command `sudo octoprint_deploy/octoprint_deploy.sh`.

View File

@@ -364,7 +364,7 @@ write_camera() {
}
add_camera() {
PI=$1
if [ $SUDO_USER ]; then user=$SUDO_USER; fi
echo 'Adding camera' | log
if [ -z "$INSTANCE" ]; then
@@ -386,19 +386,9 @@ add_camera() {
done
fi
dmesg -C
echo "Plug your camera in via USB now (detection time-out in 1 min)"
counter=0
while [[ -z "$CAM" ]] && [[ $counter -lt 60 ]]; do
CAM=$(dmesg | sed -n -e 's/^.*SerialNumber: //p')
TEMPUSBCAM=$(dmesg | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p')
counter=$(( $counter + 1 ))
if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then
break
fi
sleep 1
done
dmesg -C
if [ -z "$PI" ]; then
detect_camera
#Failed state. Nothing detected
if [ -z "$CAM" ] && [ -z "$TEMPUSBCAM" ] ; then
echo
@@ -416,6 +406,13 @@ add_camera() {
echo -e "Camera detected with serial number: \033[0;34m $CAM \033[0m" | log
check_sn "$CAM"
fi
else
echo "Setting up a Pi camera service for /dev/video0"
echo "Please note that doing this with USB cameras may lead to issues."
echo "Don't expect extensive support for trying to fix these issues."
fi
echo "Camera Port (ENTER will increment last value in /etc/camera_ports):"
read CAMPORT
if [ -z "$CAMPORT" ]; then
@@ -454,6 +451,10 @@ add_camera() {
#Need to check if this is a one-off install
if [ -n "$camopt" ]; then
write_camera
#Pi Cam setup, replace cam_INSTANCE with /dev/video0
if [ -n "$PI" ]; then
sed -i "s/cam_$INSTANCE/video0/" /etc/systemd/system/cam_$INSTANCE.service
fi
systemctl start cam_$INSTANCE.service
systemctl enable cam_$INSTANCE.service
udevadm control --reload-rules
@@ -480,6 +481,22 @@ detect_printer() {
dmesg -C
}
detect_camera() {
dmesg -C
echo "Plug your camera in via USB now (detection time-out in 1 min)"
counter=0
while [[ -z "$CAM" ]] && [[ $counter -lt 60 ]]; do
CAM=$(dmesg | sed -n -e 's/^.*SerialNumber: //p')
TEMPUSBCAM=$(dmesg | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p')
counter=$(( $counter + 1 ))
if [[ -n "$TEMPUSBCAM" ]] && [[ -z "$CAM" ]]; then
break
fi
sleep 1
done
dmesg -C
}
remove_instance() {
echo
echo
@@ -1371,4 +1388,8 @@ fi
if [ "$1" == replace ]; then
replace_id
fi
if [ "$1" == picam ]; then
add_camera true
fi
main_menu