Skip to content

Commit

Permalink
Vehicle label checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomsilva committed Nov 5, 2018
1 parent a4fda91 commit 91328a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
34 changes: 18 additions & 16 deletions gen-outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,31 @@

sys.stdout.write('%s' % bname)

for i,lcar in enumerate(Lcar):
if Lcar:

draw_label(I,lcar,color=YELLOW,thickness=3)
for i,lcar in enumerate(Lcar):

lp_label = '%s/%s_%dcar_lp.txt' % (output_dir,bname,i)
lp_label_str = '%s/%s_%dcar_lp_str.txt' % (output_dir,bname,i)
draw_label(I,lcar,color=YELLOW,thickness=3)

if isfile(lp_label):
lp_label = '%s/%s_%dcar_lp.txt' % (output_dir,bname,i)
lp_label_str = '%s/%s_%dcar_lp_str.txt' % (output_dir,bname,i)

Llp_shapes = readShapes(lp_label)
pts = Llp_shapes[0].pts*lcar.wh().reshape(2,1) + lcar.tl().reshape(2,1)
ptspx = pts*np.array(I.shape[1::-1],dtype=float).reshape(2,1)
draw_losangle(I,ptspx,RED,3)
if isfile(lp_label):

if isfile(lp_label_str):
with open(lp_label_str,'r') as f:
lp_str = f.read().strip()
llp = Label(0,tl=pts.min(1),br=pts.max(1))
write2img(I,llp,lp_str)
Llp_shapes = readShapes(lp_label)
pts = Llp_shapes[0].pts*lcar.wh().reshape(2,1) + lcar.tl().reshape(2,1)
ptspx = pts*np.array(I.shape[1::-1],dtype=float).reshape(2,1)
draw_losangle(I,ptspx,RED,3)

sys.stdout.write(',%s' % lp_str)
if isfile(lp_label_str):
with open(lp_label_str,'r') as f:
lp_str = f.read().strip()
llp = Label(0,tl=pts.min(1),br=pts.max(1))
write2img(I,llp,lp_str)

sys.stdout.write('\n')
sys.stdout.write(',%s' % lp_str)

cv2.imwrite('%s/%s_output.png' % (output_dir,bname),I)
sys.stdout.write('\n')


5 changes: 5 additions & 0 deletions src/label.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import numpy as np

from os.path import isfile


class Label:

Expand Down Expand Up @@ -54,6 +56,9 @@ def set_prob(self,prob):

def lread(file_path,label_type=Label):

if not isfile(file_path):
return []

objs = []
with open(file_path,'r') as fd:
for line in fd:
Expand Down

0 comments on commit 91328a2

Please sign in to comment.