alpr-unconstrained icon indicating copy to clipboard operation
alpr-unconstrained copied to clipboard

ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type

Open azhaoaigaga opened this issue 6 years ago • 2 comments

File "/home/zhaolzlz/Desktop/alpr-unconstrained/darknet/python/darknet.py", line 127, in detect im = load_image(image, 0, 0) ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type Excuse me, why is there a type error here

azhaoaigaga avatar Jun 19 '19 02:06 azhaoaigaga

Usually a Python 3 issue with Darknet. Please use Python 2.7.

sergiomsilva avatar Jun 24 '19 03:06 sergiomsilva

@azhaoaigaga

Actually there's an easy fix for that, check this https://github.com/pjreddie/darknet/issues/241#issuecomment-354640772

TL; DR; you have to change the strings passed to the darknet part to "bytes", so just add a b in front of strings when you directly define them, or explicitly convert them using the bytes function.

So for instance somewhere in the vehicle-detection.py script:

model_path = b'/path/to/model'

R,_ = detect(vehicle_net, vehicle_meta, bytes(img_path, encoding='utf-8'),
             thresh=vehicle_threshold)

matteobarbieri avatar Aug 30 '19 08:08 matteobarbieri