g.gui.photo2image.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/usr/bin/env python3
  2. ############################################################################
  3. #
  4. # MODULE: Correcting distortions of a scanned photo (modified from GCP Manager)
  5. # AUTHOR(S): Yann modified the code (was Markus Metz for the GCP Manager)
  6. # PURPOSE: Takes a scanned photo and fits fiducial points to known geometry
  7. # COPYRIGHT: (C) 2012-2017 by Markus Metz, and the GRASS Development Team
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. ############################################################################
  20. #%module
  21. #% description: Corrects scanning distortions of a paper photo.
  22. #% keyword: imagery
  23. #% keyword: GUI
  24. #% keyword: aerial
  25. #% keyword: photo
  26. #% keyword: georectification
  27. #% keyword: geometry
  28. #% keyword: GCP
  29. #%end
  30. #%option G_OPT_I_GROUP
  31. #% key: group
  32. #% required: yes
  33. #%end
  34. #%option G_OPT_R_INPUT
  35. #% key: raster
  36. #% required: yes
  37. #%end
  38. #%option
  39. #% key: camera
  40. #% type: string
  41. #% label: The name of the camera (generated in i.ortho.camera)
  42. #% description: The name of the camera (generated in i.ortho.camera)
  43. #% required: yes
  44. #%end
  45. #%option
  46. #% key: order
  47. #% type: string
  48. #% label: The rectification order (no of Fiducial=4 -> order=1, no of Fiducial=8 -> order=2)
  49. #% description: The rectification order (no of Fiducial=4 -> order=1, no of Fiducial=8 -> order=2)
  50. #% required: yes
  51. #% answer: 1
  52. #%end
  53. #%option
  54. #% key: extension
  55. #% type: string
  56. #% label: The name of the output files extension (used in i.rectify)
  57. #% description: The name of the output files extension (used in i.rectify)
  58. #% required: yes
  59. #% answer: _ip2i_out
  60. #%end
  61. """
  62. Module to run GCP management tool as stadalone application.
  63. @author Vaclav Petras <wenzeslaus gmail.com> (standalone module)
  64. """
  65. import os
  66. import grass.script as gscript
  67. def main():
  68. """Sets the GRASS display driver
  69. """
  70. options, flags = gscript.parser()
  71. import wx
  72. from grass.script.setup import set_gui_path
  73. set_gui_path()
  74. from core.settings import UserSettings
  75. from core.giface import StandaloneGrassInterface
  76. from photo2image.ip2i_manager import GCPWizard
  77. driver = UserSettings.Get(group='display', key='driver', subkey='type')
  78. if driver == 'png':
  79. os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
  80. else:
  81. os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
  82. if options['group']:
  83. group = options['group']
  84. else:
  85. gscript.fatal(_("Please provide a group name to process"))
  86. if options['raster']:
  87. raster = options['raster']
  88. else:
  89. gscript.fatal(_("Please provide a raster map name to process"))
  90. if options['camera']:
  91. camera = options['camera']
  92. else:
  93. gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))
  94. if options['order']:
  95. order = options['order']
  96. else:
  97. gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"))
  98. if options['extension']:
  99. extension = options['extension']
  100. else:
  101. gscript.fatal(_("Please provive an output files extension (used by i.rectify)"))
  102. app = wx.App()
  103. wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), group=group,
  104. raster=raster, raster1=raster, camera=camera, order=order, extension=extension)
  105. app.MainLoop()
  106. if __name__ == '__main__':
  107. main()