Python bindings broken?


#1

Hi,

I’m using the python bindings.

Quite many times they give me this:

File “/usr/lib/python3/dist-packages/openalpr/openalpr.py”, line 195, in recognize_ndarray
response_obj = json.loads(json_data)
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 128 (char 127)

Any ideas for solution?


#2

Hi,

Sometimes the cpp code of OpenALPR returns to the python something like this (variable json_data):

{“version”:2,“data_type”:“alpr_results”,“epoch_time”:1539532890876,“img_width”:2048,“img_height”:1232,“processing_time_ms”:191,15519714355469,“uuid”:"",“error”:false,“regions_of_interest”:[{“x”:0,“y”:0,“width”:2048,“height”:1232}],“results”:[{“plate”:“XOFI53”,“confidence”:76,290855407714844,“matches_template”:0,“plate_index”:0,“region”:“eu-lv”,“region_confidence”:59,“processing_time_ms”:25,441137313842773,“requested_topn”:3,“coordinates”:[{“x”:874,“y”:507},{“x”:1149,“y”:494},{“x”:1156,“y”:573},{“x”:880,“y”:586}],“vehicle_region”:{“x”:562,“y”:0,“width”:906,“height”:906},“candidates”:[{“plate”:“XOFI53”,“confidence”:76,290855407714844,“matches_template”:0},{“plate”:“XOF153”,“confidence”:70,827560424804688,“matches_template”:0},{“plate”:“XOF53”,“confidence”:67,264251708984375,“matches_template”:0}]}]}

That’s totally broken! The decimal separator should be “.” not “,” !

The quick fix is:

import re
p = re.compile(’\d(,)\d’)
json_data = p.subn(".", json_data)[0]

Cheers,

Sampsa