Forum

Author Topic: 1.6 mergeChunks API is confusing  (Read 1694 times)

ashalota

  • Jr. Member
  • **
  • Posts: 93
  • Forest orthomosaics, long transects (300m agl)
    • View Profile
    • NASA: G-LiHT (Public orthomosaics)
1.6 mergeChunks API is confusing
« on: February 28, 2020, 08:33:47 PM »
Hi, How can I recreate this behavior from 1.5 in 1.6 (in GUI python console)?

Code: [Select]
doc = Metashape.app.document
doc.mergeChunks([doc.chunks[0],doc.chunks[2]],merge_models = True)

As far as I can tell, in 1.6 I need to name to have chunks as a named parameter, and instead of the chunk itself, I pass its index?
If I don't name the chunk, it pulls in all my cameras and merges them.
If I name them, it will only use the first chunk in the list. I'm so confused, I really hope you can revise the python manual for 1.6 soon as it is not very clear. Sample code with each function would be great.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: 1.6 mergeChunks API is confusing
« Reply #1 on: February 28, 2020, 11:02:53 PM »
Hello ahsalota,

In version 1.6 we have unified tasks and network tasks, so there are considerable changes in API.

When list of int is taken as parameter for the operation applied to certain project elements (like cameras, markers or chunks, as in your example) usually it means that you should pass the list of element keys. In your example it should be [doc.chunks[0].key, doc.chunks[2].key]
.key - is a unique identifier of the element.
Best regards,
Alexey Pasumansky,
Agisoft LLC

ashalota

  • Jr. Member
  • **
  • Posts: 93
  • Forest orthomosaics, long transects (300m agl)
    • View Profile
    • NASA: G-LiHT (Public orthomosaics)
Re: 1.6 mergeChunks API is confusing
« Reply #2 on: March 13, 2020, 10:05:58 PM »
Hi, I finally got around to trying this and it did not solve the issue.

Attached is a screenshot of what's happening, and the code. Even when i use an array of "curChunk.key" items as the input, it merges all of my items.

Code: [Select]
c=[doc.chunks[-2],doc.chunks[-1]]

c
Out[16]: 2020-03-13 14:58:43 [<Chunk 'l0s4_merged'>, <Chunk 'l0s10__7610_7619'>]

keys = [x.key for x in c]

keys
Out[18]: 2020-03-13 14:58:54 [27, 28]

doc.mergeChunks(keys)
2020-03-13 14:58:59 MergeChunks: merge_markers = on
2020-03-13 14:58:59 Merging chunks...
2020-03-13 14:59:00 Finished processing in 0.166039 sec (exit code 1)


This is merging a chunk with 10 cameras and one with 15 cameras, but the output is a merged chunk with all 465 cameras in my project. In the attached photo you can see the last two chunks, and the new chunk which is created after running doc.MergeChunks(k)

« Last Edit: March 13, 2020, 10:08:49 PM by ashalota »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: 1.6 mergeChunks API is confusing
« Reply #3 on: March 13, 2020, 10:29:50 PM »
Hello ashalota,

You are not using proper parameter, you should do it in the following way:
Code: [Select]
doc.mergeChunks(chunks = keys)
Best regards,
Alexey Pasumansky,
Agisoft LLC