2_convert 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. #IMG=$(cd /ramfs; find ./ -type f -name *.jpg -exec readlink -f {} \;)
  3. #IMG=$(ls -t /home/pi/_Pictures | head -1)
  4. source ~/BallonSonde/variables.sh
  5. while [[ ! -f /ramfs/.canbeconvert ]]; do
  6. sleep 1
  7. echo "wait for file to convert..."
  8. done
  9. IMG=$(cat /ramfs/.canbeconvert)
  10. echo "=> File $IMG detected !"
  11. #############
  12. # Mode SSTV
  13. while [[ -f "/ramfs/totx.wav" ]]; do
  14. echo "=> Skipping convert, because old one is not yet Txed !"
  15. sleep 5
  16. done
  17. # On traite l'image...
  18. if [[ $FULL_RAW_RES = 1 ]]
  19. then
  20. echo "=> Converting to PD1x0 Format 640x496"
  21. convert $DEFAULT_RAW_PATH/$IMG -resize 640x496^ /ramfs/lit-$IMG
  22. else
  23. echo "=> Already to the right format, do nothing"
  24. fi
  25. echo "=> Adding annotaion"
  26. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 28 -gravity NorthEast -annotate +0+0 "$SSTV_BANNER" -draw "image Over 525,350 90,117 '$DEFAULT_PATH/img/ussel.png'" /ramfs/lit-$IMG
  27. if [[ $HAVE_GPS = 1 ]]
  28. then
  29. echo "=> Adding GPS Position"
  30. # On cherche à voir si on a la position GPS ou non dans le exif
  31. exiftool $DEFAULT_RAW_PATH/$IMG | grep -e "GPS Position" -e "GPS Altitude"
  32. if [[ $? -eq 0 ]]
  33. then
  34. GPS_POS=$(exiftool $DEFAULT_RAW_PATH/$IMG | grep "GPS Position" | cut -d":" -f2)
  35. # many parameters GPS Altitude Ref and GPS Altitude. Keep with spaces for grep
  36. ALTITUDE=$(exiftool $DEFAULT_RAW_PATH/$IMG | grep "GPS Altitude " | cut -d":" -f2 | cut -d" " -f2)
  37. GPS_DATE=$(exiftool $DEFAULT_RAW_PATH/$IMG | grep "GPS Date/Time" | cut -d":" -f2-)
  38. if [[ -n ${GPS_POS:-} ]]
  39. then
  40. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +0+448 "$GPS_DATE / Altitude : $ALTITUDE m" /ramfs/lit-$IMG
  41. mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +0+472 "$GPS_POS" /ramfs/lit-$IMG
  42. else
  43. echo "=> No GPS Position found"
  44. fi
  45. else
  46. echo "=> No GPS Position found"
  47. # Pas beau de mettre no gps, on commente
  48. #mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+410 "Altitude : Unknown" /ramfs/lit-$IMG
  49. #mogrify -format 'jpg' -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 24 -gravity NorthEast -annotate +40+450 "NO GPS." /ramfs/lit-$IMG
  50. fi
  51. else
  52. echo "=> HAVE_GPS = 0, add nothing"
  53. fi
  54. echo " => Converting image to WAV..."
  55. cd ~/PySSTV/
  56. source bin/activate
  57. #time python -m pysstv --mode PD120 --rate 44800 --bits 16 --vox --fskid $INDICATIF /ramfs/lit-$IMG /ramfs/totx.wav
  58. time ~/libsstv/bin/sstv-encode pd180 /ramfs/lit-$IMG /ramfs/totx.wav
  59. deactivate
  60. echo "=> Setting flag that can be Tx"
  61. touch /ramfs/.canbetx
  62. rm -rf /ramfs/lit-$IMG
  63. echo -n ""