From 2b61851ae6bc343a6d703d64089c6d345cbeb97a Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Apr 2024 09:38:37 +0200 Subject: [PATCH 1/8] adds option to override not installing camera settings When the new revision of the AI cam is detected, the script shows an error, and prevents installing the macros. This makes sense if the AI cam is the only installed cam, but not if one has installed an additional USB cam, connected to the front USB port. The change gives an option, too continue the installation in that case, by asking if the user wants to continue. --- scripts/menu/install_menu.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/menu/install_menu.sh b/scripts/menu/install_menu.sh index e2fa220..9f14b2c 100755 --- a/scripts/menu/install_menu.sh +++ b/scripts/menu/install_menu.sh @@ -182,13 +182,24 @@ function install_menu() { 18) if [ -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is already installed!" - elif v4l2-ctl --list-devices | grep -q 'CCX2F3299'; then + continue + fi + if v4l2-ctl --list-devices | grep -q 'CCX2F3299'; then error_msg "You have the new hardware version of the camera and it's not compatible!" - elif [ ! -f "$KLIPPER_SHELL_FILE" ]; then - error_msg "Klipper Gcode Shell Command is needed, please install it first!" - else - run "install_camera_settings_control" "install_menu_ui" - fi;; + echo -e "\e[1A\e[K ${yellow}You can safely ignore this message, and continue if you have additional USB webcams." + read -p " ${white}Continue (y/n): ${yellow}" response + case "$response" in + [nN][oO]|[nN]) + run "install_menu_ui" + ;; + *) + if [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_camera_settings_control" "install_menu_ui" + fi + esac + fi;; 19) if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then error_msg "OctoEverywhere is already installed!" From bff130b19d6e6671c132da8fdfcd2232cbcda125 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Apr 2024 13:42:07 +0200 Subject: [PATCH 2/8] adds check for USB webcam before allowing override --- scripts/menu/install_menu.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/menu/install_menu.sh b/scripts/menu/install_menu.sh index 9f14b2c..6c66234 100755 --- a/scripts/menu/install_menu.sh +++ b/scripts/menu/install_menu.sh @@ -185,8 +185,11 @@ function install_menu() { continue fi if v4l2-ctl --list-devices | grep -q 'CCX2F3299'; then - error_msg "You have the new hardware version of the camera and it's not compatible!" - echo -e "\e[1A\e[K ${yellow}You can safely ignore this message, and continue if you have additional USB webcams." + error_msg "You have the new hardware version of the Creality AI camera and it's not compatible!" + fi + if [ "lsusb | grep -E \"(Integrated Camera|Webcam|CVD|Video|uvcvideo)\"" ]; then + echo -e "\e[1A\e[K ${yellow}An additional USB webcam was detected. It may work with the camera settings, but that's not guaranteed." + echo -e "${yellow} Would you like too install anyway?" read -p " ${white}Continue (y/n): ${yellow}" response case "$response" in [nN][oO]|[nN]) @@ -199,7 +202,7 @@ function install_menu() { run "install_camera_settings_control" "install_menu_ui" fi esac - fi;; + fi;; 19) if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then error_msg "OctoEverywhere is already installed!" From 277548fbb669bb09e53274e3c079e8571a312e66 Mon Sep 17 00:00:00 2001 From: 3DPrintingGeek <3dprintinggeekinfo@gmail.com> Date: Tue, 7 May 2024 14:55:01 +0200 Subject: [PATCH 3/8] allows installing camera settings with additional USB cam The old script didn't allow to install the camera settings macros, when the new HW revision of the AI cam has been detected, even when the additional USB cam could benefit from being controlled by the macros. The changes made in this commit give a warning about the new HW revision not bein compatible but allow the user to acknowledge that he wants the camera settings macros installed nevertheless. --- scripts/menu/install_menu.sh | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/scripts/menu/install_menu.sh b/scripts/menu/install_menu.sh index 6c66234..d137da3 100755 --- a/scripts/menu/install_menu.sh +++ b/scripts/menu/install_menu.sh @@ -183,25 +183,24 @@ function install_menu() { if [ -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is already installed!" continue - fi - if v4l2-ctl --list-devices | grep -q 'CCX2F3299'; then + elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ -f /etc/init.d/S99usb_camera ]; then error_msg "You have the new hardware version of the Creality AI camera and it's not compatible!" - fi - if [ "lsusb | grep -E \"(Integrated Camera|Webcam|CVD|Video|uvcvideo)\"" ]; then - echo -e "\e[1A\e[K ${yellow}An additional USB webcam was detected. It may work with the camera settings, but that's not guaranteed." - echo -e "${yellow} Would you like too install anyway?" - read -p " ${white}Continue (y/n): ${yellow}" response - case "$response" in - [nN][oO]|[nN]) - run "install_menu_ui" - ;; - *) - if [ ! -f "$KLIPPER_SHELL_FILE" ]; then - error_msg "Klipper Gcode Shell Command is needed, please install it first!" - else - run "install_camera_settings_control" "install_menu_ui" - fi - esac + if [ "lsusb | grep -E \"(Integrated Camera|Webcam|CVD|Video|uvcvideo)\" | wx -l | grep -q '^ [1-9]" ]; then + echo -e "\e[1A\e[K ${yellow}An additional USB webcam was detected. It may work with the camera settings, but that's not guaranteed." + echo -e "${yellow} Would you like too install anyway?" + read -p " ${white}Continue (y/n): ${yellow}" response + case "$response" in + [nN][oO]|[nN]) + run "install_menu_ui" + ;; + *) + if [ ! -f "$KLIPPER_SHELL_FILE" ]; then + error_msg "Klipper Gcode Shell Command is needed, please install it first!" + else + run "install_camera_settings_control" "install_menu_ui" + fi + esac + fi fi;; 19) if [ -d "$OCTOEVERYWHERE_FOLDER" ]; then From e24d8f32e35b5cdb33341a2388d42e3b42874100 Mon Sep 17 00:00:00 2001 From: 3DPrintingGeek <3dprintinggeekinfo@gmail.com> Date: Tue, 7 May 2024 14:55:35 +0200 Subject: [PATCH 4/8] adds new macro CAM_SELECT When using additional cameras there must be a way to select for which camera the subsequent macro calls of the camera settings macros should be executed. The default camera is the Creality AI camera. Usage: Before calling one of the other macros, make a call to CAM_SELECT cam_device=n with n being the number of the cameras video device. E.g.: If your second USB cam is /dev/video5 then call "CAM_SELECT cam_device=5". Every other camera macro call will now be for this camera until changed by another CAM_SELECT-call. Note: Not all camera macros will work with every camera, and some only if the camera is in a specific mode. It depends mostly on the cams hardware capabilities. Calling the CAM_SETTINGS macro will show the available settings and their current values. --- files/camera-settings/camera-settings.cfg | 75 ++++++++++++++++++----- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/files/camera-settings/camera-settings.cfg b/files/camera-settings/camera-settings.cfg index 9efbb08..98f51b3 100644 --- a/files/camera-settings/camera-settings.cfg +++ b/files/camera-settings/camera-settings.cfg @@ -5,6 +5,7 @@ [delayed_gcode LOAD_CAM_SETTINGS] initial_duration: 2 gcode: + CAM_SELECT CAM_DEVICE=4 CAM_BRIGHTNESS BRIGHTNESS=0 CAM_CONTRAST CONTRAST=32 CAM_SATURATION SATURATION=56 @@ -17,7 +18,9 @@ gcode: CAM_BACKLIGHT_COMPENSATION BACKLIGHT_COMPENSATION=1 CAM_EXPOSURE_AUTO EXPOSURE_AUTO=3 CAM_EXPOSURE_AUTO_PRIORITY EXPOSURE_AUTO_PRIORITY=0 - + CAM_EXPOSURE_ABSOLUTE EXPOSURE_ABSOLUTE=1000 + CAM_FOCUS_AUTO FOCUS_AUTO=0 + CAM_FOCUS_ABSOLUTE FOCUS_ABSOLUTE=127 [gcode_shell_command v4l2-ctl] command: v4l2-ctl @@ -26,82 +29,124 @@ verbose: True [gcode_macro CAM_SETTINGS] gcode: - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 -l" + {% set param = "-d /dev/video%s -l" % (printer["gcode_macro CAM_SELECT"].cam_device) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_BRIGHTNESS] description: min=-64 / max=64 gcode: {% set brightness = params.BRIGHTNESS|default(0) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl brightness="{brightness} + {% set param = "-d /dev/video%s --set-ctrl brightness=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, brightness) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_CONTRAST] description: min=0 / max=64 gcode: {% set contrast = params.CONTRAST|default(32) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl contrast="{contrast} + {% set param = "-d /dev/video%s --set-ctrl contrast=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, contrast) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_SATURATION] description: min=0 / max=128 gcode: {% set saturation = params.SATURATION|default(56) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl saturation="{saturation} + {% set param = "-d /dev/video%s --set-ctrl saturation=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, saturation) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_HUE] description: min=-40 / max=40 gcode: {% set hue = params.HUE|default(0) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl hue="{hue} + {% set param = "-d /dev/video%s --set-ctrl hue=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, hue) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_WHITE_BALANCE_TEMPERATURE_AUTO] description: disable=0 / enable=1 gcode: {% set white_balance_temperature_auto = params.WHITE_BALANCE_TEMPERATURE_AUTO|default(1) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl white_balance_temperature_auto="{white_balance_temperature_auto} + {% set param = "-d /dev/video%s --set-ctrl white_balance_temperature_auto=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, white_balance_temperature_auto) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_GAMMA] description: min=72 / max=500 gcode: {% set gamma = params.GAMMA|default(80) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl gamma="{gamma} + {% set param = "-d /dev/video%s --set-ctrl gamma=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, gamma) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_GAIN] description: min=0 / max=100 gcode: {% set gain = params.GAIN|default(0) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl gain="{gain} + {% set param = "-d /dev/video%s --set-ctrl gain=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, gain) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_POWER_LINE_FREQUENCY] description: min=0 / max=2 gcode: {% set power_line_frequency = params.POWER_LINE_FREQUENCY|default(1) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl power_line_frequency="{power_line_frequency} + {% set param = "-d /dev/video%s --set-ctrl power_line_frequency=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, power_line_frequency) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_WHITE_BALANCE_TEMPERATURE] description: min=2800 / max=6500 gcode: {% set white_balance_temperature = params.WHITE_BALANCE_TEMPERATURE|default(4600) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl white_balance_temperature="{white_balance_temperature} + {% set param = "-d /dev/video%s --set-ctrl white_balance_temperature=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, white_balance_temperature) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_SHARPNESS] description: min=0 / max=6 gcode: {% set sharpness = params.SHARPNESS|default(3) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl sharpness="{sharpness} + {% set param = "-d /dev/video%s --set-ctrl sharpness=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, sharpness) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_BACKLIGHT_COMPENSATION] description: min=0 / max=2 gcode: {% set backlight_compensation = params.BACKLIGHT_COMPENSATION|default(1) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl backlight_compensation="{backlight_compensation} + {% set param = "-d /dev/video%s --set-ctrl backlight_compensation=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, backlight_compensation) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_EXPOSURE_AUTO] description: manual=1 / auto=3 gcode: {% set exposure_auto = params.EXPOSURE_AUTO|default(3) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl exposure_auto="{exposure_auto} + {% set param = "-d /dev/video%s --set-ctrl exposure_auto=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, exposure_auto) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" [gcode_macro CAM_EXPOSURE_AUTO_PRIORITY] description: disable=0 / enable=1 gcode: {% set exposure_auto_priority = params.EXPOSURE_AUTO_PRIORITY|default(0) %} - RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl exposure_auto_priority="{exposure_auto_priority} + {% set param = "-d /dev/video%s --set-ctrl exposure_auto_priority=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, exposure_auto_priority) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" + +[gcode_macro CAM_EXPOSURE_ABSOLUTE] +description: min=3 / max=2047 +gcode: + {% set exposure_absolute = params.EXPOSURE_ABSOLUTE|default(3) %} + {% set param = "-d /dev/video%s --set-ctrl exposure_absolute=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, exposure_absolute) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" + +[gcode_macro CAM_FOCUS_AUTO] +description: disable=0 / enable=1 +gcode: + {% set focus_auto = params.FOCUS_AUTO|default(0) %} + {% set param = "-d /dev/video%s --set-ctrl focus_auto=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, focus_auto) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" + +[gcode_macro CAM_FOCUS_ABSOLUTE] +description: min=0 / max=250 +gcode: + {% set focus_absolute = params.FOCUS_ABSOLUTE|default(127) %} + {% set param = "-d /dev/video%s --set-ctrl focus_absolute=%s" % (printer["gcode_macro CAM_SELECT"].cam_device, focus_absolute) %} + RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="""{param}""" + +[gcode_macro CAM_SELECT] +description: device=/dev/video(4|5) +variable_cam_device: 4 +gcode: + SET_GCODE_VARIABLE MACRO=CAM_SELECT VARIABLE=cam_device VALUE={params.CAM_DEVICE|default(cam_device)} + \ No newline at end of file From d21252cbf56a608baf4a322c175744f2dd5f8e3c Mon Sep 17 00:00:00 2001 From: 3DPrintingGeek <3dprintinggeekinfo@gmail.com> Date: Wed, 8 May 2024 08:11:11 +0200 Subject: [PATCH 5/8] changes install_menu to install_menu_k1 --- scripts/menu/K1/install_menu_K1.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/menu/K1/install_menu_K1.sh b/scripts/menu/K1/install_menu_K1.sh index 5314580..0667ae1 100755 --- a/scripts/menu/K1/install_menu_K1.sh +++ b/scripts/menu/K1/install_menu_K1.sh @@ -183,13 +183,13 @@ function install_menu_k1() { read -p " ${white}Continue (y/n): ${yellow}" response case "$response" in [nN][oO]|[nN]) - run "install_menu_ui" + run "install_menu_ui_k1" ;; *) if [ ! -f "$KLIPPER_SHELL_FILE" ]; then error_msg "Klipper Gcode Shell Command is needed, please install it first!" else - run "install_camera_settings_control" "install_menu_ui" + run "install_camera_settings_control" "install_menu_ui_k1" fi esac fi From d7105c26440df72976a98e36216bb8a5f0606670 Mon Sep 17 00:00:00 2001 From: 3DPrintingGeek <84936569+3DPrintingGeek@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:15:13 +0200 Subject: [PATCH 6/8] replaces hardcoded path to initd folder with variable --- scripts/menu/K1/install_menu_K1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/menu/K1/install_menu_K1.sh b/scripts/menu/K1/install_menu_K1.sh index 015125c..6fd82f6 100755 --- a/scripts/menu/K1/install_menu_K1.sh +++ b/scripts/menu/K1/install_menu_K1.sh @@ -175,7 +175,7 @@ function install_menu_k1() { if [ -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is already installed!" continue - elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ -f /etc/init.d/S99usb_camera ]; then + elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ -f "$INITD_FOLDER"/S99usb_camera ]; then error_msg "You have the new hardware version of the Creality AI camera and it's not compatible!" if [ "lsusb | grep -E \"(Integrated Camera|Webcam|CVD|Video|uvcvideo)\" | wx -l | grep -q '^ [1-9]" ]; then echo -e "\e[1A\e[K ${yellow}An additional USB webcam was detected. It may work with the camera settings, but that's not guaranteed." From 297bd0877e7d2627b579df625cbacb06978637ab Mon Sep 17 00:00:00 2001 From: 3DPrintingGeek <84936569+3DPrintingGeek@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:19:28 +0200 Subject: [PATCH 7/8] changes foldername USB camera support is installed into $INITD/S50_usb_camera This change changes the wrong directory S99_usb_camera to S50_usb_camera --- scripts/menu/K1/install_menu_K1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/menu/K1/install_menu_K1.sh b/scripts/menu/K1/install_menu_K1.sh index 6fd82f6..3c30534 100755 --- a/scripts/menu/K1/install_menu_K1.sh +++ b/scripts/menu/K1/install_menu_K1.sh @@ -175,7 +175,7 @@ function install_menu_k1() { if [ -f "$CAMERA_SETTINGS_FILE" ]; then error_msg "Camera Settings Control is already installed!" continue - elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ -f "$INITD_FOLDER"/S99usb_camera ]; then + elif v4l2-ctl --list-devices | grep -q 'CCX2F3299' && [ -f "$INITD_FOLDER"/S50usb_camera ]; then error_msg "You have the new hardware version of the Creality AI camera and it's not compatible!" if [ "lsusb | grep -E \"(Integrated Camera|Webcam|CVD|Video|uvcvideo)\" | wx -l | grep -q '^ [1-9]" ]; then echo -e "\e[1A\e[K ${yellow}An additional USB webcam was detected. It may work with the camera settings, but that's not guaranteed." From 40332e90a9832b8212aee32fd0dd484732ae1a30 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Aug 2024 18:50:55 +0800 Subject: [PATCH 8/8] changes made to files --- ...usb_camera-dual => S50usb_camera-dual.bak} | 8 ++-- files/services/S50usb_camera-multi | 40 +++++++++++++++++++ files/services/S50usb_camera-single | 12 +++--- scripts/paths.sh | 4 +- scripts/usb_camera.sh | 5 ++- 5 files changed, 55 insertions(+), 14 deletions(-) rename files/services/{S50usb_camera-dual => S50usb_camera-dual.bak} (70%) create mode 100755 files/services/S50usb_camera-multi diff --git a/files/services/S50usb_camera-dual b/files/services/S50usb_camera-dual.bak similarity index 70% rename from files/services/S50usb_camera-dual rename to files/services/S50usb_camera-dual.bak index b3bc1c2..fc83fee 100755 --- a/files/services/S50usb_camera-dual +++ b/files/services/S50usb_camera-dual.bak @@ -5,13 +5,13 @@ case "$1" in start) echo "Starting USB Camera..." - V4L_DEVS=$(v4l2-ctl --list-devices | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') - CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY' | wc -l) + V4L_DEVS=$(v4l2-ctl --list-devices | grep -vE 'CCX2F3298|CCX2F3299' | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') + CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F3298|CCX2F3298' | wc -l) if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then - /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video4 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video5 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video6 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8081" else - /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video4 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d /dev/video5 -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p 8080" fi ;; stop) diff --git a/files/services/S50usb_camera-multi b/files/services/S50usb_camera-multi new file mode 100755 index 0000000..66cf33e --- /dev/null +++ b/files/services/S50usb_camera-multi @@ -0,0 +1,40 @@ +#!/bin/sh +# USB Camera Service +# Credit: destinal & Guilouz + +case "$1" in + start) + echo "Starting USB Camera..." + V4L_DEVS=$(v4l2-ctl --list-devices | grep -vE 'CCX2F3298|CCX2F3299' | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') + #CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -A1 'CREALITY|CCX2F3298|CCX2F3299' | grep -v 'CREALITY|CCX2F3298|CCX2F3299' | wc -l) + CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -EA1 --no-group-separator 'CREALITY|CCX2F3298|CCX2F3299' | grep -vE 'CREALITY|CCX2F3298|CCX2F3299' | cut -d ' +' -f 2) + PORT=8080 + if [ "x$CREALITY_CAMS" != x ]; then + echo /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $CREALITY_CAMS -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $CREALITY_CAMS -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" + PORT=`expr $PORT + 1` + #echo "Error: No third party camera found or you use a Creality camera!" + #exit 1 + fi + for V4L_DEV in $V4L_DEVS; do + echo /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $V4L_DEV -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" + /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $V4L_DEV -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" + PORT=`expr $PORT + 1` + done + ;; + stop) + echo "Stopping USB Camera..." + killall -q mjpg_streamer && killall -q cam_app && killall -q cx_ai_middleware + ;; + restart|reload) + "$0" stop + sleep 1 + "$0" start + ;; + *) + echo "Usage: /etc/init.d/S50usb_camera {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/files/services/S50usb_camera-single b/files/services/S50usb_camera-single index ff7e827..198adb0 100755 --- a/files/services/S50usb_camera-single +++ b/files/services/S50usb_camera-single @@ -5,12 +5,12 @@ case "$1" in start) echo "Starting USB Camera..." - V4L_DEVS=$(v4l2-ctl --list-devices | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') - CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F3298' | wc -l) - if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then - echo "Error: No third party camera found or you use a Creality camera!" - exit 1 - fi + V4L_DEVS=$(v4l2-ctl --list-devices | grep -vE 'CCX2F3298|CCX2F3299' | grep -A1 usb | sed 's/^[[:space:]]*//g' | grep '^/dev') + CREALITY_CAMS=$(v4l2-ctl --list-devices | grep -E 'CREALITY|CCX2F3298|CCX2F3299' | wc -l) +# if [ "x$V4L_DEVS" = "x" -o $CREALITY_CAMS -gt 0 ]; then +# echo "Error: No third party camera found or you use a Creality camera!" +# exit 1 +# fi PORT=8080 for V4L_DEV in $V4L_DEVS; do /opt/bin/mjpg_streamer -b -i "/opt/lib/mjpg-streamer/input_uvc.so -d $V4L_DEV -r 1280x720 -f 15" -o "/opt/lib/mjpg-streamer/output_http.so -p $PORT" diff --git a/scripts/paths.sh b/scripts/paths.sh index 785e935..27d8324 100755 --- a/scripts/paths.sh +++ b/scripts/paths.sh @@ -141,7 +141,7 @@ function set_paths() { # USB Camera Support USB_CAMERA_FILE="${INITD_FOLDER}/S50usb_camera" USB_CAMERA_SINGLE_URL="${HS_FILES}/services/S50usb_camera-single" - USB_CAMERA_DUAL_URL="${HS_FILES}/services/S50usb_camera-dual" + USB_CAMERA_MULTI_URL="${HS_FILES}/services/S50usb_camera-multi" # OctoEverywhere # OCTOEVERYWHERE_FOLDER="${USR_DATA}/octoeverywhere" @@ -192,4 +192,4 @@ function set_permissions() { chmod +x "$CURL" >/dev/null 2>&1 & -} \ No newline at end of file +} diff --git a/scripts/usb_camera.sh b/scripts/usb_camera.sh index 8866bea..3fceb89 100755 --- a/scripts/usb_camera.sh +++ b/scripts/usb_camera.sh @@ -23,9 +23,9 @@ function install_usb_camera(){ echo -e "${white}" echo -e "Info: Copying file..." if [ "$model" = "K1" ]; then - cp "$USB_CAMERA_DUAL_URL" "$INITD_FOLDER"/S50usb_camera + cp "$USB_CAMERA_MULTI_URL" "$INITD_FOLDER"/S50usb_camera else - cp "$USB_CAMERA_SINGLE_URL" "$INITD_FOLDER"/S50usb_camera + cp "$USB_CAMERA_MULTI_URL" "$INITD_FOLDER"/S50usb_camera echo echo -e " ${darkred}Be careful with the 1080p resolution!" echo -e " It takes more resources and timelapses are larger and take longer to convert.${white}" @@ -102,3 +102,4 @@ function remove_usb_camera(){ esac done } +