Browse Source

[enh] Exif information in JPG + GPS

Pierre Bourdin 1 year ago
parent
commit
8dc66cf115
8 changed files with 79 additions and 5 deletions
  1. 17 0
      active_nmea.py
  2. BIN
      annonce_start.wav
  3. BIN
      annonce_stop.wav
  4. 14 0
      convert_ll_dec.py
  5. 29 0
      process/1_capture
  6. 2 0
      process/2_convert
  7. 6 5
      process/3_transmit
  8. 11 0
      read_nmea.py

+ 17 - 0
active_nmea.py

@@ -0,0 +1,17 @@
+#!/usr/bin/python3
+
+import serial
+
+st="PMTK314,0,1,1,0,0,0,0,0,0,0,0,0,0,0"
+EOL = "\r\n"
+serial = serial.Serial("/dev/ttyAMA0", 38400)
+
+i = 0
+checksum = 0
+while i < len(st):
+   checksum ^= ord(st[i])
+   i+= 1
+
+data = bytes("$" + st + "*" + "%02X"%checksum + EOL, 'ascii')
+serial.write(data)
+print(data)

BIN
annonce_start.wav


BIN
annonce_stop.wav


+ 14 - 0
convert_ll_dec.py

@@ -0,0 +1,14 @@
+#!/usr/bin/python3
+import sys
+
+deg = float(sys.argv[1])
+
+m, s = divmod(abs(deg)*3600, 60)
+d, m = divmod(m, 60)
+if deg < -1:
+    d = -d
+d, m = int(d), int(m)
+
+print("d:"+str(d))
+print("m:"+str(m))
+print("s:{:.6f}".format(s));

+ 29 - 0
process/1_capture

@@ -1,7 +1,36 @@
 #!/bin/bash
 
 DATE=$(date +%y%m%d_%H%M%S)
+../read_nmea.py > /ramfs/.out
 raspistill -o /ramfs/$DATE.jpg
+
+DATA=$(cat /ramfs/.out)
+NS=$(echo $DATA| tr ' ' '\n' | grep NS | cut -d'=' -f2 | cut -d',' -f1)
+EW=$(echo $DATA| tr ' ' '\n' | grep EW | cut -d'=' -f2 | cut -d',' -f1)
+
+LAT=$(echo $DATA| tr ' ' '\n' | grep 'lat=' | cut -d'=' -f2 | cut -d',' -f1)
+LATD=$(../convert_ll_dec.py $LAT | grep "d:" | cut -d':' -f1)
+LATM=$(../convert_ll_dec.py $LAT | grep "d:" | cut -d':' -f1)
+LATS=$(../convert_ll_dec.py $LAT | grep "d:" | cut -d':' -f1)
+
+LON=$(echo $DATA| tr ' ' '\n' | grep 'lon=' | cut -d'=' -f2 | cut -d',' -f1)
+LOND=$(../convert_ll_dec.py $LON| grep "d:" | cut -d':' -f1)
+LONM=$(../convert_ll_dec.py $LON | grep "d:" | cut -d':' -f1)
+LONS=$(../convert_ll_dec.py $LON | grep "d:" | cut -d':' -f1)
+
+# Creation du script pour ajout des données Exif dans le JPG
+cat <<EOF > /ramfs/.conf_exif
+    # Ajouter aux metadatas les informations de geolocalisation
+    # 'add' pour ajouter les informations
+    # 'set' pour remplacer celles déjà exisante
+    # 'del' pour les supprimer (sans préciser de valeur)
+    add Exif.GPSInfo.GPSLatitudeRef ${NS}
+    add Exif.GPSInfo.GPSLatitude ${LATD}/1 ${LATM}/1 ${LATS}/6
+    add Exif.GPSInfo.GPSLongitudeRef ${EW}
+    add Exif.GPSInfo.GPSLongitude ${LOND}/1 ${LONM}/1 ${LONS}/6
+EOF
+
+exiv2 -m /ramfs/.conf_exif /ramfs/$DATE.jpg
 echo "Picz $DATE.jpg saved in RAM"
 cp /ramfs/$DATE.jpg ~/_Pictures
 echo "Picz $DATE.jpg saved to SDCARD"

+ 2 - 0
process/2_convert

@@ -5,3 +5,5 @@ cd /ramfs
 FILE=$(find ./ -type f -name *.jpg)
 convert $FILE -resize 640x496^ lit-$(echo $FILE | cut -d"/" -f2)
 rm -rf $FILE
+
+mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 26 -gravity NorthEast -annotate +10+10 "$(date) - F4IYQ - 73 ;)" *.jpg

+ 6 - 5
process/3_transmit

@@ -23,22 +23,23 @@ deactivate
 
 raspi-gpio set 4 dl
 sleep 1
-
 echo " => Playing WAV file"
-# TXT_TO_WFALL
+ TXT_TO_WFALL
 cd ~/trxamadrmv3_7/linux
 ./txwfal 0
 sleep 1
-espeak "Radio station S S T V"
+aplay ~/BallonSonde/annonce_start.wav
 sleep 1
 aplay /ramfs/out.wav
+aplay ~/BallonSonde/annonce_stop.wav
 raspi-gpio set 4 dh
-espeak "End of transmission"
+
 
 #############
 # Mode DRM
 #cd ~/trxamadrmv3_7/linux/
-#(./drm $IMG; raspi-gpio set 4 dh)
+#./drm $IMG
+#raspi-gpio set 4 dh
 
 
 echo " => All done, cleaning ramfs"

+ 11 - 0
read_nmea.py

@@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+import serial
+from pynmeagps import NMEAReader
+
+stream = serial.Serial('/dev/ttyAMA0', 38400, timeout=3)
+nmr = NMEAReader(stream)
+(raw_data, parsed_data) = nmr.read()
+print(parsed_data)
+
+