Пример #1
0
import sfmio
import xtrelio
import geometry
import sgen
import ba_problem as ba

import rasterio
import numpy as np
import os
import time

flightMissionImages = geometry.ImageCollection(
    collectionId=0)  #creating empty collection of images with id = 0
# We create our camera:
# missionCamera = geometry.PinholeCamera(name = "myCamera" , pixelSizeMilimeters=0.004, numberOfRows = 4000, numberOfColumns= 6000, principalDistanceMilimeters = 20.0)
missionCamera = geometry.PinholeCamera(name="DJIPhantom4PRO",
                                       pixelSizeMilimeters=0.0024,
                                       numberOfRows=3648,
                                       numberOfColumns=5472,
                                       principalDistanceMilimeters=8.8)
missionCamera.setCalibrationFlags([0, 0, 0, 0])

baSettings = xtrelio.readBaSettings(
    "ExampleSimulateBaProblem/inputData/baconfig_eo_large_noise.yaml"
)  #Reading settings for our problem
outputXtrelDirectoryName = "ExampleSimulateBaProblem/baProblem"
# eozFile = "ExampleSimulateBaProblem/inputData/CaliforniaEO.txt"
eozFile = "ExampleSimulateBaProblem/inputData/EOZ_zielonki_50.txt"
sfmio.importFromExternalOrientationTextfile(
    eozFile,
    ' ',  #importing external orientation for our images
Пример #2
0
def createImageCollectionFromXtrelReport(filename, collectionId):
    reportFile = open(filename,"r")
    lines = reportFile.readlines()
    numberOfImages = 0
    #looking for line with number of images:
    for line in lines:
        if len(line) < 28:
            continue
        if line[0:27] == "Number of images          :":
            elements = line.split()
            numberOfImages = int(elements[len(elements)-1])
    
    positionOfCameras = lines.index("Cameras assignments and number of points:\n")
    cameraAssignments = {}
    cameraFiles = set()

    #reading file names of cameras
    for lineId in range(positionOfCameras+2, positionOfCameras + 2 + numberOfImages):
        elements = lines[lineId].split()
        cameraAssignments[elements[0]] = elements[1]
        cameraFiles.add(elements[1])
    
    cameras = {}
    for cameraFile in cameraFiles:
        try:
            camera = readCameraFromCamFile(cameraFile)
            cameras[cameraFile] = camera
        except:
            print("Error while reading camera from cam file")
    
    #reading coordinates of projection centers
    positionOfCoordinatesStart = lines.index("Coordinates:\n")
    projectionCenterCoordinates = {}
    for lineId in range(positionOfCoordinatesStart+2, positionOfCoordinatesStart + 2 + numberOfImages):
        elements = lines[lineId].split()
        imageId = elements[1]
        coordinates = np.zeros((3,1))
        coordinates[0,0] = float(elements[2])
        coordinates[1,0] = float(elements[3])
        coordinates[2,0] = float(elements[4])
        projectionCenterCoordinates[imageId] = coordinates

    #reading rotation
    positionOfRotationsStart = lines.index("Rotation:\n")
    anglesRad = {}
    parametrization = {}
    for lineId in range(positionOfRotationsStart+2, positionOfRotationsStart + 2 + numberOfImages):
        elements = lines[lineId].split()
        imageId = elements[1]
        angles = np.zeros(3)
        angles[0] = conv.degrees2Radians(float(elements[3]))
        angles[1] = conv.degrees2Radians(float(elements[4]))
        angles[2] = conv.degrees2Radians(float(elements[5]))
        anglesRad[imageId] = angles
        parametrization[imageId] = elements[2]

    reportFile.close()

    #building collection:
    mapRotationSequenceToName = {"om-fi-ka" : "xyz", "al-ni-ka" : "zxz" }

    collectionOfImages = geometry.ImageCollection(collectionId = collectionId)

    for imageId, position in projectionCenterCoordinates.items():
        pose = geometry.Pose()
        pose.setTranslation(position)
        pose.setRotationEuler(anglesRad[imageId], mapRotationSequenceToName[parametrization[imageId]] )
        image = geometry.Image()
        image.setPose(pose)
        image.setCamera(cameras[cameraAssignments[imageId]])
        image.rotationSequence = mapRotationSequenceToName[parametrization[imageId]]
        collectionOfImages.addImage(image, imageId)

    return collectionOfImages
Пример #3
0
                                 numberOfColumns=6000,
                                 principalDistanceMilimeters=12.0)

pose1.setRotationEuler(conv.degrees2Radians(np.array([25.0, -3.0, -0.75])),
                       'xyz')
pose1.setTranslation(projectionCenter1)

pose2.setRotationEuler(conv.degrees2Radians(np.array([0.0, -1.0, -0.55])),
                       'xyz')
pose2.setTranslation(projectionCenter2)

print("getting transformation matrix for pose 1")
print(pose1.T)

print("getting transformation matrix for pose 2")
print(pose2.T)

image1 = geometry.Image()
image1.setCamera(camera1)
image1.setPose(pose1)

image2 = geometry.Image()
image2.setCamera(camera1)
image2.setPose(pose2)

collectionOfImages = geometry.ImageCollection()
collectionOfImages.addImage(image1, "im1")
collectionOfImages.addImage(image2, "im2")

sfmio.writeImageCollectionToObj(collectionOfImages, "test.obj")
import sfmio
import xtrelio
import geometry
import rasterio
import sgen
import ba_problem as ba
import numpy as np

flightMissionImages = geometry.ImageCollection(collectionId=0)
missionCamera = geometry.PinholeCamera(name="myCamera",
                                       pixelSizeMilimeters=0.004,
                                       numberOfRows=4000,
                                       numberOfColumns=6000,
                                       principalDistanceMilimeters=20.0)
baSettings = xtrelio.readBaSettings("baconfig.yaml")
outputXtrelDirectoryName = "CaliforniaSmall"
sfmio.importFromExternalOrientationTextfile("CaliforniaSmallEO.txt",
                                            ' ',
                                            flightMissionImages,
                                            "xyz",
                                            observedPosition=False,
                                            observedOrientation=False,
                                            camera=missionCamera)
sfmio.writeImageCollectionToObj(flightMissionImages,
                                "test",
                                imageWidthInMeters=12,
                                axesLenghtInMeters=7.0)

#generating structure
dsm = rasterio.open("D:/DANE/tutorials/rasterio/opentopography/output_be.tif",
                    driver="GTiff")