1_capture~ 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. mv /ramfs/$DATE.jpg ~/_Pictures
  45. echo "Picz $DATE.jpg saved to SDCARD"
  46. echo "$DATE.jpg" > /ramfs/.canbeconvert
  47. echo "Sleeping... zzzZZZzzZZZzzz..."
  48. }
  49. raspistill -o /ramfs/$DATE.jpg
  50. #if [ $? -eq 0 ]; then
  51. acquire
  52. #else
  53. # echo "Command failed"
  54. #fi
  55. #