Ubuntu : Itunes via Wine : rien de bon …

J’ai essayé l’installation de iTunes avec Wine sous Ubuntu.

Les versions :

J’ai eu une seule erreur, c’est lors de l’installation des fonts. Pour la fixer j’ai du faire la modification du checkum. L’erreur c’était : sha256sum mismatch! Rename .cache/winetricks/PowerPointViewer/PowerPointViewer.exe and try again.

sudo sed -i -e s/249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423/e17cb384eeac4caf08a4f5d4bceb9697fff83fa942d2a3d9ad0294a9b1774390/g /usr/bin/winetricks

L’installation des fonts :

sudo apt install winetricks
winetricks allfonts

Sachant que l’installation suivante permet d’eviter des problèmes de checksum :

sudo apt-get remove winetricks
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks 
sudo mv -v winetricks /usr/bin

L’espace que cela prend sur le disque :

$ du -sh .cache/winetricks/
350M .cache/winetricks/
$ du -sh .wine/
1,9G .wine/

Quand je lance iTunes j’ai un joli carré noir :

Bref c’est pas le top. J’ai donc lancé winecfg pour modifier et passer de Windows 7 à Windows XP.

Avec Windows XP pas de lancement de iTunes, j’ai donc mis Windows 8.1 et Windows 10 (toujours noir).

Ensuite j’ai essayé de mettre Steam :

Crash …

(Draft) Ubuntu, Jupyter Notebook, Python3, Tensorflow, OpenCV : Comptage des cyclistes avec yolo model et floutage des visages

J’ai enfin mon process complet, pour compter les cyclistes et flouter les visages dans la vidéo :

Etape 1 : Faire la vidéo avec la GoPRO.

  • Le résultat est un MP4.
  • La taille : 91 Mo
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2020-10-04T13:52:54.000000Z
encoder : HandBrake 0.9.8 2012071800
Duration: 00:01:51.44, start: 0.000000, bitrate: 6813 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 6810 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2020-10-04T13:52:54.000000Z
encoder : JVT/AVC Coding

Etape 2 : Passer Jupyter Notebook, Python3, Tensorflow, OpenCV.

  • Le résultat est un AVI.
  • La commande : tracking-yolo-model.ipynb
  • La taille : 400 Mo
Metadata:
encoder : Lavf58.58.100
Duration: 00:01:29.07, start: 0.000000, bitrate: 37644 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 37651 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc

Etape 3 : Convertir le AVI en MP4.

  • Le résultat est un MP4.
  • La commande : ffmpeg -i output-bicyle.avi output-bicyle.mp4
  • La taille : 60 Mo
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:01:29.07, start: 0.000000, bitrate: 5605 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1280x720, 5602 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler

Etape 4 : Flouter les visages via https://github.com/ORB-HD/deface

  • Le résultat est un MP4.
  • La commande : deface output-bicyle.mp4
  • La taille : 35 Mo.
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:29.07, start: 0.000000, bitrate: 3241 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 3238 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler

Etape 5 : Compresser la video pour le Web.

  • Le résultat est un MP4.
  • La commande : ffmpeg -i output-bicyle_anonymized.mp4 -c:v libx264 -b:v 1.5M -c:a aac -b:a 128k -filter:v scale=540×480 output-bicyle_anonymized_compress.mp4
  • La taille : 16 Mo.
 Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:01:29.07, start: 0.000000, bitrate: 1477 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 540x480, 1474 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler

Le résultat final :

Python facetool : Modification d’un visage par une image dans un MP4.

J’ai téléchargé https://github.com/hay/facetool afin de faire la modification des visages via une commande du type :

./facetool.py swap -i smiley.jpg -t output-bicyle.mp4 -o swap-bicyle.mp4

D’abord j’ai eu un premier problème que j’ai fixé ainsi :
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so

Et maintenant j’ai un bug dans le programme :

No faces found, could not swap (Faceswapping smiley.jpg on head-tmp-jdrmcn3j/2357.jpg, saving to out-tmp-jdrmcn3j/2357.jpg)
100%|███████████████████████████████████████████████████████████████████▉| 2671/2672 [25:15<00:00, 2.30it/s]
No faces found, could not swap (Faceswapping smiley.jpg on head-tmp-jdrmcn3j/1180.jpg, saving to out-tmp-jdrmcn3j/1180.jpg)
Traceback (most recent call last):
File "./facetool.py", line 591, in <module>
main(args)
File "./facetool.py", line 565, in main
swapper.swap_image_to_video(args.target, args.input, args.output)
File "./github/facetool/facetool/swapper.py", line 206, in swap_image_to_video
combineframes(self.tempdirs.out, out)
File "./github/facetool/facetool/media.py", line 49, in combineframes
first_file = list(glob(f"{inp}/*"))[0]
IndexError: list index out of range

Bref j’ai l’impression que cela ne détecte aucun visage :

~/github/facetool$ ls -al head-tmp-jdrmcn3j/*.jpg | wc -l
2672
~/github/facetool$ ls -al out-tmp-jdrmcn3j/*.jpg | wc -l
ls: cannot access 'out-tmp-jdrmcn3j/*.jpg': No such file or directory
0

Je vais devoir chercher ailleur.

(Draft) Ubuntu, Jupyter Notebook, Python3, Tensorflow, OpenCV : Comptage des cyclistes avec yolo model

J’ai donc pris « Yolo V3 », c’est le modèle le plus fiable. Et j’ai modifier les sources de tracking-yolo-model afin de compter seulement les cyclistes.

Je mets des ID (que j’ai remplacé par Num) seulement sur les cyclistes :

Le source est donc :

(H, W) = (None, None) # input image height and width for the network
writer = None
bicycle = 0
while(True):

ok, image = cap.read()

if not ok:
print("Cannot read the video feed.")
break

if W is None or H is None: (H, W) = image.shape[:2]

blob = cv.dnn.blobFromImage(image, 1 / 255.0, (416, 416), swapRB=True, crop=False)
net.setInput(blob)
detections_layer = net.forward(layer_names) # detect objects using object detection model

detections_bbox = [] # bounding box for detections

boxes, confidences, classIDs = [], [], []
for out in detections_layer:
for detection in out:
scores = detection[5:]
classID = np.argmax(scores)
confidence = scores[classID]

if confidence > yolomodel['confidence_threshold']:
box = detection[0:4] * np.array([W, H, W, H])
(centerX, centerY, width, height) = box.astype("int")
x = int(centerX - (width / 2))
y = int(centerY - (height / 2))

boxes.append([x, y, int(width), int(height)])
confidences.append(float(confidence))
classIDs.append(classID)

idxs = cv.dnn.NMSBoxes(boxes, confidences, yolomodel["confidence_threshold"], yolomodel["threshold"])

if len(idxs)>0:
for i in idxs.flatten():
(x, y) = (boxes[i][0], boxes[i][1])
(w, h) = (boxes[i][2], boxes[i][3])
if (labels[classIDs[i]] == 'bicycle'):
detections_bbox.append((x, y, x+w, y+h))
clr = [int(c) for c in bbox_colors[classIDs[i]]]
cv.rectangle(image, (x, y), (x+w, y+h), clr, 2)
cv.putText(image, "{}: {:.4f}".format(labels[classIDs[i]], confidences[i]),
(x, y-5), cv.FONT_HERSHEY_SIMPLEX, 0.5, clr, 2)

objects = tracker.update(detections_bbox) # update tracker based on the newly detected objects

for (objectID, centroid) in objects.items():
text = "Num {}".format(objectID)
if (int(format(objectID)) > bicycle):
bicycle = int(format(objectID))
text2 = "Total %d "%(bicycle+1)
cv.putText(image, text, (centroid[0] - 10, centroid[1] - 10), cv.FONT_HERSHEY_SIMPLEX,
0.5, (0, 255, 0), 2)
cv.circle(image, (centroid[0], centroid[1]), 4, (0, 255, 0), -1)
cv.putText(image, text2, (30, 30), cv.FONT_HERSHEY_SIMPLEX,
1, (0, 0, 255), 3)

cv.imshow("image", image)

if cv.waitKey(1) & 0xFF == ord('q'):
break

if writer is None:
fourcc = cv.VideoWriter_fourcc(*"MJPG")
writer = cv.VideoWriter("output-bicyle.avi", fourcc, 30, (W, H), True)
writer.write(image)
writer.release()
cap.release()
cv.destroyWindow("image")

Cette fois je compte en double des cyclistes, je pense qu’avec plus d’images par seconde je n’aurai pas eu le problème. J’ai un total de 280 cyclistes.

Mon modèle est le suivant :

yolomodel = {"config_path":"../pretrained_models/yolo_weights/yolov3.cfg",
"model_weights_path":"../pretrained_models/yolo_weights/yolov3.weights",
"coco_names":"../pretrained_models/yolo_weights/coco.names",
"confidence_threshold": 0.5,
"threshold":0.3
}

Si je change de modèle pour mettre :

yolomodel = {"config_path":"../pretrained_models/yolo_weights/yolov3.cfg",
"model_weights_path":"../pretrained_models/yolo_weights/yolov3.weights",
"coco_names":"../pretrained_models/yolo_weights/coco.names",
"confidence_threshold": 0.6,
"threshold":0.4
}

Le résultat est le suivant : 238 cyclistes (à la place de 280).

Si je continue d’augmenter de la facon suivante :

yolomodel = {"config_path":"../pretrained_models/yolo_weights/yolov3.cfg",
"model_weights_path":"../pretrained_models/yolo_weights/yolov3.weights",
"coco_names":"../pretrained_models/yolo_weights/coco.names",
"confidence_threshold": 0.75,
"threshold":0.5
}

Le résultat est le suivant : 209 cyclistes, je pense que c’est proche de la réalité.

Quand j’ai 0,75 je détecte de facon plus proche et j’ai donc moins d’erreur sur le suivi du numéro. Par contre ensuite j’ai à nouveau des doublons si j’essaye d’augmenter encore la valeur.

A suivre.