Forum

Author Topic: Reading Mesh UV Stats from Python  (Read 4606 times)

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Reading Mesh UV Stats from Python
« on: April 10, 2019, 06:32:43 PM »
Is it possible to read stats like Fill ratio or Overlap ratio through python?

Normally this is accessed through Tools -> Mesh -> View Mesh UVs

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15159
    • View Profile
Re: Reading Mesh UV Stats from Python
« Reply #1 on: April 12, 2019, 03:48:44 PM »
Hello wojtek,

Do you need to export them as images, or access/calculate the related information?
Best regards,
Alexey Pasumansky,
Agisoft LLC

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Reading Mesh UV Stats from Python
« Reply #2 on: April 12, 2019, 03:56:45 PM »
I need to access the information so that I can iterate on the mesh until the stats meet my criteria (for example fill ratio > 60%)

Sometimes decimating 1 triangle down means a much better Unwrap. It would also help if Metashape had a built in parameter for desired fill ratio/overlap so the app handles it for us.

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Reading Mesh UV Stats from Python
« Reply #3 on: August 11, 2019, 04:30:30 PM »
Should I make a better case for this or is this something that you already acknowledge and no further sales pitch is needed? :D

I can provide examples of how much the fill ratio differs based purely on slightly different mesh (ie, decimated down by 1 triangle)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15159
    • View Profile
Re: Reading Mesh UV Stats from Python
« Reply #4 on: August 16, 2019, 09:55:39 PM »
Hello wojtek,

By current means of Python API I can only suggest to access model.texture() as an image and check the fourth component in the color tuple (related to Alpha - transparency, value). If the value is 255 - the texture pixel is used, if 0 - then it is unused. Ratio of 255-values to the image dimensions should give you the fill ratio (probably with numpy you can access this statistics faster).
Best regards,
Alexey Pasumansky,
Agisoft LLC

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Reading Mesh UV Stats from Python
« Reply #5 on: August 16, 2019, 10:03:11 PM »
Ah, that should do it for now. Thanks!