Commit 2e755e24 authored by Kelvinrr's avatar Kelvinrr
Browse files

merge from upstream

parents 00862a06 250dc4ec
Loading
Loading
Loading
Loading
+30 −13
Original line number Diff line number Diff line
language: generic  # Since we use conda, just go generic
sudo: false
language: generic
sudo: true

branches:
  only:
    - dev
    - testing

os:
  - linux
  - osx
matrix:
  include:
    - os: linux
      env: PYTHON_VERSION=3.6
    - os: linux
      env: PYTHON_VERSION=3.7
    
env:
  - PYTHON_VERSION=3.5
  - PYTHON_VERSION=3.6
  - PYTHON_VERSION=3.7

# Setup a postgresql instance w/postgis
services:
  - postgresql
addons:
  postgresql: 9.6
  apt:
    packages:
    - postgresql-9.6-postgis-2.4

before_install:
  # Create the template database that is used to instantiate the test DB 
  - psql -c 'create database template_postgis;' -U postgres
  - psql template_postgis -U postgres -c "create extension postgis"
  - psql template_postgis -c "create extension postgis_topology"
  - psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
  - psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
  - psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"

install:
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
@@ -26,6 +44,7 @@ before_install:
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda config --add channels conda-forge
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a
@@ -34,13 +53,11 @@ before_install:
  - source activate test

  # Install dependencies
  - conda config --add channels menpo
  - conda config --add channels usgs-astrogeology
  - conda config --add channels conda-forge
  - conda env update -n test -f environment.yml
  - export PROJ_LIB=$CONDA_PREFIX/share/proj  

script:
  - pytest autocnet tests
  - autocnet_config=config/test_config.yml pytest -v autocnet

after_success:
  - coveralls

README.md

0 → 100644
+29 −0
Original line number Diff line number Diff line
# AutoCNet

[![Gitter Chat](https://badges.gitter.im/USGS-Astrogeology/autocnet.svg)](https://gitter.im/USGS-Astrogeology/autocnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Travis-CI](https://travis-ci.org/USGS-Astrogeology/autocnet.svg?branch=dev)](https://travis-ci.org/USGS-Astrogeology/autocnet)

[![Coveralls](https://coveralls.io/repos/USGS-Astrogeology/autocnet/badge.svg?branch=dev&service=github)](https://coveralls.io/github/USGS-Astrogeology/autocnet?branch=dev)

[![Docs](https://img.shields.io/badge/Docs-latest-green.svg)](https://usgs-astrogeology.github.io/autocnet/)

Automated sparse control network generation to support photogrammetric control of planetary image data.

## Documentation
Is available at: https://usgs-astrogeology.github.io/autocnet/

## Installation Instructions
We suggest using Anaconda Python to install Autocnet within a virtual environment.  These steps will walk you through the process.

1. [Download](https://www.continuum.io/downloads) and install the Python 3.x Miniconda installer.  Respond ``Yes`` when prompted to add conda to your BASH profile.  
2. Install the autocnet environment using the supplied environment.yml file: `conda env create -n autocnet -f environment.yml` 
3. Activate your environment: `conda activate autocnet`
4. If you are doing to develop autocnet or would like to use the bleeding edge version: `python setup.py develop`. Otherwise, `conda install -c usgs-astrogeology` autocnet.

## How to run the test suite locally

1. Install Docker
2. Get the Postgresql with Postgis container and run it `docker run --name testdb -e POSTGRES_PASSOWRD='' -e POSTGRES_USER='postgres' -p 5432:5432 -d mdillon/postgis`
3. create database template_postgis: `docker exec testdb psql -c 'create database template_postgis;' -U postgres`
4. Run the test suite: `autocnet_config=config/test_config.yml pytest autocnet`

README.rst

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
===============================
AutoCNet
===============================

.. image:: https://badges.gitter.im/USGS-Astrogeology/autocnet.svg
   :alt: Join the chat at https://gitter.im/USGS-Astrogeology/autocnet
   :target: https://gitter.im/USGS-Astrogeology/autocnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://img.shields.io/pypi/v/autocnet.svg
        :target: https://pypi.python.org/pypi/autocnet

.. image:: https://travis-ci.org/USGS-Astrogeology/autocnet.svg?branch=master
    :target: https://travis-ci.org/USGS-Astrogeology/autocnet

.. image:: https://coveralls.io/repos/USGS-Astrogeology/autocnet/badge.svg?branch=master&service=github
    :target: https://coveralls.io/github/USGS-Astrogeology/autocnet?branch=master

.. image:: https://img.shields.io/badge/Docs-latest-green.svg
    :target: hhttps://usgs-astrogeology.github.io/autocnet/
    :alt: Documentation Status

.. image:: https://badge.waffle.io/USGS-Astrogeology/autocnet.png?label=ready&title=Ready
 :target: https://waffle.io/USGS-Astrogeology/autocnet
 :alt: 'Stories in Ready'

Automated sparse control network generation to support photogrammetric control of planetary image data.

* Documentation: https://usgs-astrogeology.github.io/autocnet/

Installation Instructions
-------------------------
We suggest using Anaconda Python to install Autocnet within a virtual environment.  These steps will walk you through the process.

#. [Download](https://www.continuum.io/downloads) and install the Python 3.x Miniconda installer.  Respond ``Yes`` when
   prompted to add conda to your BASH profile.  
#. (Optional) We like to sequester applications in their own environments to avoid any dependency conflicts.  To do this:
   
   * ``conda create -n <your_environment_name> python=3 && source activate <your_environment_name>``
   
   Note, that you might want to specify either ``python=3.5`` or ``python=3.6``, depending on your requirements. Both are currently supported by autocnet.
#. Make the newly created environment the active one:

   * ``conda activate <your_environment_name>`` (or ``source activate`` on an older conda system)
   
#. Bring up a command line and add three channels to your conda environment-specific config file:
   
   * ``conda config --env --add channels conda-forge``
   * ``conda config --env --add channels menpo``
   * ``conda config --env --add channels usgs-astrogeology``
#. Finally, install autocnet: ``conda install autocnet``

+2 −2
Original line number Diff line number Diff line
import numpy as np
from autocnet.camera.utils import crossform
import cv2
from cv2 import triangulatePoints



@@ -102,7 +102,7 @@ def triangulate(pt, pt1, p, p1):
    if pt1.shape[0] != 3:
        pt1 = pt1.T

    X = cv2.triangulatePoints(p, p1, pt[:2], pt1[:2])
    X = triangulatePoints(p, p1, pt[:2], pt1[:2])
    X /= X[3] # Homogenize
    return X

+0 −52
Original line number Diff line number Diff line
@@ -1363,9 +1363,6 @@ class NetworkCandidateGraph(CandidateGraph):
        onobj = options[on]

        res = []
        key = 1
        if isinstance(on, EdgeView):
            key = 2

        for job_counter, elem in enumerate(onobj.data('data')):
            # Determine if we are working with an edge or a node
@@ -1428,54 +1425,6 @@ class NetworkCandidateGraph(CandidateGraph):
        for i, n in self.nodes(data='data'):
            n.generate_vrt(**kwargs)

    def compute_overlaps(self):
        """
        For the candidate graph, compute the overlapping polygons that
        comprise the entire candidate graph / footprint map. Each overlap
        includes an 'overlaps' attribute/column that includes a list of the
        footprint polygons that have contributed to given overlap.

        """
        query = """
    SELECT ST_AsEWKB(geom) AS geom FROM ST_Dump((
        SELECT ST_Polygonize(the_geom) AS the_geom FROM (
            SELECT ST_Union(the_geom) AS the_geom FROM (
                SELECT ST_ExteriorRing((ST_DUMP(footprint_latlon)).geom) AS the_geom
                FROM images) AS lines
        ) AS noded_lines
    )
)"""
        session = Session()
        oquery = session.query(Overlay)
        iquery = session.query(Images)

        rows = []
        srid = config['spatial']['srid']
        for q in engine.execute(query).fetchall():
            overlaps = []
            b = bytes(q['geom'])
            qgeom = shapely.wkb.loads(b)
            res = iquery.filter(Images.footprint_latlon.ST_Intersects(geoalchemy2.shape.from_shape(qgeom, srid=srid)))
            for i in res:
                fgeom = geoalchemy2.shape.to_shape(i.footprint_latlon)
                area = qgeom.intersection(fgeom).area
                if area < 1e-6:
                    continue
                overlaps.append(i.id)
            o = Overlay(geom=f'SRID={srid};{qgeom.qkt}', overlaps=overlaps)
            res = oquery.filter(Overlay.overlaps == o.overlaps).first()
            if res is None:
                rows.append(o)

        session.bulk_save_objects(rows)
        session.commit()

        # If an overlap has only 1 entry, it is a sliver and we want to remove it.
        res = oquery.filter(sqlalchemy.func.array_length(Overlay.overlaps, 1) <= 1)
        res.delete(synchronize_session=False)
        session.commit()
        session.close()

    def to_isis(self, path, flistpath=None,         sql = """
SELECT points.id, measures.serial, points.pointtype, measures.sample, measures.line, measures.measuretype,
measures.imageid
@@ -1570,4 +1519,3 @@ AND i1.id < i2.id""".format(query_string)
        obj = cls.from_adjacency(adjacency, node_id_map=adjacency_lookup, config=config)

        return obj
Loading