Forum

Author Topic: Stop and Continue  (Read 4596 times)

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Stop and Continue
« on: May 21, 2018, 08:47:30 PM »
Hello guys, i have a little situation here.
I have a script that starts, identify markers, create scale bars, merge chunks, align and build a dense cloud.
But i want to clean an area that is not interesting for me, and resize the bounding box.
In first i wonder that is possible to make this automatically, but i saw that the program use  marker or scale bar to resize the bounding box. If there is a way to resize bounding box and clean the area, please HELP ME haha
The other way that i thought is to stop the scrit, and the user will resize the bounding box, clean the not interesting areas and click "enter" (for example), and then the program will continue, but i tried many ways and it not work.
Some one can help me??

This is the 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]))
DISTANCE = 0.09193781
start = 0
while (start +1 < len(photo_list)):
    chunk = doc.addChunk()
    chunk.addPhotos(photo_list[start:start+2])
    scalebar = chunk.addScalebar(chunk.cameras[0],chunk.cameras[1])
    scalebar.label = chunk.cameras[0].label + " - " + chunk.cameras[1].label
    scalebar.reference.distance = DISTANCE
    start += 2
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)






Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #1 on: May 22, 2018, 04:54:37 PM »
Hello guicanarin,

I think you can just split your script into two independent parts. Run first, adjust something manually, then run second.
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Stop and Continue
« Reply #2 on: May 22, 2018, 07:11:33 PM »
So, i'll have to run one script and after the other, or i just can run the two scripts togheter?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #3 on: May 22, 2018, 09:43:02 PM »
Hello guicanarin,

Just split your original script into tow parts (keep in mind that the second script wouldn't be aware about any variables defined in the first script, so you should repeat the variable assignment operations). Then run the first script, after it finishes do the manual job, then run the second script.
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Stop and Continue
« Reply #4 on: May 24, 2018, 03:42:44 PM »
Ok Alexey, it works!!
But, i really need to stop the script, and then continue.
There is a way to do that? Or is impossible??
haha
Thx a lot!!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #5 on: May 24, 2018, 03:58:00 PM »
Hello guicanarin,

Do you need to stop it on any point of processing?
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Stop and Continue
« Reply #6 on: May 24, 2018, 04:13:53 PM »
I want to break the process after align photos to clean some points that is not my interest, and then continue the process.
Is this possible?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #7 on: May 24, 2018, 04:50:07 PM »
Hello guicanarin,

Why can't you just use two scripts?
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]))
DISTANCE = 0.09193781
start = 0
while (start +1 < len(photo_list)):
    chunk = doc.addChunk()
    chunk.addPhotos(photo_list[start:start+2])
    scalebar = chunk.addScalebar(chunk.cameras[0],chunk.cameras[1])
    scalebar.label = chunk.cameras[0].label + " - " + chunk.cameras[1].label
    scalebar.reference.distance = DISTANCE
    start += 2
PhotoScan.app.document.mergeChunks()
merged_chunk = PhotoScan.app.document.chunks[-1]
merged_chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
merged_chunk.alignCameras(adaptive_fitting=True)


Code: [Select]
import PhotoScan
doc = PhotoScan.app.document

merged_chunk = doc.chunk
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: Stop and Continue
« Reply #8 on: May 24, 2018, 06:32:31 PM »
Hello alexey, i'm using PhotoScan Pro in my academics works, and this is the first script.
This will be used for many years and a lot of people will use.
If we have two scripts,  this information will be lost in many years.
So i want to concentrate all information just in one script.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #9 on: May 24, 2018, 06:41:35 PM »
Hello guicanarin,

Maybe then you can create the custom menu items from this script - then two new menu elements will appear related to the first and second part of the processing.

Code: [Select]
import os, PhotoScan

def part_one():
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]))
DISTANCE = 0.09193781
start = 0
while (start +1 < len(photo_list)):
chunk = doc.addChunk()
chunk.addPhotos(photo_list[start:start+2])
scalebar = chunk.addScalebar(chunk.cameras[0],chunk.cameras[1])
scalebar.label = chunk.cameras[0].label + " - " + chunk.cameras[1].label
scalebar.reference.distance = DISTANCE
start += 2
PhotoScan.app.document.mergeChunks()
merged_chunk = PhotoScan.app.document.chunks[-1]
merged_chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
merged_chunk.alignCameras(adaptive_fitting=True)
return 1

def part_two():
doc = PhotoScan.app.document
merged_chunk = doc.chunk
merged_chunk.buildDepthMaps(quality=PhotoScan.UltraQuality, filter=PhotoScan.AggressiveFiltering)
merged_chunk.buildDenseCloud(point_colors=True)
return 1


PhotoScan.app.addMenuItem("Custom menu/Script - Part 1", part_one)
PhotoScan.app.addMenuItem("Custom menu/Script - Part 2", part_two)


« Last Edit: May 24, 2018, 07:28:23 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Stop and Continue
« Reply #10 on: May 24, 2018, 07:25:35 PM »
Hello Alexey, i tried to use this, and nothing happened.
What i suppose to do to this code works?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Stop and Continue
« Reply #11 on: May 24, 2018, 07:30:33 PM »
Hello guicanarin,

The script creates two elements in the newly created Custom Menu: "Script - Part 1" and "Script - Part 2", so using each of those options would run the corresponding code block.

Note that I've updated the script for proper naming of the custom menu elements. Also if you are using Run Script multiple times you'll get the duplicated options in the Custom menu.
Best regards,
Alexey Pasumansky,
Agisoft LLC

guicanarin

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Stop and Continue
« Reply #12 on: May 24, 2018, 07:31:55 PM »
Ah ok ok, i found this!! haha THX Alexey!