I have ~100 jpeg images taken by a Drone. I tried to use gdal_merge
to merge them and create a big tile GeoTIFF image. gdal_merge spends lots of time, and in the end, it just put each jpeg image precisely on top of the previous one. The GeoTIFF result shows the last jpeg file.
I tried to diagnose the problem and used gdalinfo
. I found the jpeg files include full GPS EXIF data, but they do not have proper corner coordinates. That means the corner coordinate of all jpeg images shows like below:
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 3648.0)
Upper Right ( 4864.0, 0.0)
Lower Right ( 4864.0, 3648.0)
Center ( 2432.0, 1824.0)
Is there any way to use GDAL to extract Corner Coordinates based on GPS coordination in the jpg’s EXIF file?
I know OpenDroneMap uses the GDAL and perfectly merges Drone images. I just don’t know how it extracts Corner Coordinates from EXIF? Below link is an example (images are in the images folder):
https://github.com/OpenDroneMap/odm_data_aukerman
Per @Spacedman ask, here is the full extract from gdalinfo
. The sample image is here: https://github.com/OpenDroneMap/odm_data_aukerman/blob/master/images/DSC00229.JPG
OpenDroneMap can perfectly merge the images in the sample meantioned above. However, gdal_merge fails since it cannot figure out Corner Coordinates (my guess)
Driver: JPEG/JPEG JFIF
Files: 0.JPG
Size is 4896, 3672
Coordinate System is `'
Metadata:
EXIF_BrightnessValue=(7.53672)
EXIF_ColorSpace=1
EXIF_ComponentsConfiguration=0x01 0x02 0x03 0x00
EXIF_CompressedBitsPerPixel=(3)
EXIF_Contrast=0
EXIF_CustomRendered=0
EXIF_DateTime=2016:06:29 10:47:04
EXIF_DateTimeDigitized=2016:06:29 10:47:04
EXIF_DateTimeOriginal=2016:06:29 10:47:04
EXIF_DigitalZoomRatio=(1)
EXIF_ExifVersion=0230
EXIF_ExposureBiasValue=(0)
EXIF_ExposureMode=0
EXIF_ExposureProgram=2
EXIF_ExposureTime=(0.004)
EXIF_FileSource=0x03
EXIF_Flash=16
EXIF_FlashpixVersion=0100
EXIF_FNumber=(3.3)
EXIF_FocalLength=(4.45)
EXIF_GPSAltitude=(346.315)
EXIF_GPSLatitude=(41) (18) (13.7576)
EXIF_GPSLatitudeRef=N
EXIF_GPSLongitude=(81) (45) (1.6792)
EXIF_GPSLongitudeRef=W
EXIF_ImageDescription=
EXIF_Interoperability_Index=R98
EXIF_Interoperability_Version=0x30 0x31 0x30 0x30
EXIF_ISOSpeedRatings=100
EXIF_LensSpecification=(4.45) (44.5) (3.3) (5.9)
EXIF_LightSource=0
EXIF_Make=SONY
EXIF_MakerNote=SONY DSC
EXIF_MaxApertureValue=(3.44531)
EXIF_MeteringMode=5
EXIF_Model=DSC-WX220
EXIF_PixelXDimension=4896
EXIF_PixelYDimension=3672
EXIF_RecommendedExposureIndex=100
EXIF_ResolutionUnit=2
EXIF_Saturation=0
EXIF_SceneCaptureType=0
EXIF_SceneType=0x01
EXIF_SensitivityType=2
EXIF_Sharpness=0
EXIF_Software=eBee
EXIF_UserComment=
EXIF_WhiteBalance=0
EXIF_XResolution=(350)
EXIF_YCbCrPositioning=2
EXIF_YResolution=(350)
Image Structure Metadata:
COMPRESSION=JPEG
INTERLEAVE=PIXEL
SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 3672.0)
Upper Right ( 4896.0, 0.0)
Lower Right ( 4896.0, 3672.0)
Center ( 2448.0, 1836.0)
Band 1 Block=4896x1 Type=Byte, ColorInterp=Red
Overviews: 2448x1836, 1224x918, 612x459, 160x120
Image Structure Metadata:
COMPRESSION=JPEG
Band 2 Block=4896x1 Type=Byte, ColorInterp=Green
Overviews: 2448x1836, 1224x918, 612x459, 160x120
Image Structure Metadata:
COMPRESSION=JPEG
Band 3 Block=4896x1 Type=Byte, ColorInterp=Blue
Overviews: 2448x1836, 1224x918, 612x459, 160x120
Image Structure Metadata:
COMPRESSION=JPEG
@RoVo should note that this has to be part of a batch process. I cannot use QGIS or interactive tools.
I am aware of so many commercial tools and products that can do this.
I am asking if I can use GDAL to solve this problem.
Answer
No, you can't use GDAL to do this because it is beyond the scope of GDAL.
You can use GDAL to read in the file, you can then use some mathematical expressions to work out the corner coordinates from the metadata, and then you can use GDAL to write a georeferenced file out.
You can use any programming language that supports the GDAL API to do this - C++, Python being the most popular.
No comments:
Post a Comment