g.gui.iphoto2image.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/usr/bin/env python
  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: aerial
  24. #% keyword: photo
  25. #% keyword: GUI
  26. #%end
  27. #%option G_OPT_I_GROUP
  28. #% key: group
  29. #% required: yes
  30. #%end
  31. #%option G_OPT_R_INPUT
  32. #% key: raster
  33. #% required: yes
  34. #%end
  35. #%option
  36. #% key: camera
  37. #% type: string
  38. #% label: The name of the camera (generated in i.ortho.camera)
  39. #% description: The name of the camera (generated in i.ortho.camera)
  40. #% required: yes
  41. #%end
  42. #%option
  43. #% key: order
  44. #% type: string
  45. #% label: The rectification order (no of Fiducial=4 -> order=1, no of Fiducial=8 -> order=2)
  46. #% description: The rectification order (no of Fiducial=4 -> order=1, no of Fiducial=8 -> order=2)
  47. #% required: yes
  48. #% answer: 1
  49. #%end
  50. #%option
  51. #% key: extension
  52. #% type: string
  53. #% label: The name of the output files extension (used in i.rectify)
  54. #% description: The name of the output files extension (used in i.rectify)
  55. #% required: yes
  56. #% answer: _ip2i_out
  57. #%end
  58. """
  59. Module to run GCP management tool as stadalone application.
  60. @author Vaclav Petras <wenzeslaus gmail.com> (standalone module)
  61. """
  62. import os
  63. import grass.script as gscript
  64. def main():
  65. """Sets the GRASS display driver
  66. """
  67. options, flags = gscript.parser()
  68. import wx
  69. from grass.script.setup import set_gui_path
  70. set_gui_path()
  71. from core.settings import UserSettings
  72. from core.globalvar import CheckWxVersion
  73. from core.giface import StandaloneGrassInterface
  74. from iphoto2image.ip2i_manager import GCPWizard
  75. driver = UserSettings.Get(group='display', key='driver', subkey='type')
  76. if driver == 'png':
  77. os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
  78. else:
  79. os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'
  80. if options['group']:
  81. group = options['group']
  82. else:
  83. gscript.fatal(_("Please provide a group name to process"))
  84. if options['raster']:
  85. raster = options['raster']
  86. else:
  87. gscript.fatal(_("Please provide a raster map name to process"))
  88. if options['camera']:
  89. camera = options['camera']
  90. else:
  91. gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))
  92. if options['order']:
  93. order = options['order']
  94. else:
  95. gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"))
  96. if options['extension']:
  97. extension = options['extension']
  98. else:
  99. gscript.fatal(_("Please provive an output files extension (used by i.rectify)"))
  100. app = wx.App()
  101. if not CheckWxVersion([2, 9]):
  102. wx.InitAllImageHandlers()
  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()