- Notifications
You must be signed in to change notification settings - Fork3
Traffic analysis using Automatic Number Plate Recognition (ANPR) cameras.
License
NotificationsYou must be signed in to change notification settings
ppintosilva/anprx
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Traffic analysis using networks of Automatic Number Plate Recognition cameras.
ANPRX is available through pypi:
pip install anprx
Seerequirements.txt
for a complete list of dependencies.
Important:OSMnx requires theRtree package which is a python wrapper forlibspatialindex. To get osmnx to work properly, which this package heavily relies on,download and installlibspatialindex first.
- Obtain a model of the drivable street network, usingosmnx andnetworkx, that encompasses the traffic cameras (coordinate points).
fromanprx.coreimportPointfromanprx.coreimportget_surrounding_network# Using the same dummy location twicelocations= [Point(lat=54.974537,lng=-1.625644),Point(lat=54.974537,lng=-1.625644)]network=get_surrounding_network(locations)
- Instantiate camera objects whoseobserved 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.
importnetworkxasnxfromanprx.coreimportCamera# With address filtering - only nearby edges with the# given address are consideredmock_camera1=Camera(network=network,id="c1",point=locations[0],address="Pitt Street, Newcastle Upon Tyne, UK")# Without address filtering - all nearby edges are consideredmock_camera2=Camera(network=network,id="c2",point=locations[1])# chosen edgemock_camera1.edgemock_camera2.edge# proportion of valid points for each candidate edgemock_camera1.p_cedgesmock_camera2.p_cedges# then you can compute routes between camerasroute=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.
fromanprx.plotimportplot_cameraplot_camera(mock_camera1)plot_camera(mock_camera2)
Mock camera on Pitt Street with address filtering | Mock camera on Pitt Street without address filtering |
---|---|
![]() | ![]() |
- Produce a video animation explaining how the edge estimation algorithm works.
fromanprx.animateimportanimate_camera# saved to ~/.anprx/images/c1.mp4anim1=animate_camera(mock_camera1,progress=True,save_mp4=True)# saved to ~/.anprx/images/c2.mp4anim2=animate_camera(mock_camera2)
- Enrich the road network by adding further attributes to the edges of the network (address details, elevation, bearing).
importosmnxasoxfromanprx.coreimportenrich_networknetwork=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 attributeedges_color=ox.get_node_colors_by_attr(network,'bearings',cmap='plasma')fig,ax=ox.plot_graph(network,edge_color=egdes_color)
Among others:
- Filter/compress the road network based on edge attributes.
- Batch analysis of ANPR data: trip identification and inference.
All modules and methods are documented inanprx.readthedocs.io
About
Traffic analysis using Automatic Number Plate Recognition (ANPR) cameras.
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published