Aerotriangulation. problem with importing data from csv file

Hi,

I got a problem with aerotriangulation results when importing data from an external CSV file. I mean when I make aerotriangulation with the addPhotoInAutoMode method everything is fine. But when I try to import GPS data from external CSV file earotriangulation works but its results are different. Tie points are rotated differently in regards to the word matrix.

These are aerotriangulation results when I got metadata from xlif.

And these are results when I use external csv file:

These are CSV data samples:

Name Alt Lat Long
DSC00634_t.JPG 1064.658 46.40924 -114.13910000000001
DSC00541_t.JPG 1075.346 46.40921 -114.13900000000001
DSC00756_t.JPG 1062.16 46.40916 -114.13900000000001
DSC00675_t.JPG 1070.784 46.40903 -114.13910000000001
DSC00366_t (1).JPG 1075.73 46.409099999999995 -114.13910000000001

My code look like this:

    # --------------------------------------------------------------------
    # create project
    # --------------------------------------------------------------------
    projectName = os.path.basename(config['aerotriangulationDirPath'])
    project = ccmasterkernel.Project()
    project.setName(projectName)
    project.setDescription('Automatically generated from python script')
    project.setProjectFilePath(os.path.join(config['aerotriangulationDirPath'], projectName))
    err = project.writeToFile()
    if not err.isNone():
        print(err.message)
        sys.exit(0)
   
    print('Project %s successfully created.' % projectName)
    print('')
   
    inputSRS = ccmasterkernel.SRS("WGS84")
    ECEF_SRS = ccmasterkernel.SRS("EPSG:4978")
    toECEF = ccmasterkernel.SRSTransformation(inputSRS, ECEF_SRS)
   
    ################
   
    # block = createBlock(project)
   
    # --------------------------------------------------------------------
    # create block
    # --------------------------------------------------------------------
    block=ccmasterkernel.Block(project)
    block.setPositioningLevel(ccmasterkernel.PositioningLevel.PositioningLevel_georeferenced)
    project.addBlock(block)
   
    photogroups = block.getPhotogroups()
    photogroups.addPhotogroup( ccmasterkernel.Photogroup() )
    photogroup = photogroups.getPhotogroup(photogroups.getNumPhotogroups() - 1)
   
    # --------------------------------------------------------------------
    # parse input txt file
    # --------------------------------------------------------------------
    firstPhoto = True
    inputFilePath = getPhotoLocationsFilePath()
    with open(inputFilePath, 'r') as csvfile:
        rd = csv.reader(csvfile, skipinitialspace=True)
        next(rd)
        for row in rd:
            inputP = ccmasterkernel.Point3d(float(row[2]), float(row[1]), float(row[3]))
            ecefP = toECEF.transform(inputP)
           
            if ecefP == None:
                print('Invalid coordinates')
                sys.exit(0)
               
            imageFilePath = os.path.join(
                os.path.dirname(config['photosDirPath']), row[0])
           
            if not os.path.isfile(imageFilePath):
                print('File ' + imageFilePath + ' does not exist')
                continue
           
            photo = ccmasterkernel.Photo(imageFilePath, IMAGEDIMENSIONS)
            photo.pose.center = ecefP
           
            if firstPhoto:
                firstPhoto = False            
                photogroup.setupFromPhoto(photo)
                photogroup.focalLength_mm = FOCALLENGTH_MM
            photogroup.addPhoto(photo)
           
    block.setChanged()
    block.exportToKML(os.path.join(config['aerotriangulationDirPath'], 'block.kml'))
This code base was obtained from ContextCapture MasterKernel Python SDK - example script import_txt.py file.
What could also be important is that at the end of that script is exportToKML but I got an error message: "Failed to transform coordinates."
Could you help me? Maybe I am missing something here but I don't know what. I thought that this is something with coordinates system transformations but I couldn't solve it.
Any help will be appreciated. 
Tomasz
Parents Reply Children
No Data