示例#1
0
                image_rows = restored_image.shape[0]
                image_cols = restored_image.shape[1]

                pixel_size = sensor_width / image_cols  # unit: mm/px
                pixel_size = pixel_size / 1000  # unit: m/px

                end_time = time.time()
                print("--- %s seconds ---" % (time.time() - start_time))

                read_time = end_time - start_time

            else:
                print('Read EOP - ' + file)
                print('Latitude | Longitude | Height | Omega | Phi | Kappa')
                eo = readEO(file_path)
                eo = convertCoordinateSystem(eo)
                R = Rot3D(eo)

                # 4. Extract a projected boundary of the image
                bbox = boundary(restored_image, eo, R, ground_height, pixel_size, focal_length)
                print("--- %s seconds ---" % (time.time() - start_time))

                # 5. Compute GSD & Boundary size
                # GSD
                gsd = (pixel_size * (eo[2] - ground_height)) / focal_length  # unit: m/px
                # Boundary size
                boundary_cols = int((bbox[1, 0] - bbox[0, 0]) / gsd)
                boundary_rows = int((bbox[3, 0] - bbox[2, 0]) / gsd)

                # 6. Compute coordinates of the projected boundary
import numpy as np
from EoData import readEO, Rot3D, latlon2tmcentral, tmcentral2latlon
from Boundary import pcs2ccs, projection

bbox_px = np.array([[79, 159, 159, 79],
                    [2719, 2719, 2639, 2639]])

eo_path = '../Data/DJI_0386.txt'
rows = 3000
cols = 4000
sensor_width = 6.3  # unit: mm
pixel_size = sensor_width / cols    # mm/px
focal_length = 4.7  # mm
ground_height = 65  # unit: m

eo = readEO(eo_path)
eo = latlon2tmcentral(eo)
R_GC = Rot3D(eo)
R_CG = R_GC.transpose()

# Convert pixel coordinate system to camera coordinate system
bbox_camera = pcs2ccs(bbox_px, rows, cols,
                      pixel_size, focal_length)    # shape: 3 x bbox_point

# Project camera coordinates to ground coordinates
proj_coordinates = projection(bbox_camera, eo, R_CG, ground_height)

bbox_ground1 = tmcentral2latlon(proj_coordinates[:, 0])
bbox_ground2 = tmcentral2latlon(proj_coordinates[:, 1])
bbox_ground3 = tmcentral2latlon(proj_coordinates[:, 2])
bbox_ground4 = tmcentral2latlon(proj_coordinates[:, 3])