Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log libamera device resolutions and controls #240

Merged
merged 40 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d8332a6
refactor: refactor detect_libcamera func
KwadFan Jan 20, 2024
94f2ec7
feat: print picamera resolutions
KwadFan Jan 31, 2024
5410a9e
chore: wip
KwadFan Jan 31, 2024
64000be
chore: wip
KwadFan Jan 31, 2024
f7bc73f
chore: wip
KwadFan Jan 31, 2024
b32a18c
chore: wip
KwadFan Jan 31, 2024
e9e4011
chore: wip
KwadFan Jan 31, 2024
63a5529
chore: wip
KwadFan Jan 31, 2024
947cb07
chore: wip
KwadFan Jan 31, 2024
a1429f1
chore: dont display controls on pi5
KwadFan Jan 31, 2024
63bbbea
chore: dont display resolutions on pi5
KwadFan Jan 31, 2024
09b19c9
fix: revert code style changes
KwadFan Jan 31, 2024
b901181
chore: switch to bash
KwadFan Mar 19, 2024
7b32509
fix: fix typo
KwadFan Mar 19, 2024
30b2aeb
fix: fix output
KwadFan Mar 19, 2024
8b39771
chore: wip
KwadFan Mar 19, 2024
1853129
chore: wip
KwadFan Mar 19, 2024
78d644e
chore: wip
KwadFan Mar 19, 2024
84267b9
chore: wip
KwadFan Mar 19, 2024
38e63a2
chore: wip
KwadFan Mar 19, 2024
127b0fc
chore: wip
KwadFan Mar 19, 2024
8dcb9cb
chore: wip
KwadFan Mar 19, 2024
3ff0296
chore: wip
KwadFan Mar 19, 2024
32bb8c2
chore: wip
KwadFan Mar 19, 2024
9c4266b
chore: wip
KwadFan Mar 19, 2024
9ce04f5
chore: wip
KwadFan Mar 19, 2024
1c2ce25
chore: wip
KwadFan Mar 19, 2024
094b15d
chore: wip
KwadFan Mar 19, 2024
d0e743b
chore: wip
KwadFan Mar 19, 2024
1df93b1
chore: wip
KwadFan Mar 19, 2024
058df55
chore: revert code style changes
KwadFan Mar 19, 2024
dd8e1d2
chore: revert code style change
KwadFan Mar 19, 2024
10ec828
chore: revert code style changes
KwadFan Mar 20, 2024
ae02f46
chore: revert code style changes
KwadFan Mar 20, 2024
55e2f06
chore: remove useless comment
KwadFan Mar 21, 2024
6bf8fd8
chore: wip
KwadFan Mar 21, 2024
9239cd8
chore: wip
KwadFan Mar 21, 2024
b26f5ed
chore: wip
KwadFan Mar 21, 2024
2cd11c4
chore: wip
KwadFan Mar 21, 2024
4ba3942
chore: wip
KwadFan Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ detect_avail_cams() {
local avail realpath
avail="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null)"
count="$(echo "${avail}" | wc -l)"
if [[ -d "/dev/v4l/by-id/" ]] &&
[[ -n "${avail}" ]]; then
if [[ -d "/dev/v4l/by-id/" ]] && [[ -n "${avail}" ]]; then
log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)"
echo "${avail}" | while read -r v4l; do
realpath=$(readlink -e "${v4l}")
Expand Down Expand Up @@ -63,8 +62,8 @@ detect_libcamera() {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
avail="$(libcamera-hello --list-cameras | sed '/^\[.*\].*/d' | awk 'NR==1 {print $1}')"
if [[ "${avail}" = "Available" ]]; then
avail="$(libcamera-hello --list-cameras | grep -c "Available")"
if [[ "${avail}" = "1" ]]; then
get_libcamera_path | wc -l
else
echo "0"
Expand All @@ -83,23 +82,62 @@ get_libcamera_path() {
fi
}

# print libcamera resolutions
list_picam_resolution() {
local prefix
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "'libcamera' device(s) resolution(s) :"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/')
}

#type=3):
get_libcamera_controls() {
local ust_bin flags
flags=( --camera-type=libcamera --camera-list_options )
ust_bin="${BASE_CN_PATH}/bin/camera-streamer/camera-streamer"
if [[ -x "${ust_bin}" ]]; then
"${ust_bin}" "${flags[@]}" 2> /dev/null | \
sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \
sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' | \
sed 's/- available option: //g' | sed '/^$/d;' | \
sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7/d;/type=4/d' | \
sed 's/type=1/\t(bool/g;s/type=3/\t(int/g;s/type=5/\t(float/g' | \
sed 's/\[/\tmin=/g;s/\.\./\tmax=/g;s/\]$//g'
else
log_msg "WARN: 'libcamera' device option can not be displayed, because"
log_msg "WARN: camera-streamer is not installed"
fi
}

list_picam_controls() {
local prefix
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "'libcamera' device controls :"
while read -r i; do
if [[ ! "${i}" =~ "INFO" ]]; then
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
fi
done < <(get_libcamera_controls)
# blank line workaround
log_msg ""
}

# Determine connected "legacy" device
function detect_legacy {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
command -v vcgencmd &> /dev/null; then
if vcgencmd get_camera &> /dev/null ; then
avail="$(vcgencmd get_camera \
| awk -F '=' '{ print $3 }' \
| cut -d',' -f1 \
)"
command -v vcgencmd &>/dev/null; then
mryel00 marked this conversation as resolved.
Show resolved Hide resolved
if vcgencmd get_camera &>/dev/null; then
avail="$( vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)"
fi
fi
echo "${avail:-0}"
}

function dev_is_legacy {
v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
mryel00 marked this conversation as resolved.
Show resolved Hide resolved
awk 'NR==2 {print $1}'
}

Expand Down
6 changes: 5 additions & 1 deletion libs/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ function print_cams {
for device in $(get_libcamera_path); do
log_msg "Detected 'libcamera' device -> ${device}"
done
if [[ "$(is_pi5)" = "0" ]]; then
list_picam_resolution
list_picam_controls
fi
fi
if [[ "${legacy}" -ne 0 ]]; then
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
mryel00 marked this conversation as resolved.
Show resolved Hide resolved
awk 'NR==2 {print $1}')"
log_msg "Detected 'Raspicam' Device -> ${raspicam}"
if [[ ! "${CROWSNEST_LOG_LEVEL}" = "quiet" ]]; then
Expand Down
Loading