Friday, March 21, 2014

Agisoft Photoscan Crash Course (v. 1.0.2)

*Updated version for Photoscan 1.1 is finally here*


A not-so-quick tutorial in using Photoscan to process a single photoset in Agisoft Photoscan Professional version 1.0 (1.0.2 or 1.0.3), for Photoscan version 1.1 please see the updated tutorial.

I have written this for various research groups at the University of Oregon, Oregon State University, and Dartmouth College. I hope that this will help others get started as well. I also plan to add screen shots to this eventually, but for now this will have to do.

Photo Prep

1.    Eliminate any blurry, out of focus, random photos from your photoset
2.    If you has GPS track data for you photos, use a program like GeoSetter to geotag your photos before processing.
a.    With geotagged photos, the coordinates are usually Lat/Long (in degrees); use the convert tool in the ‘ground control’ pane to convert to UTM.
b.    Never use geotagged photos as the sole source of georeferencing information. The error’s in consumer grade GPS units (handheld or in camera) is too great for anything more than helping with photo alignment.
3.    Make sure you have a camera calibration file ready to go for your camera
a.    Agisoft has a tool for this on their website
b.    When calibrating in Agisoft Lens be sure that all of the variable boxes are checked

Photo Alignment

1.    Load your photos
a.    Apply the camera calibration file to all of the photos (Tools…Camera Calibration…)
2.    Align Photos Settings:
a.    Accuracy:
                                          i.    High: is best for smaller photosets
                                         ii.    Medium: is best for larger photosets
b.    Pair Selection:
                                          i.    Disabled: default, works for most datasets
                                         ii.    Generic: I use this one if I’m having trouble getting photos to align
                                        iii.    Ground Control: If your photos are geotagged, this will use the GPS positions to speed up processing.
c.    Advanced:
                                          i.    Point Limit: 40,000 is default. Smaller numbers can speed up processing, but you run the risk of not having enough points to align photos.
                                         ii.    Constrain features by mask: You can use masks to exclude parts of the images you do not want to model, check this box if you have masks.
3.    Fixing misaligned/unaligned photos
a.    After the initial pass of photo alignment, there may be photos that are misaligned or unaligned. You can force the program to try again, usually this works (but not always).
                                          i.    Select all of the photos that are causing trouble, right-click and select ‘Reset Alignment’
                                         ii.    Right-click again, select ‘Align Selected Cameras’
                                        iii.    If that does not work, select a smaller batch of problem photos and try again working in small batches.
                                       iv.    If none of that works, there is not a whole lot you can do but disable or exclude the photos that will not align.

Georeferencing

1.    Prep your control point data
a.    Double-check your projection and vertical datum, do any conversions outside of Photoscan.
b.    Load your data points into Excel and delete all but the NAME, LAT(Northing), LONG(Easting), ELEV to simplify things.
c.    Save as a text file (tab delimited)
d.    Use the Import tool in the ‘Ground Control’ pane, set the import settings, say ‘Yes to all’ when it asks to add points.
e.    If you import a larger file, you should delete any points that are not present in the photoset.
2.    Set your projection with the ‘Settings’, the other settings are default
3.    Find the first photo with a ground control point
a.    Double-click the photo to open it, zoom in on the control point, right-click on the center of the control point marker, select ‘Place Marker’ and select the appropriate marker.
b.    Find the next photo with the same GCP as the first, set the marker.
                                          i.    Once you have a marker placed in two photos the software starts to guess where they should be in other photos.
                                         ii.    Right-click on the marker you have been working on, select ‘Filter Photos by Marker’. This will show just the photos that the marker is in.
                                        iii.    Click through all of the photos and place the markers.
                                       iv.    If a photo has a marker flag in it, but the GCP is not visible
1.    You can leave it as a gray flag and it will not be used, or
2.    You can right-click on it and ‘Remove Marker’
c.    In the photos pane, select ‘Reset Filter’ to get back to the full photoset.
d.    Repeat the above steps for the next two GCPs
4.    After you have three GCP markers set, you can ‘Update’ the georeferencing in the ground control pane
a.    This will roughly georeference the model and make finding the remaining GCPs easier
b.    If your first three points are close together, this may not work very well…
                                          i.    In this case you will likely have to manually find and mark an additional GCP
5.    Right-click on the next GCP in the list and ‘Filter Photos by Marker’
a.    Run through all of the photos and place the markers
b.    ‘Update’ again to refine the georeferencing
c.    Repeat this step for the rest of the GCPs
6.    Double-check that all of your GCP markers are placed
a.    Right-click on all of the GCPs and ‘Filter Photos by Marker’
b.    Double-check that all of the photos have little blue flags above them in the photo pane.
c.    Update one last time

Optimize the alignment

1.    Double-check that you have a camera calibration applied to all of the photos
2.    Click on ‘Optimize’ in the ground control pane
a.    Make sure the ‘Fit k4’ box is checked
b.    This optimizes the camera alignment based on the camera calibration and control points
3.    Check your error for each GCP
a.    In the georeferencing pane, the point with the worst error is highlighted in red
                                          i.    You can also click on ‘View Errors’ to view the X, Y, and Z components of the error
b.    If you have points with errors that are higher than you would like, you can uncheck the box on the left to exclude it from the georeferencing calculations
c.    Update the georeferencing, repeat for any other bad points if necessary
d.    If you change exclude a lot of points, re-optimizing is a good thing to do

Building Dense Point Clouds

1.    Check the bounding box (the light gray box with a red bottom) size and orientation
a.    Use the ‘Resize Region’ and ‘Rotate Region’ tools on the toolbar if the bounding box looks like it is going to cut off any parts of the model
2.    Settings
a.    Quality:
                                          i.    This is the super memory intensive part of the process, photosets that are large (lots of photos) can take a long time to complete. Too many photos cause the program to run out of memory. The quality that’s achievable and the time it takes depend on your processor (CPU), RAM, and video card (GPU)
                                         ii.    High: great for smaller photosets (up to ≈150 photos)
                                        iii.    Medium: good for larger datasets (over 150 photos)
b.    Advanced
                                          i.    Depth Filtering: Aggressive (default), limits points that are too far from the surface. For vegetation, this may need to be relaxed a bit.

Point Cloud Editing

1.    If there are any points in the dense point cloud are outside of the envelope you wish to export, you can manually delete them
2.    Use the ‘Rectangle Selection’, ‘Circle Selection’, or ‘Free-from Selection’ tools on the toolbar to select and delete errant points

Build Mesh

1.    Settings
a.    Surface Type:
                                          i.    Height Field: only builds a mesh surface orthogonal to the reference system Z-axis (i.e. no undercuts will be modeled). This is the fastest mesh procedure and excellent if DEMs are going to be your final product.
1.    For geography applications, a height field would normally be modeled orthogonal to the Z-axis of the coordinate system. In Photoscan, the height field is actually modeled against the orientation of the bounding box (the light gray box with a red bottom) of the model. You can run this Python script (**Align Bounding Box Tool**) in the console to align the bounding box to the reference system. You will need to
                                         ii.    Arbitrary: Will model every nook and cranny of the object. Best for oblique imagery, when point clouds or complex mesh surfaces are going to be the final product.
b.    Source Data:
                                          i.    Dense cloud: default
                                         ii.    Sparse cloud: You could use this, but I am not sure why…
c.    Polygon Count: The number of polygons that the model will be decimated to after processing.
                                          i.    The software has High, Medium, Low values
                                         ii.    Or you can specify a custom number (entering 0 will not decimate the final model)
d.    Interpolation
                                          i.    Enabled: default, will interpolate over small holes in the surface
                                         ii.    Extrapolation: will leave holes in the final surface where there are no dense points
e.    Point Classes:
                                          i.    There is a point classification tool in Photoscan. If you used it to classify the dense point cloud, you could specify which point classes you want use for the mesh.

Exporting DEM / Orthophotos

1.    File…Export DEM…Export TIFF/BIL/XYZ…
a.    Settings:
                                          i.    Choose your projection
                                         ii.    Crop invalid DEM: checked by default
                                        iii.    No-data value: Use -9999 for ArcGIS
                                       iv.    Pixel Size: Photoscan estimates an appropriate pixel size, can be changed to match your requirements
                                        v.    Split in blocks: segment the DEM into X by X rasters (only needed for large datasets)
                                       vi.    Set boundaries:
1.    Check the box and click ‘Estimate’, this limits extra no-data values on the edges
                                      vii.    Write world file: not necessary if you export a TIFF
                                     viii.    Choose your output location, file name, and type
2.    File…Export Orthophoto…Export JPEG/TIFF/PNG
a.    Settings:
                                          i.    Choose your projection
                                         ii.    Blending mode: Mosaic (default)
                                        iii.    Enable Color Correction: not usually necessary, but if you need the color to be evened out feel free to select this option
                                       iv.    Pixel Size: same as above
                                        v.    Split in Blocks: same as above
                                       vi.    Set boundaries: same as above
                                      vii.    Write world file: not necessary if you export a TIFF
                                     viii.    Choose your output location, file name, and type

6 comments:

  1. This must be for the Pro version or did I somehow miss many of those features in the Standard version?

    ReplyDelete
    Replies
    1. It is indeed for the Pro version, thanks for catching that.

      Delete
  2. Do you have any insight on choosing a texture size? I've found 4k and 8k sometimes are pixelated for large areas.

    ReplyDelete
    Replies
    1. Kris, It depends on what type of object you are modelling. For topography, you can get an idea for the size of the texture by going to the "Export Ortho" dialog. Set the pixel size you want, hit the 'Estimate' in the boundary section, the max value in the total size fields would be what you enter as the texture size (mine are up in the 10K - 30K range).

      Delete
    2. That helps! I'm doing scans of cliff walls and canyons so I'll do that!

      Delete
  3. Students want to develop the impression by delivering the Abstract Dissertation. Get abstract dissertation writing by our pro dissertation professionals.

    ReplyDelete