Opened 9 years ago

Closed 8 years ago

#702 closed defect/bug (fixed)

Speed camera OSD

Reported by: tegzed Owned by: KaZeR
Priority: major Milestone:
Component: core Version: git master
Severity: Keywords: gui speed camera osd
Cc: nick@…

Description

Hello,

Recently I have been working on a speed camera warner OSD module. The module takes an IGO8 format speedcam text file as input and warns when a listed camera gets close. The input format is described here(sorry for the hungarian): http://www.pdacafe.hu/speedcam-informacios-adatbazis-az-igo-navigacios-szoftverhez.html the file format includes the type of camera(fixed,built in traffic lamp,red lamp detection,section camera,mobile camera,railway cross camera,traffipax), direction type(all directions,unidirectional,bidirectional) and direction data and the speed limit the camera is set to.

The search for the closest camera is done using a quadtree based algorithm for performance reasons. On each new position fix the closest camera is searched for and for such frequent search this algorithm gives appropriate performance. During my tests a camera list with more than 54000 entries gave sufficient performance.

This OSD module will search the camera list file in $NAVIT_DATA_DIR/speedcam.txt or if path attribute is set in the osd tag then at the position the path attribute points to.

An example osd line is shown below:

<osd enabled="yes" type="speed_cam" w="550" h="40" x="30" y="350" announce_on="1" font_size="350" path="/home/dandor/speedcam.txt" />

During operation the above mentioned properties will be displayed for the closest camera and an announcement is emitted when speed dependant distance limit is reached and the user is also notified by the color of the output text. Please test it and if you find bugs or have suggestions please send comment to this ticket. If you find this useful I'll commit this patch.

An extract from the input file is shown here to show the input file format:

X,Y,TYPE,SPEED,DIRTYPE,DIRECTION
13.74132,51.04641,2,50,0,0
8.34681,49.62934,2,50,0,0
12.11390,49.02778,3,0,0,0
8.83805,53.08262,3,0,0,0
9.14767,47.68987,3,0,0,0
6.94611,51.12167,1,30,0,0
7.82556,51.46417,1,70,0,0
14.17350,51.12366,5,50,0,0
13.89502,52.25109,5,100,0,0

Regards, David Tegze

Attachments (6)

openSUSE_crash.txt (20.4 KB) - added by number6 9 years ago.
de.po.in.diff (412 bytes) - added by hape 9 years ago.
German translation for announcment of speedcam and speedwarner
osd_core.c.speedcam.diff (24.1 KB) - added by tegzed 9 years ago.
add support for cameras in navit binfile maps
igo2navittext.pl (393 bytes) - added by tegzed 9 years ago.
changed to more perl-ish syntax
csv.tbz2 (4.8 KB) - added by tegzed 8 years ago.
initial version of csv map driver
Unknown_2011-10-01_082526.png (194.2 KB) - added by hape 8 years ago.
Display if no speedcam is near by

Download all attachments as: .zip

Change History (39)

comment:1 Changed 9 years ago by tegzed

Here is another link for the google translated version of the page mentioned above.Not a perfect translation but gives more info for the minority of people who cannot speak hungarian :)

http://translate.google.pl/translate?js=n&prev=_t&hl=pl&ie=UTF-8&layout=2&eotf=1&sl=hu&tl=en&u=http://www.pdacafe.hu/speedcam-informacios-adatbazis-az-igo-navigacios-szoftverhez.html&act=url

comment:2 follow-up: Changed 9 years ago by korrosa

Good work once again tegzed! A suggestion: speed cameras are also available in OSM data, and these are marked as either: 1) NODE: highway = speed_camera (http://wiki.openstreetmap.org/wiki/Tag:highway%3Dspeed_camera) 2) RELATION: type = enforcement; enforcement = maxspeed OR traffic_signals; maxspeed = xx (http://wiki.openstreetmap.org/wiki/Relation:enforcement)

highway = speed_camera IS processed by maptool, so that data is available. If the node data can be tied in with any available maxspeed data, that would be awesome. Obviously, this doesn't provide quite the level of detail as IGO8 format, but it'd be a good addition...

Discuss.

comment:3 in reply to: ↑ 2 Changed 9 years ago by number6

  • Cc nick@… added

highway = speed_camera IS processed by maptool, so that data is available. If the node data can be tied in with any available maxspeed data, that would be awesome. Obviously, this doesn't provide quite the level of detail as IGO8 format, but it'd be a good addition...

The inclusion of data already available to us would be great.

comment:4 Changed 9 years ago by tegzed

Yes, I also think that inclusion of OSM speed_camera data would be great and it would only affect the input reading part of the speedecam osd. Unfortunately in Hungary`s OSM data there is only one speed_camera entry :) while in the IGO8 text files I downloaded several thousand cameras were listed. So I don't have much chance to test OSM data :) When handling both input methods we need some method to avoid duplicate camera entries. Maybe cameras closer than a predefined distance treshold can be filtered out. Can anybody do tests on this patch to make sure it works correctly on different devices?

comment:5 Changed 9 years ago by korrosa

I can give it a go on my Ubuntu netbook - does the latest patch include the use of OSM speed_camera data?. For others, IGO8 speed camera data: http://speedcamerapoi.com/download.php. Other, better websites may be available...

comment:6 Changed 9 years ago by number6

  • Keywords gui speed camera osd added

Crashes on openSUSE. Attached dumpfile.

No GPS installed, crashes on both GTK and internal GUI. Navit.xml entry is

<osd enabled="yes" type="speed_cam" w="550" h="40" x="30" y="350" font_size="350" path="/home/number6/Downloads/ie-speedcam.txt" />

Changed 9 years ago by number6

comment:7 Changed 9 years ago by tegzed

Korrosa: the OSM camera data handling is not included. How much camera data could you find for your country?

Number6: hmm. Have you used Demo vehicle? I could reproduce the crash with the Demo vehicle, but not with other vehicle types (nmea replayer and gpsd) maybe demo vehicle is not providing some attribute data that is needed by the osd. I'll check it and upload a fixed version soon.

comment:8 Changed 9 years ago by korrosa

For the United Kingdom there's 10094 camera locations in the IGO8 file from http://speedcamerapoi.com/download.php. (There's 30 for Ireland...!!) However, I've had a quick look in my area and it seems that there are multiple instances of the same camera defined, at slightly different locations (about 10m difference) - I would expect the code which will integrate the OSM speed_camera data to be able to filter out any instances of cameras (both from IGO8 and OSM data) closer than a certain threshold, but what that threshold should be I'm not sure: perhaps let the user decide in the xml file?

comment:9 Changed 9 years ago by tegzed

Number6,can you pls try this latest patch also to see if this solves your crash?

comment:10 Changed 9 years ago by number6

Dandor, yes, it does fix the problem! Great!

Would it be possible to get a screenshot of the speed_cam GUI in action, so I can compare with my own installation?

Also, can navit parse this data from the binfile also?

comment:11 Changed 9 years ago by hape

any plans to make a possibility to show only a icon for the cam type with the distance below. This could be handy for devices with small screens. You could take the icons from here: http://speedcamerapoi.com/download.php

comment:12 Changed 9 years ago by hape

Some warnings: sd_core.Tpo -c osd_core.c -fPIC -DPIC -o .libs/osd_core.o osd_core.c:1181: warning: no previous prototype for 'quadtree_node_new' osd_core.c:1204: warning: no previous prototype for 'quadtree_find_nearest_flood' osd_core.c: In function 'quadtree_find_nearest_flood': osd_core.c:1220: warning: unused variable 'dist_min' osd_core.c: At top level: osd_core.c:1250: warning: no previous prototype for 'quadtree_find_nearest' osd_core.c:1326: warning: no previous prototype for 'quadtree_add' osd_core.c: In function 'quadtree_add': osd_core.c:1330: warning: implicit declaration of function 'quadtree_split' osd_core.c: At top level: osd_core.c:1374: warning: no previous prototype for 'quadtree_split' osd_core.c:1419: warning: no previous prototype for 'quadtree_destroy' osd_core.c:1463: warning: function declaration isn't a prototype osd_core.c:1598: warning: no previous prototype for 'osd_speed_cam_load' osd_core.c: In function 'osd_speed_cam_load': osd_core.c:1603: warning: unused variable 'tmp_str' osd_core.c: In function 'osd_text_format_attr': osd_core.c:2075: warning: implicit declaration of function 'iso8601_to_secs' osd_core.c: At top level: osd_core.c:2382: warning: no previous prototype for 'oti_new' osd_core.c: In function 'osd_auxmap_draw': osd_core.c:2899: warning: unused variable 'c' osd_core.c: In function 'quadtree_split': osd_core.c:1416: warning: control reaches end of non-void function osd_core.c: In function 'quadtree_add': osd_core.c:1371: warning: control reaches end of non-void function osd_core.c: In function 'osd_speed_cam_load': osd_core.c:1605: warning: 'lon_str' may be used uninitialized in this function I expect they are comming from your patch ...

comment:13 Changed 9 years ago by hape

Tested on the PalmPre? today morning. Working without problems. I did not used that path attribute. Only copied the seedcam.txt for Germany into the Navit directory. Can you enable the text_color attribute please, background_color is working.

Thanks for the patch.

Changed 9 years ago by hape

German translation for announcment of speedcam and speedwarner

comment:14 Changed 9 years ago by hape

Can you please add the German translations when you check it in. I attached the diff.

comment:15 Changed 9 years ago by korrosa

So got this to work fine now - thanks for the help on irc! Two feature requests:

1) Can we split up the displayed string into its constituent parts, so I can decide which to display? So there'd be $distance, $type, $direction, $directiontype and $speed strings to choose from (perhaps choose better names!). This could be quite useful, as here in the UK speed limits are in mph, and it looks like many of the speed limits in the file I linked to previously are actually in mph, which means it shows up wrong on the osd.

2) Can we choose how to announce the speed camera? Many sat-navs just give an audible noise (like a hooter or a beep) when a speed camera is close by. I'd very much like to be able to just make a noise when a camera is within a threshold $distance - perhaps by using the native 'beep' command in Linux. Obviously, not every platform has 'beep', so perhaps something more generic: allow a user to execute a command within a threshold $distance from a camera? Bonus points for allowing separate commands for separate types of cameras...!!

Good work on this one!

comment:16 Changed 9 years ago by tegzed

Korrosa:

  1. I also planned some template replacement for the text of speedcam similarly to odometer
  2. however I think the custom command execution is not so easy to implement in a way that works on most devices

comment:17 Changed 9 years ago by tegzed

Korrosa: I updated the patch again, now it accepts an attibute called label with format string. it accepts the following format parameters: ${distance} ${camera_type} ${camera_dir} ${direction} ${speed_limit} See an example line below:

<osd enabled="yes" type="speed_cam" w="500" h="40"  x="30" y="350"   font_size="450" text_color="#FF0000" label=" ${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" />  

so one can now choose the data elements to be displayed

comment:18 follow-up: Changed 9 years ago by korrosa

Good job!

I've been going through the code, and appreciate that English isn't your first language. I have some suggestions for translations for camera types (also shown on http://wiki.navit-project.org/index.php/User:Korrosa#OSD:_Speed_Camera):

  • Fix -> Fixed. This is a fixed speed enforcement camera.
  • Traffic lamp -> Red light. This is a red light enforcement camera.
  • Red detect -> Bus lane. Typically, this is a camera which will check bus lanes for non-bus traffic which shouldn't be in that lane. These lanes are often red, hence 'red detect' I guess!
  • Section -> Avg speed. These are average speed check cameras.
  • Mobile -> Mobile. Mobile cameras. This one seems fine.
  • Rail -> Rail. Railway crossings. This one seems fine.
  • Traffipax(non persistent) -> I have no idea what this is supposed to be!

Other suggestions are very welcome, but I hope this helps!

comment:19 in reply to: ↑ 18 Changed 9 years ago by hape

Replying to http://wiki.navit-project.org/index.php/user:korrosa:

I've been going through the code, and appreciate that English isn't your first language. I

I can add the German versions if you tell me how.

comment:20 Changed 9 years ago by hape

Hi Dandor,

did some more testing yesterday with a lager database, about 12000 speedcams for Germany. The performance is still good on my Palm Pre. I got a lot of false positives for camera that are on a street that is 100-200 meters away from the street that I'm driving on. Would it be possible to also check the distance to the calculated route and only announce the camera if the distance is below 30 meters?

comment:21 Changed 9 years ago by hape

Hi David,

I would like to show the camera type below the distance. Is it possible to add support for /n in the label tag.

Hape

Changed 9 years ago by tegzed

add support for cameras in navit binfile maps

Changed 9 years ago by tegzed

changed to more perl-ish syntax

comment:22 Changed 9 years ago by tegzed

If anybody would like to test camera handling from navit binfile then this latest patch can be used for that. Speedcam osd now tries to use binfile based camera list if no IGO8 format file is found (no speedcam.txt in navit data dir and no path attribute in osd tag). One should create a navit textfile first using the attached igo2navittext.pl. The script reads its input on standard input and outputs navit textfile on stdout. Usage is the following :

perl igo2navittext.pl  < speedcam.txt  > speedcam_navit.txt

One can create navit binfile from this navit textfile by copying it to the maps folder in the source tree and issuing the following command (of course the base name should be the same as the navit text file, in this case speedcam_navit):

make speedcam_navit.bin

The resulting bin file should be added to the active mapset in navit.xml as usual. After this if no IGO8 camera data is configured and there is no speedcam.txt in navit data dir the speedcam osd will use the binfile data. Using binfile has the advantage that cameras are displayed on the map.

comment:23 Changed 9 years ago by korrosa

The latest diff and igo2navittext.pl all works for me, and the cameras show up perfectly on the map! This is some amazing stuff, and will be very useful!

Another feature request: can we have an option where over a certain camera distance threshold the text disappears? This gives it the effect of "popping-up" when the camera comes into the range!

Changed 8 years ago by tegzed

initial version of csv map driver

comment:24 Changed 8 years ago by tegzed

Hello,

I changed the behaviour of speedcam osd a bit. Now it doesn't try to load csv files directly but uses map data only. So it won't load file specified by path attribute in osd tag or speedcam.txt in navit data dir anymore. To be able to use igo8 files without modification I've implemented a map driver to load map items in csv format. Of course camera definitions in navit textfile or binfile format can also be used as described in the above comments. To configure a csv map one needs to create a map tag with type set to "csv" inside the active mapset definition in navit.xml. The map definition should set the item type of the the csv records (one csv file can only contain one item type) (See below definition). For speed cameras it is "tec_common". The corresponding attribute types for the columns of csv file should be specified by attr_types attribute inside the map tag. The value of that attribute should be a comma separated list of navit attributes in the order they appear in the csv file. The data attribute of map tag is used to set the csv file's path similarly to other map types.

Here is a definition to load the most common igo8 csv format: <map type="csv" enabled="yes" data="/home/dandor/speedcam.txt" item_type="tec_common" attr_types="position_longitude,position_latitude,tec_type,maxspeed,tec_dirtype,tec_direction" />

The below definition is usable for igo8 csv with id column: <map type="csv" enabled="yes" data="/home/dandor/speedcam.txt" item_type="tec_common" attr_types="id,position_longitude,position_latitude,tec_type,maxspeed,tec_dirtype,tec_direction" />

The csv map definition should have position_longitude and position_latitude attributes in the attr list definition otherwise the csv file will not be loaded.

The osd tag for the speedcam warner is the same as before with the difference that the path attribute is not used anymore.

Below is an example: <osd enabled="yes" type="speed_cam" w="550" h="40" x="30" y="350" font_size="450" text_color="#00FF00" label="${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" />

By using the csv map driver the camera icons can be seen on the map and other item types than cameras in csv format can be used by navit.

This modification is committed to svn and can be reached from r3873.

David Tegze

comment:25 follow-up: Changed 8 years ago by korrosa

Woohoo, good stuff! Question: why not use the header (first line) within the csv file to define the item type and attribute types, instead of in the map xml? Just curious, as I have no real preference...

comment:26 in reply to: ↑ 25 Changed 8 years ago by tegzed

Hi Korrosa,

I have downloaded some igo files before with very different headers, only the order was the same for them, for example some used "X,Y" for the coordinates some others used "longitude,latitude" so it seemed to me that the most straightforward way is to specify the order explicitly.

Replying to http://wiki.navit-project.org/index.php/user:korrosa:

Woohoo, good stuff! Question: why not use the header (first line) within the csv file to define the item type and attribute types, instead of in the map xml? Just curious, as I have no real preference...

comment:27 Changed 8 years ago by hape

Hi David,

I'm using build 3883. Everything is working as expected when the next speedcam is nearby. If this is not the case I get wired information in the display for the next speedcam. I attached you a screenshot and my speecam file.

Changed 8 years ago by hape

Display if no speedcam is near by

comment:28 Changed 8 years ago by tegzed

Hi Hape,

Can you pls try the version from yesterday(r3903). I fixed a couple of problems in that version including that one.

comment:29 Changed 8 years ago by hape

Hi David, restested with r3922 and it is working now. #

HaPe?

comment:30 Changed 8 years ago by tegzed

  • Resolution set to fixed
  • Status changed from new to closed

comment:31 Changed 8 years ago by hape

  • Resolution fixed deleted
  • Status changed from closed to reopened

Hi, I have the problem that I get no voice warning in the case when I drive into a section with a speed limit and I'm already above the limit.

The warning is announced when I go below the limit one time or when I'm below the limit when I enter the section where the limit starts.

HaPe?

comment:32 Changed 8 years ago by tegzed

Hi Hape,

The limit is speed dependent, and changes linearly with speed, lower speed lower limit. If we are below the limit no announcement fired. At speed 130km/h the distance limit is 750m . Currently the speed limit attribute of cameras are not taken into account at announcements. Maybe it worth using that info also.

comment:33 Changed 8 years ago by hape

  • Resolution set to fixed
  • Status changed from reopened to closed

Sorry wron ticket

Note: See TracTickets for help on using tickets.