Git Product home page Git Product logo

anprx's Introduction

PyPI version Build Status Documentation Status

ANPRx

Traffic analysis using networks of Automatic Number Plate Recognition cameras.

Installation

ANPRX is available through pypi:

pip install anprx

See requirements.txt for a complete list of dependencies.

Important: OSMnx requires the Rtree package which is a python wrapper for libspatialindex. To get osmnx to work properly, which this package heavily relies on, download and install libspatialindex first.

Features

  • Obtain a model of the drivable street network, using osmnx and networkx, that encompasses the traffic cameras (coordinate points).
from anprx.core import Point
from anprx.core import get_surrounding_network

# Using the same dummy location twice
locations = [ Point(lat = 54.974537,
                    lng = -1.625644),

              Point(lat = 54.974537,
                    lng = -1.625644)]

network = get_surrounding_network(locations)
  • Instantiate camera objects whose observed network edge is implicitly estimated. If the camera's address has been annotated by a human, you can use it to remove candidate edges with a different address.
import networkx as nx
from anprx.core import Camera

# With address filtering - only nearby edges with the
#                          given address are considered
mock_camera1 = Camera(
  network = network,
  id = "c1",
  point = locations[0],
  address = "Pitt Street, Newcastle Upon Tyne, UK")

# Without address filtering - all nearby edges are considered
mock_camera2 = Camera(
  network = network,
  id = "c2",
  point = locations[1])

# chosen edge
mock_camera1.edge
mock_camera2.edge

# proportion of valid points for each candidate edge
mock_camera1.p_cedges
mock_camera2.p_cedges

# then you can compute routes between cameras
route = nx.shortest_path(network,
                         source = mock_camera1.edge.u,
                         target = mock_camera2.edge.v,
                         weight = 'length')
  • Visualise the camera's placement on the road network, including nearby nodes, and the likelihood of candidate edges.
from anprx.plot import plot_camera

plot_camera(mock_camera1)
plot_camera(mock_camera2)
Mock camera on Pitt Street with address filtering Mock camera on Pitt Street without address filtering
not a real camera, sorry :() not a real camera, sorry :(
  • Produce a video animation explaining how the edge estimation algorithm works.
from anprx.animate import animate_camera

# saved to ~/.anprx/images/c1.mp4
anim1 = animate_camera(mock_camera1,
                       progress = True,                       
                       save_mp4 = True)

# saved to ~/.anprx/images/c2.mp4
anim2 = animate_camera(mock_camera2)

Animated!

  • Enrich the road network by adding further attributes to the edges of the network (address details, elevation, bearing).
import osmnx as ox
from anprx.core import enrich_network

network     = enrich_network(network,
                             elevation_api_key = "dummy",
                             postcode_delim = ' ')

elevations  = nx.get_edge_attributes(network, 'elevation')
bearings    = nx.get_edge_attributes(network, 'bearing')
postcodes   = nx.get_edge_attributes(network, 'postcode')
suburbs     = nx.get_edge_attributes(network, 'suburb')
importance  = nx.get_edge_attributes(network, 'importance')
road_types  = nx.get_edge_attributes(network, 'type')

# you can use osmnx to plot the network and colour the edges by attribute
edges_color = ox.get_node_colors_by_attr(network, 'bearings', cmap='plasma')
fig, ax     = ox.plot_graph(network, edge_color = egdes_color)

Under development

Among others:

  • Filter/compress the road network based on edge attributes.
  • Batch analysis of ANPR data: trip identification and inference.

Documentation

All modules and methods are documented in anprx.readthedocs.io

License

Apache v2.0

anprx's People

Contributors

ppintosilva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.