Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad calibration export when estimate K4 parameters in metashape or index not found if not estimate unused K3 parameter #9

Open
Peamon opened this issue Jul 7, 2023 · 0 comments

Comments

@Peamon
Copy link

Peamon commented Jul 7, 2023

Hi, when you export camera parameters you use an index but, if you calculate K4 for example in metashape, the index are not correct anymore. I propose this change in the code to be sure having no problem. it will also create a better error message when camera parameters that is needed is not present in xml file.

Replace at line 113:

		fl_x = float(calibration[1].text)
		fl_y = fl_x
		k1 = float(calibration[4].text)
		k2 = float(calibration[5].text)
		p1 = float(calibration[7].text)
		p2 = float(calibration[8].text)
		cx = float(calibration[2].text) + w/2
		cy = float(calibration[3].text) + h/2

By:

		for chld in calibration:
			if chld.tag == "f":
				fl_x = float(chld.text)
				fl_y = fl_x
			elif chld.tag == "cx":
				cx = float(chld.text) + w/2
			elif chld.tag == "cy":
				cy = float(chld.text) + h/2
			elif chld.tag == "k1":
				k1 = float(chld.text)
			elif chld.tag == "k2":
				k2 = float(chld.text)
			elif chld.tag == "p1":
				p1 = float(chld.text)
			elif chld.tag == "p2":
				p2 = float(chld.text)

Agisoft export with only k1 k2 estimated is like this:

        <calibration type="frame" class="adjusted">
          <resolution width="540" height="960"/>
          <f>768.68340771397811</f>
          <cx>-10.291821702893024</cx>
          <cy>3.7142687950142763</cy>
          <k1>0.054258424223576199</k1>
          <k2>-0.1179548245864302</k2>
          <p1>-0.0011294399122456702</p1>
          <p2>0.0022433983854041159</p2>
        </calibration>

Agisoft export with k3 and k4 estimated is like this:

        <calibration type="frame" class="adjusted">
          <resolution width="540" height="960"/>
          <f>768.68340771397811</f>
          <cx>-10.291821702893024</cx>
          <cy>3.7142687950142763</cy>
          <k1>0.054258424223576199</k1>
          <k2>-0.1179548245864302</k2>
          <k3>0.054258424223576199</k1>
          <k4>-0.1179548245864302</k2>
          <p1>-0.0011294399122456702</p1>
          <p2>0.0022433983854041159</p2>
        </calibration>
@Peamon Peamon changed the title Bad calibration export when estimate K4 parameters in metashape or index not found if not estimate K3 unused parameter Bad calibration export when estimate K4 parameters in metashape or index not found if not estimate unused K3 parameter Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant