Forum

Author Topic: Error in 1.2.0 addChunk  (Read 5519 times)

gchaprnka

  • Newbie
  • *
  • Posts: 14
    • View Profile
Error in 1.2.0 addChunk
« on: December 11, 2015, 09:17:33 PM »
Script was running well in 1.1.6, but now crashes in 1.2.0. I updated other calls as shown in http://www.agisoft.com/forum/index.php?topic=4588, but this fails too.


2015-12-11 11:59:34     doc2.addChunk(chunk.copy())
2015-12-11 11:59:34 TypeError: addChunk() takes no arguments (1 given)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #1 on: December 11, 2015, 11:05:35 PM »
Hello gchaprnka,

ANd what's your intention of the script?

doc.addChunk() - creates new empty chunk in the active document.
If you need to make a chunk copy (similar to the duplicate command accessible from GUI), use chunk.copy() (without .addChunk), as it will create a copy of the chunk and add it to the document automatically.
Best regards,
Alexey Pasumansky,
Agisoft LLC

gchaprnka

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #2 on: December 17, 2015, 12:36:41 AM »
automated processing of shots from my camera array. This snippet was previously taking the last of a series of copied chunks (adjusting gradual selection until a certain % of original data is left, iteratively), and copying the final chunk to a new doc ("doc2"), and saving just that doc out.

Code: [Select]
...
doc2 = PhotoScan.Document()
doc2.addChunk(chunk.copy())
doc2.save(C:\\Path\\to\\file.psz")

However, addChunk now seems to exclusively make new chunks, and chunk.copy doesn't seem to put the copy in the new doc. I can't seem to find the method to copy the active chunk into a new "Document".

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #3 on: December 17, 2015, 03:03:59 PM »
Hello gchaprnka,

Thanks for clarification, now we understand that some convenient option should be implemented in Python API to allow creating and saving new document from the list of existing chunks.

We'll try to implement it in the next update. At the moment I see the only workaround to copy the complete document and remove all but one chunk from it.
Best regards,
Alexey Pasumansky,
Agisoft LLC

gchaprnka

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #4 on: December 17, 2015, 07:42:34 PM »
Thanks Alexey - I've also noticed that it seems gradual selection is working differently between 1.1.6 and 1.2.0 (and 1.2.1). I used to iteratively lower my threshold until I had ~80% of the original points, and that was working well with a .25 step per iteration. Now it seems that I never get any data with those values - because I get to .25 and still above 80%, and the next step is 0. Was there some fundamental change in how gradual selection works in the update?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #5 on: December 17, 2015, 08:37:31 PM »
Hello gchaprnka,

What criterion you are using? And do you apply it to the point clouds generated in version 1.1 or in 1.2?
Best regards,
Alexey Pasumansky,
Agisoft LLC

gchaprnka

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #6 on: December 18, 2015, 12:12:11 AM »
I'm testing completely in 1.2.1 right now (but I am testing with the same raw photo set that I have run through 1.1.6 successfully, with different results.

Code: [Select]
gradualFlag = int(float(numPoints) * 80) #80 is 80% - our target number of points to keep
reprojectionError = float(10)
currentPoints = numPoints

while (currentPoints > gradualFlag):
reprojectionError -= .25
newChunk = chunk.copy()
newChunk.buildPoints(error = reprojectionError)
currentPoints = len(newChunk.point_cloud.points)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #7 on: December 30, 2015, 06:05:50 PM »
Hello gchaprnka,

Back to your previous request, in the version 1.2.2 you can now pass the list of chunks to be saved in the separate project when using document.save() function.

As for the buildPoints() issue, I've checked your script on some random projects (printing the ratio of current/original points) and it worked as expected (I've only changed the gradualFlag definition from ...* 80 to ... *0.8 ). Have you tried using GUI option for gradual selection and checking its behavior?
« Last Edit: January 01, 2016, 09:48:44 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
doc.save() error in new Python API
« Reply #8 on: January 01, 2016, 09:46:27 PM »
Hello Alexey,

in new Python API 1.2.2, I am trying to use following script to save document:


import PhotoScan
doc = PhotoScan.app.document
doc.save()


and I get following error from console:


2016-01-01 12:40:09 Traceback (most recent call last):
2016-01-01 12:40:09   File "C:/Users/paul.pelletier/Documents/Photoscan/Scripts/savedoc.py", line 3, in <module>
2016-01-01 12:40:09     doc.save()
2016-01-01 12:40:09 TypeError: expected a list of chunks as an argument

What can I modify in doc.save to be able to save document?


Best regards,
Best Regards,
Paul Pelletier,
Surveyor

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #9 on: January 01, 2016, 10:09:43 PM »
Hello pap1956,

You need to pass path and chunks agruments to doc.save() function:
Code: [Select]
doc.save(path = "D://project.psz", chunks = doc.chunks)it will save all the chunks from the current project to the specified project file.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1303
    • View Profile
Re: Error in 1.2.0 addChunk
« Reply #10 on: January 02, 2016, 09:21:13 AM »
Thanks for yur quick help!
Best Regards,
Paul Pelletier,
Surveyor