Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Imagery pipeline & extract training dataset from OSM #133

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Key = highway
Value = crossing
ZoomLevel = 19
Compare = yes
Orthofoto = other
Orthofoto = wms
FollowStreets = yes
StepWidth = 0.66

Expand All @@ -86,16 +86,8 @@ Some hints to the config file:


### Own Orthofotos
To use your own Orthofotos you have to do the following steps:

1. Add a new directory to `src/data/orthofoto`
2. Add a new module to the directory with the name: <code><var>&lt;your_new_directory></var>_api.py</code>
3. Create a class in the module with the name: <code><var>&lt;Your_new_directory></var>Api</code> (First letter needs to be uppercase)
4. Implement the function `def get_image(self, bbox):` and returns a pillow image of the bbox
5. After that you can use your api with the parameter <code>--orthofots <var>&lt;your_new_directory></var></code>

If you have problems with the implementation have a look at the wms or other example.

Provide it as a WMS from a MapProxy server.

## Dataset
During this work, we have collected our own dataset with swiss crosswalks and non-crosswalks. The pictures have a size of 50x50 pixels and are available by request.
Expand Down
43 changes: 43 additions & 0 deletions mapproxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
layers:
- name: osm
title: osm
sources: [cache_osm]
- name: bing
title: bing
sources: [cache_bing]
- name: ign
title: ign
sources: [cache_ign]

caches:
cache_osm:
grids: [webmercator]
sources: [source_osm]
cache_bing:
grids: [webmercator]
sources: [source_bing]
cache_ign:
grids: [webmercator]
sources: [source_ign]

sources:
source_osm:
type: tile
grid: GLOBAL_WEBMERCATOR
url: http://a.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png
source_bing:
type: tile
grid: GLOBAL_WEBMERCATOR
url: https://t2.ssl.ak.tiles.virtualearth.net/tiles/a%(quadkey)s.jpeg?g=4401&n=z
source_ign:
type: tile
grid: GLOBAL_WEBMERCATOR
url: https://proxy-ign.openstreetmap.fr/94GjiyqD/bdortho/%(z)s/%(x)s/%(y)s.jpg

grids:
webmercator:
base: GLOBAL_WEBMERCATOR

services:
demo:
wms:
2 changes: 1 addition & 1 deletion requires.dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
click==6.6
geopy==1.11.0
httplib2==0.9.2
overpass==0.4.0
overpass==0.6.0
Pillow==2.6.1
pytest==2.9.2
redis==2.10.5
Expand Down
2 changes: 1 addition & 1 deletion src/base/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, config_file_path=''):
{'option': 'value', 'fallback': 'crossing'},
{'option': 'zoomlevel', 'fallback': '19'},
{'option': 'compare', 'fallback': 'yes'},
{'option': 'orthophoto', 'fallback': 'other'},
{'option': 'orthophoto', 'fallback': 'wms'},
{'option': 'stepwidth', 'fallback': '0.66'},
{'option': 'followstreets', 'fallback': 'yes'}]},
{'section': 'JOB', 'options': [{'option': 'bboxsize', 'fallback': '2000'},
Expand Down
15 changes: 8 additions & 7 deletions src/base/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


class Tile:
def __init__(self, image=None, bbox=None):
def __init__(self, image_api=None, image=None, bbox=None):
self.image_api = image_api
self.image = image
self.bbox = bbox

Expand All @@ -14,15 +15,15 @@ def get_pixel(self, node):
x = node.longitude - self.bbox.left
y = node.latitude - self.bbox.bottom

pixel_x = int(self.image.size[0] * (x / image_width))
pixel_y = self.image.size[1] - int(self.image.size[1] * (y / image_height))
image_size = self.image_api.get_image_size(self.bbox)
pixel_x = int(image_size[0] * (x / image_width))
pixel_y = image_size[1] - int(image_size[1] * (y / image_height))
return pixel_x, pixel_y

def get_node(self, pixel=(0, 0)):
x = pixel[0]
y = pixel[1]
image_size_x = self.image.size[0]
image_size_y = self.image.size[1]
image_size_x, image_size_y = self.image_api.get_image_size(self.bbox)
y_part = 0
x_part = 0
if image_size_x > 0 and image_size_y > 0:
Expand All @@ -45,12 +46,12 @@ def get_tile_by_node(self, centre_node, side_length):
y2 = centre_pixel[1] + side_length // 2

crop_box = (x1, y1, x2, y2)
img = self.image.crop(crop_box)
left_down = self.get_node((x1, y1))
right_up = self.get_node((x2, y2))
bbox = Bbox.from_nodes(node_left_down=left_down, node_right_up=right_up)
img = self.image_api.get_image(bbox)

return Tile(img, bbox)
return Tile(image=img, bbox=bbox)

def get_centre_node(self):
diff_lat = self.bbox.node_right_up().latitude - self.bbox.node_left_down().latitude
Expand Down
Empty file.
29 changes: 0 additions & 29 deletions src/data/orthofoto/other/fitting_bbox.py

This file was deleted.

60 changes: 0 additions & 60 deletions src/data/orthofoto/other/multi_loader.py

This file was deleted.

78 changes: 0 additions & 78 deletions src/data/orthofoto/other/other_api.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/data/orthofoto/other/url_builder.py

This file was deleted.

23 changes: 0 additions & 23 deletions src/data/orthofoto/other/user_agent.py

This file was deleted.

13 changes: 0 additions & 13 deletions src/data/orthofoto/tile_loader.py

This file was deleted.

10 changes: 4 additions & 6 deletions src/data/orthofoto/wms/wms.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ NtlmUser = hans
NtlmPassword = test

[WMS]
Url = http://test.com
Srs = EPSG:4326
Version = 1.0.1
Layer = upwms


Url = http://localhost:8080/service
Srs = EPSG:3857
Version = 1.1.1
Layer = bing
Loading