Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kbarn

Pages: [1]
1
A final update for the hive-mind, I found a way that allowed me to use Paul's recommendations and loop through files. This worked for me with version 1.5.4. Thanks again Paul for your recommendations!

Code: [Select]
for file in files:
   
    Metashape.app.document.open(file)

    doc = Metashape.app.document

    chunk = doc.chunk # could add another loop here if more than one chunk.

    for sensor in chunk.sensors:
        calibration = sensor.calibration
        calibration.cx = 0
        calibration.cy = 0
        calibration.p1 = 0
        calibration.p2 = 0
        calibration.p3 = 0
        calibration.p4 = 0
        calibration.b1 = 0
        calibration.b2 = 0
        calibration.k1 = 0
        calibration.k2 = 0
        calibration.k3 = 0
        calibration.k4 = 0
        sensor.calibration = calibration

  doc.save()

2
Hi Paul,

I just tried out your script and it does work for me! Not entirely sure why, but no matter.

Thanks for your help!
Katy

3
Thanks again for your recommendations Paul.

That did fix the TypeError... but didn't fix the underlying issue.


4
Thanks for the recommendation Paul. I tried it and it also didn't work. The other idea I thought to try is below (it also didn't work, but raised a TypeError).

Code: [Select]
for file in files:
    doc = Metashape.Document()
    doc.open(file)
    for chunk in doc.chunks:
        for sensor in chunk.sensors:
            calib = Metashape.Calibration
            calib.f = sensor.calibration.f
            calib.cx = 0.
            calib.cy = 0.
            calib.b1 = 0.
            calib.b2 = 0.
            calib.k1 = 0.
            calib.k2 = 0.
            calib.k3 = 0.
            calib.k4 = 0.
            calib.p1 = 0.
            calib.p2 = 0.
            calib.p3 = 0.
            calib.p4 = 0.
            sensor.calibration = calib
    doc.save()

This raises the following error (I'm running Metashape 1.5.4)

Code: [Select]
TypeError: expected  Metashape.Calibration object

5
I have a set of 10 projects in which I would like to re-start the camera optimization process.
I have twelve projects, each with at least 6 sensors, thus I would like to accomplish resetting the cx, cy, k1-4, b1, b2, and p1-4 to 0.0 with python instead of by hand.

I have tried out a couple of guesses at how to do this, but have not been successful.

I would expect that the following would work, but did not find that it changed the values. Any recommendations are welcome.

Code: [Select]
for file in files:
    doc = Metashape.Document()
    doc.open(file)
    for chunk in doc.chunks:
        for sensor in chunk.sensors:
            sensor.calibration.cx = 0
            sensor.calibration.cy = 0.
            sensor.calibration.b1 = 0.
            sensor.calibration.b2 = 0.
            sensor.calibration.k1 = 0.
            sensor.calibration.k2 = 0.
            sensor.calibration.k3 = 0.
            sensor.calibration.k4 = 0.
            sensor.calibration.p1 = 0.
            sensor.calibration.p2 = 0.
            sensor.calibration.p3 = 0.
            sensor.calibration.p4 = 0.
    doc.save()

thank you,
katy

Pages: [1]