Forum

Author Topic: align chunks and build depth failures, ground control preselection?  (Read 13355 times)

flightfollowing

  • Newbie
  • *
  • Posts: 9
    • View Profile
I am unable to get some basic scripting operations to execute, seemingly due to parameters not being properly specified. Is 'ground control' preselection enabled in scripting?  If anyone can suggest the correct scripting to execute the following it would be much appreciated, in both the align and the build opertions return errors:

import PhotoScan
doc = PhotoScan.app.document
pathfile = ('c', .... )

for files in pathfile:
    doc.clear()
    doc.open(files + ".psz")
    doc.activeChunk.matchPhotos(accuracy="high", preselection="ground control")
    doc.activeChunk.alignPhotos()
    doc.save(files + "a.psz")


    doc.activeChunk.buildDepth(quality="lowest")
    doc.activeChunk.buildModel(object="height field", geometry="point cloud", faces=50000)
 
« Last Edit: June 13, 2013, 11:21:34 PM by flightfollowing »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #1 on: June 13, 2013, 11:32:47 PM »
Hello flightfollowing,

And what is the error returned in the Console pane?

Are you using absolute paths?
« Last Edit: June 13, 2013, 11:44:23 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

flightfollowing

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #2 on: June 14, 2013, 03:45:24 AM »
Alexey,

Yes, using absolute paths, e.g:

            "J:\\Midwest\\2013_06_10_DC\\LenoxHi\\Ortho\\LenoxHi",
            "J:\\Midwest\\2013_06_10_DC\\SchuylerHi\\Ortho\\SchuylerHi",
            "J:\\Midwest\\2013_06_10_DC\\Imperial\Ortho\\Imperial",

and the error returned is:


Traceback (most recent call last):
  File "J:/Midwest/2013_06_11_LS/alignmodels.py", line 12, in <module>
    doc.activeChunk.matchPhotos(accuracy="high", preselection="ground control")
AttributeError: 'NoneType' object has no attribute 'matchPhotos'

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #3 on: June 14, 2013, 11:20:10 AM »
Hello flightfollowing,

Do you see project file open in the Workspace pane and if there are any chunks?

You should probably check the working workflow manually by inputting Python commands one by one in the Console pane (just for single path, for example). Looks like the projects are not opening correctly.
Best regards,
Alexey Pasumansky,
Agisoft LLC

James

  • Hero Member
  • *****
  • Posts: 748
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #4 on: June 14, 2013, 12:03:58 PM »
I can recreate this behaviour exactly by feeding in a non-existent file name to doc.open(). (It works perfectly if i put in a valid path)

Make sure your path names are being constructed correctly, maybe you need to add another '\\' between the directory and the project file name?

The 'NoneType' object has no attribute 'matchPhotos' error means that you have a null object, in my case caused by attempting to open a file with an incorrect path, so nothing to do with parameter specification.

flightfollowing

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #5 on: June 15, 2013, 08:18:39 PM »
James and Alexey,

Thanks very much for the suggestions. I rebuilt the paths very carefully by hand typing rather than copying the path, and the opening of the files works properly when I delimit out the matchphotos and alignphotos, so that is not a problem with the file and pathnames. but when I undelimit the matching and aligning, I get the following errors:

Traceback (most recent call last):
  File "J:/alignmodels.py", line 15, in <module>
    doc.activeChunk.matchPhotos(accuracy="high", preselection="ground control")
AttributeError: 'NoneType' object has no attribute 'matchPhotos'

The 0.9.1 documentation does not mention that ground control preselection is implemented, can this be the problem?

Has anyone started up a repository of some example or useful scripts? That might be quite helpful, I have not found quite relevent examples in this forum yet for the multi file batch processing I am trying to undertake.

I thought I might query the user for a file name and then print that out with something like this:

import PhotoScan
app = PhotoScan.Application
testfiles = app.getOpenFileName()

but got errors that the getopenFileName object needed a photoscan application object, but tried many but no luck.  If anyone has example scripts that do any of these sort of things that would be extremely helpful to review.

Thanks,





Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #6 on: June 15, 2013, 11:22:13 PM »
Hello flightfollowing,

The mentioned error messages refers to the fact that there is no information for doc.activeChunk. I recommend to check the problematic lines manually - open project maunally and then input the following lines from your script one by one in the console pane:
Code: [Select]
doc = PhotoScan.app.document
doc.activeChunk.matchPhotos(accuracy="high", preselection="ground control")
doc.activeChunk.alignPhotos()

Ground Conrol preselection is mentioned in 0.9.1 Manual, however, according to the error message there is no problem.

As for open file dialog you need to use PhotoScan.app.getOpenFileName() command.
Best regards,
Alexey Pasumansky,
Agisoft LLC

flightfollowing

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #7 on: June 21, 2013, 12:19:26 AM »
Alexey and James,

Thanks again for the great help, here is the simple working script in case it helps anyone else:

import PhotoScan
app = PhotoScan.Application

pathfile = PhotoScan.app.getOpenFileNames()

doc = PhotoScan.app.document

#first loop is just QC to make sure all the files exist and filenames are correct:
for files in pathfile:
        doc.clear()
        doc.open(files)

for files in pathfile:
        doc.clear()
        doc.open(files) 
        doc.activeChunk.matchPhotos(accuracy="high", preselection="ground control")
        doc.activeChunk.alignPhotos()
        doc.save(files[:-4] + "a.psz")

flightfollowing

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #8 on: June 21, 2013, 06:07:30 AM »
The twin processes of matching points and then aligning in the scripted environment seem to take 2x as long as performing the single nonscripted task from the gui application? Does anyone else find this to be true? If so, is their some way to step directly into aligning from matching to avoid the double step process?

James

  • Hero Member
  • *****
  • Posts: 748
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #9 on: June 21, 2013, 11:32:13 AM »
I haven't tried it, just looked at the API doc, so could be wrong, but i think the call to alignPhotos is redundant.

matchPhotos seems to do what you want, alignPhotos seems to be for if you want to align specific photos, and without any parameter presumably aligns them all, again, which would explain the 2x as much time!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #10 on: June 21, 2013, 02:07:35 PM »
Hello flightfollowing,

Thank you for reporting.

Will fix this problem in the next update, there was unoptimized ground control pre-selection method implemented in Python. That caused longer matching time.
Best regards,
Alexey Pasumansky,
Agisoft LLC

James

  • Hero Member
  • *****
  • Posts: 748
    • View Profile
Re: align chunks and build depth failures, ground control preselection?
« Reply #11 on: June 21, 2013, 02:57:54 PM »
Just did what I should have done all along and actually tried before saying anything and I can confirm what I was saying in my last post is nonsense!