feat: log available v4l2 controls

Needs new option in config file
log_v4l2ctrls: true

This spits out the equvivalent to v4l2-ctl -L in log.
See README for details.

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2022-04-02 15:20:01 +02:00
parent 664d9b539b
commit 03d03f851e
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639
5 changed files with 55 additions and 12 deletions

View File

@ -282,15 +282,33 @@ to your camera setup section. \
Restart webcamd via mainsail (or your used UI) and you're good to go.
To determine which options or better said parameters your Webcam provides, \
login to your Pi via ssh and type
add to your
v4l2-ctl -d <yourdevice> -L
[webcamd]
_Note: Replace \<yourdevice> with the according string. ex.:_
section, simply
v4l2-ctl -d /dev/video0 -L
log_v4l2ctrls: true
This will show you a list with available options.
This will show you a list with available options. Like this:
[04/02/22 15:07:44] webcamd: Supported Controls:
[04/02/22 15:07:44] webcamd: brightness 0x00980900 (int) : min=1 max=255 step=1 default=128 value=128
[04/02/22 15:07:44] webcamd: contrast 0x00980901 (int) : min=1 max=255 step=1 default=128 value=128
[04/02/22 15:07:44] webcamd: saturation 0x00980902 (int) : min=1 max=255 step=1 default=128 value=128
[04/02/22 15:07:44] webcamd: white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
[04/02/22 15:07:44] webcamd: gain 0x00980913 (int) : min=1 max=100 step=1 default=50 value=50
[04/02/22 15:07:45] webcamd: power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
[04/02/22 15:07:45] webcamd: 0: Disabled
[04/02/22 15:07:45] webcamd: 1: 50 Hz
[04/02/22 15:07:45] webcamd: 2: 60 Hz
[04/02/22 15:07:45] webcamd: white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4650 value=4650 flags=inactive
[04/02/22 15:07:45] webcamd: sharpness 0x0098091b (int) : min=1 max=255 step=1 default=128 value=128
[04/02/22 15:07:45] webcamd: exposure_auto 0x009a0901 (menu) : min=0 max=3 default=0 value=0
[04/02/22 15:07:45] webcamd: 0: Auto Mode
[04/02/22 15:07:45] webcamd: 2: Shutter Priority Mode
[04/02/22 15:07:46] webcamd: exposure_absolute 0x009a0902 (int) : min=5 max=2500 step=1 default=5 value=5 flags=inactive
[04/02/22 15:07:46] webcamd: exposure_auto_priority 0x009a0903 (bool) : default=0 value=0
You have to "play around" with those settings if it matches your needs.
simply repeat the commands as mentioned earlier in your ssh connection.

View File

@ -14,7 +14,7 @@
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -e
set -eE
### Detect Hardware
function detect_avail_cams {
@ -30,6 +30,9 @@ function detect_avail_cams {
if [ "$(log_level)" != "quiet" ]; then
list_cam_formats "${v4l}"
fi
if [ "$(log_v4l2ctrls)" == "true" ]; then
list_cam_v4l2ctrls "${v4l}"
fi
done
else
log_msg "INFO: No usable Cameras found."
@ -54,7 +57,7 @@ function detect_avail_csi {
# Used for "verbose" and "debug" logging in logging.sh
function list_cam_formats {
local device
local device formats
device="${1}"
formats="$(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d')"
log_msg "Supported Formats:"
@ -63,6 +66,16 @@ function list_cam_formats {
done
}
function list_cam_v4l2ctrls {
local device ctrls
device="${1}"
ctrls="$(v4l2-ctl -d "${device}" --list-ctrls-menus)"
log_msg "Supported Controls:"
echo "${ctrls}" | while read -r i; do
log_msg "\t\t${i}"
done
}
# Determine connected "raspicam" device
function detect_raspicam {
local avail

View File

@ -14,7 +14,7 @@
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -e
set -eE
## Logging
function init_log_entry {
@ -35,6 +35,10 @@ function log_level {
fi
}
function log_v4l2ctrls {
get_param webcamd log_v4l2ctrls 2> /dev/null || echo "false"
}
function delete_log {
local del_log logfile
logfile="$(get_param "webcamd" log_path | sed "s#^~#${HOME}#gi")"
@ -104,6 +108,9 @@ function print_cams {
if [ ! "$(log_level)" = "quiet" ]; then
list_cam_formats "${raspicam}"
fi
if [ "$(log_v4l2ctrls)" == "true" ]; then
list_cam_v4l2ctrls "${raspicam}"
fi
fi
if [ -d "/dev/v4l/by-id/" ]; then
detect_avail_cams

View File

@ -6,6 +6,7 @@
[webcamd]
log_path: ~/klipper_logs/webcamd.log # Default logfile in ~/klipper_logs/webcamd.log
log_level: verbose # Valid Options are quiet/verbose/debug
log_v4l2ctrls: true
[cam 1]
mode: mjpg # mjpg/rtsp/webrtc

View File

@ -1,12 +1,16 @@
[webcamd]
log_path: ~/klipper_logs/webcamd.log # Default logfile in ~/klipper_logs/webcamd.log
log_level: quiet # Valid Options are quiet/verbose/debug
log_v4l2ctrls: false # if set to true, it logs available controls for camera
delete_log: false # true to get fresh log on every start
[cam 1]
mode: mjpg # mjpg/rtsp/webrtc
port: 8080 # Port
mode: mjpg # mjpg/rtsp/webrtc ( webrtc is comming in the future )
port: 8080 # Port for ustreamer
device: /dev/video0 # See Log for available ...
resolution: 640x480 # widthxheight format
resolution: 640x480 # WidthxHeight format
max_fps: 15 # If Hardware Supports this it will be forced, ohterwise ignored/coerced.
#custom_flags: # You can run the Stream Services with custom flags.
#custom_flags: # Custom Flags to set for ustreamer, this is optional