Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ curl -k --anyauth -u root:<password> \
will list the current settings:

```sh
root.findwind.FindwindSpotID=301
root.findwind.Style=1A
root.findwind.Opacity=0.7
root.findwind.Position=topLeft
root.findwind.CustomPositionX=0
root.findwind.CustomPositionY=0
root.Findwind.CustomPositionX=0
root.Findwind.CustomPositionY=0
root.Findwind.FindwindSpotID=301
root.Findwind.Opacity=0.7
root.Findwind.Position=topLeft
root.Findwind.Scale=100
root.Findwind.Style=1A
```

> [!TIP]
Expand All @@ -137,13 +138,18 @@ root.findwind.CustomPositionY=0
> *topLeft/topRight/bottomLeft/bottomRight/custom* and *CustomPositionX*
> and *CustomPositionY* must be within the range -1.0 to 1.0.

If you want to set the opacity to e.g. 0.8:
If you want to set the style to e.g. 1B:

```sh
curl -k --anyauth -u root:<password> \
'https://<camera hostname/ip>/axis-cgi/param.cgi?action=update&root.findwind.Opacity=0.8'
'https://<camera hostname/ip>/axis-cgi/param.cgi?action=update&root.findwind.Style=1B'
```

> [!TIP]
> The *Scale* parameter is a percentage value that scales the overlay size.
> For example, a scale of 200 will double the size of the overlay, while
> a scale of 50 will reduce it to half size.

## Usage

Once configured and running, the application will overlay wind information on the camera's video stream. The overlay updates periodically (default every 120 seconds) with the latest data from FindWind.
Expand Down
24 changes: 19 additions & 5 deletions findwind
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,33 @@ download_svg() {
# Replace font-family with a known sans-serif font to improve chances of correct rendering (since the original font may not be available in the container)
# and set opacity on the first <g...> tag regardless of existing attributes.
opacity=$(get_non_empty_param Opacity)
echo "$svg" | \
sed -e "s#\(font-family='\)[^']*'#\1$FONT_FAMILY'#g" \
-e "s#\(font-family=\"\)[^\"]*\"#\1$FONT_FAMILY\"#g" \
-e "1,/<g[^>]*>/s#<g[^>]*>#<g opacity=\"$opacity\">#" | \
svg=$(echo "$svg" |sed -e "s#\(font-family='\)[^']*'#\1$FONT_FAMILY'#g" \
-e "s#\(font-family=\"\)[^\"]*\"#\1$FONT_FAMILY\"#g" \
-e "1,/<g[^>]*>/s#<g[^>]*>#<g opacity=\"$opacity\">#" | \
"$BASEDIR/usvg" \
--quiet \
--indent 0 \
--skip-system-fonts \
--use-fonts-dir "$FINDWIND_FONTS_DIR" \
- "$1" || {
- -c) || {
croak 'failed to render SVG text'
return 1
}

# Handle eventual scaling (with the consistent usvg output, strict format
# assumptions works and simplifies substitions).
scale=$(get_non_empty_param Scale)
[ "$scale" -eq 100 ] || {
dimensions=${svg%% xmlns*}
width=${dimensions##*width=\"}
width=${width%%\"*}
height=${dimensions##*height=\"}
height=${height%%\"*}
newwidth=$((width * scale / 100))
newheight=$((height * scale / 100))
svg=$(echo "$svg" |sed "s/<svg width=\"$width\" height=\"$height\" xmlns/<svg width=\"$newwidth\" height=\"$newheight\" viewBox=\"0 0 $width $height\" xmlns/")
}
echo "$svg" > "$1"
}

create_tmp_svg_file() {
Expand Down
7 changes: 6 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"vendorUrl": "https://github.com/d97jro",
"vendorId": "1234567890",
"runMode": "respawn",
"version": "1.1.1",
"version": "1.1.2",
"compatibleOsVersions": [
{
"max": "13"
Expand Down Expand Up @@ -37,6 +37,11 @@
"type": "enum:topLeft|Top left, topRight|Top right, bottomLeft|Bottom left, bottomRight|Bottom right, custom|Custom position",
"default": "topLeft"
},
{
"name": "Scale",
"type": "int:min=10,max=900",
"default": "100"
},
{
"name": "CustomPositionX",
"type": "double:min=-1,max=1",
Expand Down