Forum

Author Topic: My menu scripts no longer run in photoscan 1.1.0  (Read 8584 times)

susiezgreen

  • Newbie
  • *
  • Posts: 5
    • View Profile
My menu scripts no longer run in photoscan 1.1.0
« on: December 27, 2014, 10:11:06 PM »
Hi,
has something changed in the way menu links to scripts are processed in photoscan 1.1.0?
None of my scripts can be run from my menus anymore

they are set up using PhotoScan.app.addMenuItem (in a file called "PhotoScan_Python_Tools_SG_Menu.py")
which references another file containing the scripts.  ("PhotoScan_Python_Tools_SG.py")

ie.
PhotoScan.app.addMenuItem("Python Tools/Photo Management/Delete Unselected Photos", PhotoScan_Python_Tools_SG.Delete_Unselected_Photos_SG)

The menu items do still appear so the script path must be correct (both files are in the same folder). These all worked fine in version 1.0.0


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15083
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #1 on: December 28, 2014, 10:40:55 AM »
Hello susiezgreen,

There were some major changes in Python API in the version 1.1.0, so scripts chould be modified according to the new API reference.

For example, instead of doc.activeChunk you need to use doc.chunk.

If you have troubles with scripts, please contact our support team (support@agisoft.com).
Best regards,
Alexey Pasumansky,
Agisoft LLC

Cavi_Ing

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #2 on: January 09, 2015, 10:16:13 AM »
Hello together,

i have the same problem with my small script now in v.1.1.0:

Where is my error?

-------------------

import PhotoScan, math

def main():

   doc = PhotoScan.app.document
   chunk = doc.chunk
   
   if chunk.model:
      x = PhotoScan.app.getInt("Input number of smoothing steps:", 3)
      chunk.smoothModel(x)
      print("Smoothing by script finished.")
      return 1
   else:
      print("No model. Script aborted.")
      return 0

PhotoScan.app.addMenuItem("Cavi_Ing/Smooth model", main)   


def rotateBb():

   doc = PhotoScan.app.document
   chunk = doc.chunk
   
   T = chunk.transform
   v = PhotoScan.Vector( [0,0,0,1] )
   v_t = T * v
   v_t.size = 3

   m = chunk.crs.localframe(v_t)
   m = m * T
   s = math.sqrt(m[0,0]**2 + m[0,1]**2 + m[0,2]**2) #scale factor
   R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])

   R = R * (1. / s)
   reg = chunk.region
   reg.rot = R.t()
   chunk.region = reg

PhotoScan.app.addMenuItem("Cavi_Ing/Bounding box to coordinate system", rotateBb)


-------------------

The first part - smooth model -  works. the second part not.   

Thx

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15083
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #3 on: January 09, 2015, 11:17:30 AM »
Hello,

T = chunk.transform -> T = chunk.transform.matrix
Best regards,
Alexey Pasumansky,
Agisoft LLC

susiezgreen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #4 on: January 18, 2015, 08:47:12 PM »
Is there a list somewhere of the changes that have been made?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15083
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #5 on: January 18, 2015, 09:13:45 PM »
Hello susiezgreen,

Please check Chapter 3 in Python API Reference: http://www.agisoft.com/pdf/photoscan_python_api_1_1_0.pdf
Best regards,
Alexey Pasumansky,
Agisoft LLC

susiezgreen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #6 on: March 15, 2015, 08:05:26 PM »
Hello,
I am still working my way through my scripts updating them from 1.0 to 1.1
I am having trouble finding a replacement for

PhotoScan.Chunk. aligned_count

I want to return a count of the number of matches made as part of returned statistics after a batch process.
Is there a way to get this information in 1.1? I can't find anything.
thanks
Susie

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15083
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #7 on: March 15, 2015, 09:05:50 PM »
Hello Susie,

The first ideas that came to mine mind:
Code: [Select]
int(str(chunk.point_cloud).split("'")[1].rsplit(" ")[0])or just
Code: [Select]
len(chunk.point_cloud.points)
Best regards,
Alexey Pasumansky,
Agisoft LLC

susiezgreen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #8 on: March 17, 2015, 02:37:16 PM »
Thanks Alexey,
sorry, my last post wasn't entirely clear. I am trying to find the count of aligned cameras, not points.
Is there a way to query whether a camera is aligned? The result I am looking for is the number of cameras that have green ticks in the aligned column when the details are displayed in the photo dialogue.
thanks,
Susie

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15083
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #9 on: March 17, 2015, 02:41:31 PM »
Hello Susie,

Then the only way seems to be to loop across all the cameras:
Code: [Select]
aligned = 0
for camera in chunk.cameras:
    if camera.transform:
          aligned += 1
Best regards,
Alexey Pasumansky,
Agisoft LLC

susiezgreen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: My menu scripts no longer run in photoscan 1.1.0
« Reply #10 on: March 17, 2015, 03:02:52 PM »
That is just what I need,
thanks!