Forum

Author Topic: Working with Specific Chunk  (Read 3836 times)

beth182

  • Newbie
  • *
  • Posts: 5
    • View Profile
Working with Specific Chunk
« on: July 14, 2017, 12:53:51 PM »
Hello,

I am new to Agisoft programming, so apologies if this is an obvious question, or if it has been asked before (I have looked, but can't see anything similar to my problem posted).

I have automated the process of creating a new chunk, choosing photos for the new chunk, creating a camera file from a reference file, and finally aligning the photos -  this process is looped, to create several chunks. However, I am stuck when it comes to building a dense cloud; I am wanting to merge all previous chunks made, and and then build a dense cloud for the newly merged chunk. When I use

PhotoScan.app.document.mergeChunks()
chunk.buildDenseCloud(quality = PhotoScan.LowQuality)


after the loop, the dense cloud IS NOT made for the merged chunk, but rather for the last chunk to be made from the loop. So, my question is, how to I target and work with a specific chunk (as in, the merged chunk)?
Thank you for your time

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Working with Specific Chunk
« Reply #1 on: July 14, 2017, 01:10:45 PM »
Hello beth182,

Merged chunk is usually added to the end of the doc.chunks list, so you can access the last element in the list after merging:
Code: [Select]
PhotoScan.app.document.mergeChunks()
merged_chunk = PhotoScan.app.document.chunks[-1]
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Working with Specific Chunk
« Reply #2 on: May 03, 2018, 09:40:01 PM »
Hi guys, i used this script, but the program is still not taking the merged chunk.

This is my code.
Code: [Select]
import os, PhotoScan
doc = PhotoScan.app.document
path_photos = PhotoScan.app.getExistingDirectory("C:\\Users\lma\Documents\Fotos.jpg")
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
        photo_list.append("/".join([path_photos, photo]))
start = 0
while (start +1 < len(photo_list)):
    chunk = doc.addChunk()
    chunk.addPhotos(photo_list[start:start+2])
    chunk.detectMarkers(type=PhotoScan.CircularTarget12bit)
    start += 2
PhotoScan.app.document.mergeChunks()
merged_chunk = PhotoScan.app.document.chunks[-1]
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
chunk.alignCameras(adaptive_fitting=True)
chunk.buildDepthMaps(quality=PhotoScan.UltraQuality, filter=PhotoScan.AggressiveFiltering)
chunk.buildDenseCloud(point_colors=True)



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Working with Specific Chunk
« Reply #3 on: May 03, 2018, 09:44:46 PM »
Hello guicanarin,

If you would like to perform some actions to data corresponding to merged_chunk variable, then you should apply PhotoScan.Chunk methods to it:
Code: [Select]
merged_chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
merged_chunk.alignCameras(adaptive_fitting=True)
merged_chunk.buildDepthMaps(quality=PhotoScan.UltraQuality, filter=PhotoScan.AggressiveFiltering)
merged_chunk.buildDenseCloud(point_colors=True)
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Working with Specific Chunk
« Reply #4 on: May 03, 2018, 10:02:56 PM »
I tried to use this, but this returns

""AttributeError: 'list' object has no attribute 'matchPhotos'""

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Working with Specific Chunk
« Reply #5 on: May 03, 2018, 10:07:52 PM »
Hello guicanarin,

Can you provide the output to Console of the following command?
Code: [Select]
print(merged_chunk)
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Working with Specific Chunk
« Reply #6 on: May 03, 2018, 10:12:12 PM »
Yes, is this..

2018-05-03 16:10:14 [<Chunk 'Chunk 1'>, <Chunk 'Chunk 2'>, <Chunk 'Chunk 3'>, <Chunk 'Chunk 4'>, <Chunk 'Chunk 5'>, <Chunk 'Chunk 6'>, <Chunk 'Chunk 7'>, <Chunk 'Chunk 8'>, <Chunk 'Chunk 9'>, <Chunk 'Chunk 10'>, <Chunk 'Chunk 11'>, <Chunk 'Chunk 12'>, <Chunk 'Chunk 13'>, <Chunk 'Chunk 14'>, <Chunk 'Chunk 15'>, <Chunk 'Chunk 16'>, <Chunk 'Chunk 17'>, <Chunk 'Chunk 18'>, <Chunk 'Chunk 19'>, <Chunk 'Chunk 20'>, <Chunk 'Merged Chunk'>]

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Working with Specific Chunk
« Reply #7 on: May 04, 2018, 12:08:06 AM »
It looks like PhotoScan.app.document.chunks and not PhotoScan.app.document.chunks[-1]
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Working with Specific Chunk
« Reply #8 on: May 04, 2018, 04:34:07 PM »
Thanks Alexey!!
your tip was goos, and my code works in this way.

Code: [Select]
import os, PhotoScan
doc = PhotoScan.app.document
path_photos = PhotoScan.app.getExistingDirectory("C:\\Users\lma\Documents\Fotos.jpg")
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
        photo_list.append("/".join([path_photos, photo]))
start = 0
while (start +1 < len(photo_list)):
    chunk = doc.addChunk()
    chunk.addPhotos(photo_list[start:start+2])
    chunk.detectMarkers(type=PhotoScan.CircularTarget12bit)
    start += 2
PhotoScan.app.document.chunks[-1]
PhotoScan.app.document.mergeChunks()
merged_chunk = PhotoScan.app.document.chunks[-1]
merged_chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
merged_chunk.alignCameras(adaptive_fitting=True)
merged_chunk.buildDepthMaps(quality=PhotoScan.UltraQuality, filter=PhotoScan.AggressiveFiltering)
merged_chunk.buildDenseCloud(point_colors=True)