Forum

Author Topic: Emulating "Align Selected Cameras" via Python API  (Read 3640 times)

jsloat

  • Newbie
  • *
  • Posts: 13
    • View Profile
Emulating "Align Selected Cameras" via Python API
« on: June 02, 2016, 04:48:35 AM »
My facility has some hellishly heavy solves ahead composed of more than 2500 very high-res images.
While I have successfully written a number of plug-ins to help us handle various issues of complexity,
however I'm hitting wall trying to emulate a particular but important GUI behavior via the API.

With so many images, we're finding even the first Camera Alignment step completely bogs down if we try to process all images at once. For a temp workaround, user is currently selecting 50 images at a time, and via the GUI running "Align Selected Cameras" which processes just the selected ones and stops. Then select the next group and process again.  I'm trying to make something more automated that can mimick this by running 50 (or variable #) cameras at a time.

I'm aware that in the API, "Align Photos" is broken into 2 parts and my plug-in is wired to do that.
I set the "selected" state for the bundle of cameras I want to process each time round the loop.
AlignCameras method takes a camera list which is great. MatchPhotos does not, and my expectation was that as long as I have the desired cameras selected, it would (or could somehow be made to ) process just the selected cameras.

The behavior I'm seeing is that as soon as I start the MatchPhotos method, it insists on trying to process all 2500 cameras (which stalls and is the reason I'm writing this plug-in in the first place.)

I've scrubbed the API doc, and the forums for any workaround or clarifications on how to emulate the selected scope processing of what the GUI  "Align Selected Cameras"  provides.

Any ideas welcomed.

Best,
-Jay-

I've included my plug-in below

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Emulating "Align Selected Cameras" via Python API
« Reply #1 on: June 02, 2016, 11:34:59 AM »
I haven't tried this but maybe you can disable cameras with Camera.enabled to exclude them from the matching step.
Also, you are missing the parenthesis for PhotoScan.app.update().

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Emulating "Align Selected Cameras" via Python API
« Reply #2 on: June 02, 2016, 12:30:01 PM »
Hello Jay,

Align Selected Cameras in GUI also requires the presence of matching points on the images being re-aligned, so you cannot just add new photos to the already matched sub-set and use Align Selected Cameras option - it will fail both in GUI and from Python.
So Match Photos operation is required to be run for all the images that would be used later for the camera alignment operation.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jsloat

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Emulating "Align Selected Cameras" via Python API (Correction)
« Reply #3 on: June 03, 2016, 04:45:59 AM »
Important clarification/qualification on one of my assertions.
In a new session, with freshly loaded pristine images, GUI will indeed give an error if one tries to use "Align Selected Cameras".
(I was mistaken about this point, my power user who showed me this working, wasn't working with a completely clean slate. She has been working with some scenes that had some initial processing, that was strategically aborted and "Reset" via the interface so it "appeared pristine" when it was not.)

So here's how my Power user manually gets to place where she can process heavy sessions involving 8,000 50 Mp images and do manual "Align Selected Cameras" as follows. (I share because I think it is an interesting and insightful technique for breaking through huge solves.)

0) Start with a strong machine with 120 Gb ram, lots of cores, and strong graphics card such as Titan-X
1) Into new session load 8000 images.
2) Manually (via GUI) run "Align Photos" and let it
    a) Detect points      (which takes her about an hour)
    b) Matching Points (which takes her about an hour)
    c) Finding Pair        (which goes fairly quickly)
    d) it starts the section "Estimating Camera Locations" but she could leave it in this step more than a week with no apparent signs of progress because there is something quite non-linear in this step, So she aborts Manual processing when it enters this phase.

3) Then she saves out the scene in this state.
4) Now, you can select some sane number of images (50-100) and run "Align Selected Cameras" on them a group at a time,
and you eventually get all 8000 cameras aligned and you save that scene to file.  (This is the part I'm trying to Automate via API script)

We plan to use our standard tools to do these later steps (but I'd be lying if I said we have completed these for solves over 2500 images thus far.

5) Then we plan to standard Chunking tools to break it into between 30-50 sections and save
6) Then we plan to leverage Network Cluster batch processing of the Chunks to generate dense point Cloud.
7) Generate Model
8) Merge chunks
9) Final Texture and output.

-Jay-