Python : matplotlib : Issue line 303 text.parse_math

Sur Kali OS j’ai eu cette erreur :


Bad key text.parse_math in file /usr/share/matplotlib/mpl-data/matplotlibrc, line 303 ('text.parse_math: False # Use mathtext if there is an even number of unescaped')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.5.2/matplotlibrc.template
or from the matplotlib source distribution
Traceback (most recent call last):
File "....Test.py", line 31, in <module>
import gradio as gr
File "/usr/local/lib/python3.11/dist-packages/gradio/__init__.py", line 3, in <module>
import gradio._simple_templates
File "/usr/local/lib/python3.11/dist-packages/gradio/_simple_templates/__init__.py", line 1, in <module>
from .simpledropdown import SimpleDropdown
File "/usr/local/lib/python3.11/dist-packages/gradio/_simple_templates/simpledropdown.py", line 6, in <module>
from gradio.components.base import FormComponent
File "/usr/local/lib/python3.11/dist-packages/gradio/components/__init__.py", line 1, in <module>
from gradio.components.annotated_image import AnnotatedImage
File "/usr/local/lib/python3.11/dist-packages/gradio/components/annotated_image.py", line 11, in <module>
from gradio import processing_utils, utils
File "/usr/local/lib/python3.11/dist-packages/gradio/processing_utils.py", line 23, in <module>
from gradio.utils import abspath
File "/usr/local/lib/python3.11/dist-packages/gradio/utils.py", line 38, in <module>
import matplotlib
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 880, in <module>
rcParamsDefault = _rc_params_in_file(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 814, in _rc_params_in_file
config[key] = val # try to convert to proper type or raise
~~~~~~^^^^^
File "/usr/lib/python3/dist-packages/matplotlib/__init__.py", line 650, in __setitem__
raise ValueError(f"Key {key}: {ve}") from None
ValueError: Key grid.color: '"' does not look like a color arg

J’ai donc edité le fichier /usr/share/matplotlib/mpl-data/matplotlibrc pour mettre en commentaire la ligne ( sachant que False ou True on a la même erreur) :


##text.parse_math: True

Mais je suis pas sûr que cela fixe le problème … cela plante un peu plus loin.

Linux/Python : Merge d’un GPX et d’une video

Etape 1 : Installation : https://pypi.org/project/gopro-overlay/

$ python3 -m venv venv
$ venv/bin/pip install gopro-overlay
$ mkdir ~/.gopro-graphics/
$ cat ~/.gopro-graphics/ffmpeg-profiles.json
{
  "overlay": {
    "input": [],
    "output": ["-vcodec", "png"]
  }
}

Etape 2 : Premier test et premier drame

$ venv/bin/gopro-dashboard.py --use-gpx-only --gpx Nextcloud/Pipe/Video/BoucleResideo.gpx 1920x1080 Nextcloud/Pipe/Video/BoucleResideo.mov 
Starting gopro-dashboard version 0.100.0
ffmpeg version is 4.4.2-0ubuntu0.22.04.1
Using Python version 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
Traceback (most recent call last):
  File "/home/arias/venv/bin/gopro-dashboard.py", line 107, in 
    font = load_font(args.font)
  File "/home/arias/venv/lib/python3.10/site-packages/gopro_overlay/font.py", line 5, in load_font
    return ImageFont.truetype(font=font, size=size)
  File "/home/arias/venv/lib/python3.10/site-packages/PIL/ImageFont.py", line 1008, in truetype
    return freetype(font)
  File "/home/arias/venv/lib/python3.10/site-packages/PIL/ImageFont.py", line 1005, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/arias/venv/lib/python3.10/site-packages/PIL/ImageFont.py", line 255, in __init__
    self.font = core.getfont(
OSError: cannot open resource

Etape 2b : Avec copie de la « font »

$ venv/bin/gopro-dashboard.py --use-gpx-only --gpx Nextcloud/Pipe/Video/BoucleResideo.gpx --overlay-size 1920x1080 Nextcloud/Pipe/Video/BoucleResideo.mov --font Nextcloud/Pipe/Video/Roboto-Medium.ttf 
Starting gopro-dashboard version 0.100.0
ffmpeg version is 4.4.2-0ubuntu0.22.04.1
Using Python version 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
GPX/FIT file:     2023-07-05T17:51:34+00:00 -> 2023-07-05T18:02:30+00:00
Timer(loading timeseries - Called: 1, Total: 2.99467, Avg: 2.99467, Rate: 0.33)
Generating overlay at Dimension(x=1920, y=1080)
Timeseries has 6561 data points
Processing....
Timer(processing - Called: 1, Total: 4.25000, Avg: 4.25000, Rate: 0.24)
FFMPEG Output is in /tmp/tmpkga_2k5h
Timelapse Factor = 1.000
Layout -> Include component 'date_and_time' = True
Layout -> Include component 'gps_info' = True
Layout -> Include component 'gps-lock' = True
Layout -> Include component 'big_mph' = True
Layout -> Include component 'gradient_chart' = True
Layout -> Include component 'gradient' = True
Layout -> Include component 'altitude' = True
Layout -> Include component 'temperature' = True
Layout -> Include component 'cadence' = True
Layout -> Include component 'heartbeat' = True
Layout -> Include component 'moving_map' = True
Layout -> Include component 'journey_map' = True
Executing 'ffmpeg -hide_banner -y -hide_banner -loglevel info -f rawvideo -framerate 10.0 -s 1920x1080 -pix_fmt rgba -i - -r 30 -vcodec libx264 -preset veryfast Nextcloud/Pipe/Video/BoucleResideo.mov'
...

Etape 3 : Shotcut : https://shotcut.org/

 

Python/BRISQUE : Voir la « qualité » des photos NEXTCLOUD avec un script

C’est pas vraiment top, dès qu’il y a de l’herbe j’ai la valeur > 100. C’était donc une fausse bonne idée …

Voici le script que j’ai fait :

#!/usr/bin/env python3.6
from libsvm import svmutil
from brisque import *
import sys
import os.path
import glob

brisq = BRISQUE()

for filename in glob.iglob('./Nextcloud/Photos/**', recursive=True):
     if (filename.endswith('.jpg')):
         temp=brisq.get_score(filename)
         if (temp > 100):
             print(filename)
             print(temp)

Par exemple : BRISQUE = 107.82606599602599 pour cette photo :

 

Python/OpenCV : Brouillon : Détection des contours du blob

C’est pas gagné pour faire la détection du contour du blob (en mv4) :

J’ai des problèmes de jaune 🙁

import cv2
import numpy as np 
import matplotlib.pyplot as plt
....
        frame_hsv=cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

        low_yellow=np.array([10, 125, 100])
        upper_yellow=np.array([60, 220, 220])
        mask_yellow=cv2.inRange(frame_hsv,low_yellow,upper_yellow)

        list_masks=[mask_yellow]
        for i,mask in enumerate(list_masks):

            contours, _=cv2.findContours(mask,cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE)

Sans le polygone (et en mp4):

A suivre.