Skip to content

Commit

Permalink
Merge pull request #91 from boostcampaitech3/jj/feat
Browse files Browse the repository at this point in the history
[feat] 기존에 사용하던 Yolo Annotation Tool에 현재 선택된 bbox를 잘 구분할 수 있는 기능 구현 #90
  • Loading branch information
updaun authored Oct 4, 2022
2 parents 1df2795 + 83e82c6 commit 9664046
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions blood_detection/yolov5/custom_dataset/yolo_annotation_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def __init__(self, master):
self.STATE['x'], self.STATE['y'] = 0, 0

# reference to bbox
self.bboxIdList = []
self.bboxIdList = [] # rectangle(bbox) object
self.bboxId = None
self.bboxList = []
self.bboxList = [] # bbox coordinates
self.bboxListCls = []
self.hl = None
self.vl = None
Expand Down Expand Up @@ -123,6 +123,11 @@ def __init__(self, master):
self.lb1.grid(row = 2, column = 2, sticky = W+N,columnspan=2)
self.listbox = Listbox(self.frame, width = 30, height = 12)
self.listbox.grid(row = 3, column = 2, sticky = N,columnspan=2)

# 선택된 bbox 표시하는 기능 추가
self.listbox.bind("<space>", self.selBbox) # Bounding boxes의 요소를 클릭한 상태로 spacebar를 누르면 bbox가 magenta로 색상 변경.
self.listbox.bind("<KeyRelease-space>", self.deselBbox) # speacebar를 떼면 bbox가 원래 색상으로 변경.

self.btnDel = Button(self.frame, text = 'Delete', command = self.delBBox)
self.btnDel.grid(row = 4, column = 2, sticky = W+E+N,columnspan=2)
self.btnClear = Button(self.frame, text = 'ClearAll', command = self.clearBBox)
Expand Down Expand Up @@ -323,6 +328,24 @@ def clearBBox(self):
self.bboxList = []
self.bboxListCls = []

def selBbox(self, event):
sel = self.listbox.curselection()

if len(sel) != 1:
return

idx = int(sel[0])
self.mainPanel.itemconfig(self.bboxIdList[idx], outline='magenta')

def deselBbox(self, event):
sel = self.listbox.curselection()

if len(sel) != 1:
return

idx = int(sel[0])
self.mainPanel.itemconfig(self.bboxIdList[idx], outline=COLORS[int(self.bboxListCls[idx])])

def prevImage(self, event = None):
self.saveImage()
if self.cur > 1:
Expand Down

0 comments on commit 9664046

Please sign in to comment.