Esempio n. 1
0
# headings = np.arange(0, 360, step=DDEG) # AK12 only
hxyz = dem.horizon(eop['xyz'], headings)

# --- Format and save GeoJSON ---- #

geo = geojson.FeatureCollection([
    geojson.Feature(geometry=geojson.LineString(xyz.tolist())) for xyz in hxyz
])
geo = glimpse.helpers.ordered_geojson(geo)
glimpse.helpers.write_geojson(geo,
                              'geojson/horizons/' + STATION + '.geojson',
                              crs=32606,
                              decimals=(5, 5, 0))

# --- Check result ---- #

svg_path = glob.glob('svg/' + STATION + '_*.svg')[-1]
img_path = cg.find_image(svg_path)
cam_args = cg.load_calibrations(path=img_path,
                                station_estimate=True,
                                merge=True)
img = glimpse.Image(img_path, cam=cam_args)
geo = glimpse.helpers.read_geojson('geojson/horizons/' + STATION + '.geojson',
                                   crs=32606)
lxyz = [coords for coords in glimpse.helpers.geojson_itercoords(geo)]
luv = [img.cam.project(xyz, correction=True) for xyz in lxyz]
img.plot()
for uv in luv:
    matplotlib.pyplot.plot(uv[:, 0], uv[:, 1], color='red')
img.set_plot_limits()
Esempio n. 2
0
    # 'AKST03A_20100720_184800',
    'CG04_20040707_200052',
    # NOTE: 20050811 ortho messed up
    # 'CG05_20050811_130000',
    # 'CG05_20050811_190000',
    # NOTE: More clarity than CG05_20050827_190000
    'CG05_20050826_190000',
    'CG06_20060712_195953',
    'CG06_20060727_195951'
)
clahe = cv2.createCLAHE(clipLimit=1.0, tileGridSize=(20, 20))

# ---- Select DEMs and Orthos ----

# Prepare DEMs
dem_paths = glob.glob(os.path.join(root, 'dem-aerometric', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-arcticdem', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-ifsar', 'data', '*.tif'))
dem_dates = [datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in dem_paths]

# Prepare orthophotos
ortho_paths = glob.glob(os.path.join(root, 'ortho', '*.tif'))
ortho_paths += glob.glob(os.path.join(root, 'ortho-ifsar', 'data', '*.tif'))
ortho_dates = [datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in ortho_paths]

# ---- Control synths (ideal camera) ----

for image in images:
    print(image)
Esempio n. 3
0
        img.cam.xyz = svg_images[0].cam.xyz
    fit = model.fit(full=True,
                    method='leastsq',
                    group_params=job['group_params']
                    if xyz_added else job['group_params'][:-1])
    suffix = datetime.datetime.now().strftime('-%Y%m%d%H%M%S')
    write_calibration(job['camera'],
                      model=model,
                      fit=fit,
                      station=station,
                      suffix=suffix)

# ---- Build ideal cameras ----

paths = [
    path for path in glob.glob(os.path.join('cameras', '*.json'))
    if not re.search(r'-[a-zA-Z]+($|\.)|_', path)
]
cameras = [glimpse.helpers.strip_path(path) for path in paths]
sequences = cg.Sequences()
ideal = dict(k=[0] * 6, p=[0] * 2, cmm=[0] * 2)
for path, camera in zip(paths, cameras):
    fmm = sequences[sequences.camera == camera].focal_length.iloc[0]
    new_args = glimpse.helpers.merge_dicts(ideal, dict(fmm=[fmm] * 2))
    calibration = glimpse.helpers.merge_dicts(glimpse.helpers.read_json(path),
                                              new_args)
    glimpse.helpers.write_json(calibration,
                               path=os.path.join('cameras',
                                                 camera + '-ideal.json'),
                               indent=4,
                               flat_arrays=True)
Esempio n. 4
0
    'nikon-d2x': keys - {'coast'},
    'nikon-d200-04-24': keys - {'coast'},
    'nikon-d200-08-24': keys - {'coast'},
    'nikon-d200-13-20': keys - {'coast', 'moraines'},
    'nikon-d200-14-20': keys - {'coast', 'moraines'},
    'canon-40d-01': keys - {'terminus', 'coast'}
}
step = 20 # pixels
suffixes = ['', '-calib', '-ideal']
stations = (
    'AK01', 'AK01b', 'AK03', 'AK03b', 'AK09', 'AK09b', 'AK10', 'AK10b',
    'AK12', 'AKJNC', 'AKST03A', 'AKST03B', 'CG04', 'CG05', 'CG06')

# ---- Orient anchor images ----

paths = glob.glob(os.path.join('svg', '*.svg'))
paths += glob.glob(os.path.join('svg-synth', '*.svg'))
metas = [cg.parse_image_path(path) for path in paths]
selected = [meta['station'] in stations for meta in metas]
paths = [path for path, meta in zip(paths, metas)
    if meta['station'] in stations]

for path in paths:
    meta = cg.parse_image_path(path, sequence=True)
    svg_keys = camera_keys.get(meta['camera'], keys)
    for suffix in suffixes:
        if not os.path.isfile(os.path.join(
            'cameras', meta['camera'] + suffix + '.json')):
            continue
        basename = os.path.join('images', meta['basename'] + suffix)
        if os.path.isfile(basename + '.json'):
Esempio n. 5
0
import cg
from cg import (glimpse, glob)
from glimpse.imports import (os, re, np)

DEM_DIR = '/volumes/science-b/data/columbia/dem'
DATE_STR = '20070922'

# ---- Read DEM ----

dem_path = glob.glob(os.path.join(DEM_DIR, DATE_STR + '*.tif'))[-1]
dem = glimpse.Raster.read(dem_path)

# ---- Moraine lines ----

paths = glob.glob('geojson/moraines/' + DATE_STR + '.geojson')
for path in paths:
    geo = glimpse.helpers.read_geojson(path, crs=32606)
    glimpse.helpers.elevate_geojson(geo, elevation=dem)
    for coords in glimpse.helpers.geojson_itercoords(geo):
        if any(np.isnan(coords[:, 2])):
            print('Missing elevations in ' + path)
    geo2 = glimpse.helpers.ordered_geojson(geo)
    glimpse.helpers.write_geojson(geo2,
        path=os.path.splitext(path)[0] + '.geojson',
        decimals=(7, 7, 2), crs=32606)

# ---- Ground control points ----

GCP_DEM_PATH = '/volumes/science-b/data/columbia/_new/ArcticDEM/v2.0/tiles/merged_projected_clipped.tif'
dem_ref = glimpse.Raster.read(GCP_DEM_PATH)
Esempio n. 6
0
import cg
from cg import (glimpse, glob)
from glimpse.imports import (np, cv2, os, matplotlib)

cg.IMAGE_PATH = '/volumes/science-b/data/columbia/timelapse'

MAX_DISTANCE_SCALE = 0.025  # max match distance (fraction of image width)
MAX_ERROR_SCALE = 0.005  # max RANSAC error (fraction of image width)
CAM_DXYZ = 25  # max camera displacement (meters)
MAX_PARALLAX = 0.5  # pixels

images = [
    glimpse.helpers.strip_path(path)
    for path in glob.glob(os.path.join('svg-synth', '*.svg'))
]
for image in images:
    basename = os.path.join(cg.CG_PATH, 'svg-synth', image)
    # Skip if output exists
    if os.path.isfile(basename + '.png'):
        continue
    print(image)
    # Prepare image
    cam = cg.load_calibrations(image,
                               station=True,
                               camera=True,
                               image=True,
                               viewdir=True,
                               merge=True,
                               file_errors=False)
    img = glimpse.Image(basename + '.JPG', cam=cam)
    I = img.read()