1_capture 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. CONVERTLL_PATH="/home/pi/BallonSonde/convert_ll_dec.py"
  3. READ_NMEA_PATH="/home/pi/BallonSonde/read_nmea.py"
  4. echo "=> Acquisition on !"
  5. DATE=$(date +%y%m%d_%H%M%S)
  6. $READ_NMEA_PATH > /ramfs/.out
  7. acquire() {
  8. DATA=$(cat /ramfs/.out)
  9. NS=$(echo $DATA| tr ' ' '\n' | grep NS | cut -d'=' -f2 | cut -d',' -f1)
  10. EW=$(echo $DATA| tr ' ' '\n' | grep EW | cut -d'=' -f2 | cut -d',' -f1)
  11. LAT=$(echo $DATA| tr ' ' '\n' | grep 'lat=' | cut -d'=' -f2 | cut -d',' -f1)
  12. echo "Latitude $LAT"
  13. LATD=$($CONVERTLL_PATH $LAT | grep "d:" | cut -d':' -f2)
  14. LATM=$($CONVERTLL_PATH $LAT | grep "m:" | cut -d':' -f2)
  15. LATS=$($CONVERTLL_PATH $LAT | grep "s:" | cut -d':' -f2 | sed 's/\.//' )
  16. echo "$LATD $LATM $LATS"
  17. LON=$(echo $DATA| tr ' ' '\n' | grep 'lon=' | cut -d'=' -f2 | cut -d',' -f1)
  18. echo "Longitude : $LON"
  19. LOND=$($CONVERTLL_PATH $LON| grep "d:" | cut -d':' -f2)
  20. LONM=$($CONVERTLL_PATH $LON | grep "m:" | cut -d':' -f2)
  21. LONS=$($CONVERTLL_PATH $LON | grep "s:" | cut -d':' -f2 | sed 's/\.//')
  22. echo "$LOND $LONM $LONS"
  23. ALTITUDE=$(echo $DATA| tr ' ' '\n' | grep 'alt=' | cut -d'=' -f2 | cut -d',' -f1)
  24. echo "$ALTITUDE meters ! Wooo so hiiigh !"
  25. # Creation du script pour ajout des données Exif dans le JPG
  26. cat <<EOF > /ramfs/.conf_exif
  27. # Ajouter aux metadatas les informations de geolocalisation
  28. # 'add' pour ajouter les informations
  29. # 'set' pour remplacer celles déjà exisante
  30. # 'del' pour les supprimer (sans préciser de valeur)
  31. add Exif.GPSInfo.GPSLatitudeRef ${NS}
  32. add Exif.GPSInfo.GPSLatitude ${LATD}/1 ${LATM}/1 ${LATS}/10000
  33. add Exif.GPSInfo.GPSLongitudeRef ${EW}
  34. add Exif.GPSInfo.GPSLongitude ${LOND}/1 ${LONM}/1 ${LONS}/10000
  35. EOF
  36. echo $LAT
  37. if [ "$LAT" == "NO_DATA" ]; then
  38. echo "Don't have GPS datas, continue without these datas"
  39. else
  40. exiv2 -m /ramfs/.conf_exif /ramfs/$DATE.jpg
  41. exiftool -GPSAltitude=$ALTITUDE /ramfs/$DATE.jpg -overwrite_original
  42. fi
  43. echo "Picz $DATE.jpg saved in RAM"
  44. cp /ramfs/$DATE.jpg ~/_Pictures
  45. mv /ramfs/$DATE.jpg /ramfs/$DATE.jp_
  46. rm -rf /ramfs/*.jpg
  47. mv /ramfs/$DATE.jp_ /ramfs/$DATE.jpg
  48. echo "Picz $DATE.jpg saved to SDCARD"
  49. echo "$DATE.jpg" > /ramfs/.canbeconvert
  50. echo "Sleeping... zzzZZZzzZZZzzz..."
  51. sleep 5
  52. }
  53. raspistill -o /ramfs/$DATE.jpg
  54. if [ $? -eq 0 ]; then
  55. acquire
  56. else
  57. echo "Command failed"
  58. /home/pi/BallonSonde/tx_process/4_tx_file /home/pi/BallonSonde/sound/error_camera.wav
  59. fi