geowatch.cli.coco_crop_tracks module

CommandLine

DVC_DPATH=$(geowatch_dvc --hardware="hdd")
echo $DVC_DPATH
python -m geowatch.cli.coco_crop_tracks \
    --src="$DVC_DPATH/Aligned-Drop3-TA1-2022-03-10/data.kwcoco.json" \
    --dst="$DVC_DPATH/Cropped-Drop3-TA1-2022-03-10/data.kwcoco.json" \
    --mode=process --workers=8


# Small test of KR only
DVC_DPATH=$(geowatch_dvc --hardware="hdd")
echo $DVC_DPATH
python -m geowatch.cli.coco_crop_tracks \
    --src="$DVC_DPATH/Drop2-Aligned-TA1-2022-02-15/data.kwcoco.json" \
    --dst="$DVC_DPATH/Cropped-Drop2-TA1-test/data.kwcoco.json" \
    --mode=process --workers=8 --channels="red|green|blue" \
    --include_sensors="WV,S2,L8" --select_videos '.name | startswith("KR_R001")' \
    --target_gsd=3


TODO:
    - [ ] option to merge overlapping regions?
class geowatch.cli.coco_crop_tracks.CocoCropTrackConfig(*args, **kwargs)[source]

Bases: DataConfig

Create a dataset of aligned temporal sequences around objects of interest in an unstructured collection of annotated geotiffs.

High Level Steps:
  • Find a set of geospatial AOIs

  • For each AOI find all images that overlap

  • Orthorectify (or warp) the selected spatial region and its annotations to a cannonical space.

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

default = {'channels': <Value(None)>, 'context_factor': <Value(1.8)>, 'dst': <Value(None)>, 'exclude_sensors': <Value(None)>, 'include_sensors': <Value(None)>, 'keep': <Value('img')>, 'mode': <Value('process')>, 'select_images': <Value(None)>, 'select_videos': <Value(None)>, 'sqlmode': <Value(0)>, 'src': <Value('in.geojson.json')>, 'target_gsd': <Value(1)>, 'workers': <Value(1)>}
geowatch.cli.coco_crop_tracks.main(cmdline=0, **kwargs)[source]

Simple CLI for cropping to tracks

geowatch.cli.coco_crop_tracks.make_track_kwcoco_manifest(dst, dst_bundle_dpath, tid_to_assets, target_gsd=1)[source]

Rebundle in a a new kwcoco file

Todo

  • [ ] populate auxiliary is taking a long time, speed it up.

geowatch.cli.coco_crop_tracks.generate_crop_jobs(coco_dset, dst_bundle_dpath, channels=None, context_factor=1.0)[source]

Generator that yields parameters to be used to call gdal_translate

Benchmark

# Test kwimage versus shapely warp

kw_poly = kwimage.Polygon.random() kw_poly = kwimage.Boxes.random(1).to_polygons()[0]

sh_poly = kw_poly.to_shapely() transform = kwimage.Affine.random()

import timerit ti = timerit.Timerit(100, bestof=10, verbose=2) for timer in ti.reset(‘shapely’):

with timer:

# This is faster than fancy indexing a, b, x, d, e, y = transform.matrix.ravel()[0:6] sh_transform = (a, b, d, e, x, y) sh_warp_poly = affine_transform(sh_poly, sh_transform)

for timer in ti.reset(‘kwimage’):
with timer:

kw_warp_poly = kw_poly.warp(transform)

kw_warp_poly2 = kwimage.Polygon.from_shapely(sh_warp_poly) print(kw_warp_poly2) print(kw_warp_poly)

geowatch.cli.coco_crop_tracks.run_crop_asset_task(crop_asset_task, keep)[source]