Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: SAV on June 11, 2014, 12:21:19 PM

Title: Estimate image quality
Post by: SAV on June 11, 2014, 12:21:19 PM
How can I delete/disable pictures which are below a certain estimated image quality value (e.g. 0.7) using python?

Thanks for the help!!

Cheers
SAV


Title: Re: Estimate image quality
Post by: Alexey Pasumansky on June 17, 2014, 12:05:50 PM
Hello SAV,

For the quality estimation you should use the following method applied to the chunk instance:
Code: [Select]
chunk.estimateImageQuality()
Then to access the quality value you need to do the following:
Code: [Select]
camera = chunk.cameras[0]
quality = camera.frames[0].meta["Image/Quality"]
if quality < threshold:
        camera.enabled = False

p
Title: Re: Estimate image quality
Post by: SAV on June 18, 2014, 04:19:34 AM
Hi Alexy,

Thank you very much.

I already used...
Code: [Select]
chunk.estimateImageQuality()... which worked fine to calculate the IQ ( ;)) for ALL the pictures.

But I did not know how to access/read the "Image Quality" for a single picture.
Thanks for your code.

Great customer service / support  ;D

Cheers
SAV

Title: Re: Estimate image quality
Post by: SAV on June 18, 2014, 05:33:41 PM
Hi again Alexy,

I have some strange behaviour of the code - it's not working. It seems like my loop gets stuck at the IF statement.

Code: [Select]
chunk.estimateImageQuality()
for i in range(0, len(chunk.cameras)):
print(i)
camera = chunk.cameras[i]
print(camera)
quality = camera.frames[0].meta["Image/Quality"]
print(quality)
if quality < 0.8:
camera.enabled = False

I deleted the IF statement to see if there was something wrong with the loop itself, but it was working fine. It went through all the photos and disabled them (code below).

Code: [Select]
chunk.estimateImageQuality()
for i in range(0, len(chunk.cameras)):
print(i)
camera = chunk.cameras[i]
print(camera)
quality = camera.frames[0].meta["Image/Quality"]
print(quality)
camera.enabled = False

Do you know what I am doing wrong?

In advance, thanks for your help.

Cheers
SAV
Title: Re: Estimate image quality
Post by: James on June 18, 2014, 05:59:14 PM
replace

Code: [Select]
if quality < threshold
with

Code: [Select]
if float(quality) < threshold
the meta thingy returns strings, not numbers!
Title: Re: Estimate image quality
Post by: Alexey Pasumansky on June 18, 2014, 06:44:21 PM
Sure, James, my fault.
Title: Re: Estimate image quality
Post by: SAV on June 19, 2014, 04:07:33 AM
Thank you guys ;D

SAV