Forum

Author Topic: export undistorted photos in python  (Read 2956 times)

william

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
export undistorted photos in python
« on: April 02, 2018, 08:41:33 PM »
I've been trying to recreate the GUI functionality export -> undistort photos using the Python API.

This is what I came up with, for a multiplane (MicaSense RedEdge) camera:

Code: [Select]
    for camera in chunk.cameras:
        for plane in camera.planes:
            img = plane.image()
            calib = plane.sensor.calibration
            # This is the key line for colour correction. Here, I opted not to square pixels or center principal point.
            imgu = img.undistort(calib, False, False)
            name = os.path.basename(plane.photo.path)
            imgu.save(os.path.join('undistorted/', name))

It seems to work. Unfortunately, it seems that the exif information, such as 'XMP:CaptureId' is not saved. (This is crucial for me.) Does anyone know if this can be accomplished?

EDIT: I noticed that photo.imageMeta() exists, and I also know how to extract metadata from the original photo using e.g. exiftool. But I'm not sure how to save the metadata properly to a new image.

EDIT 2: I am managing with a workaround--just using the metadata from the original images, and matching that to the undistorted images.
« Last Edit: April 02, 2018, 11:33:50 PM by william »