alanlukezic / d3s

D3S - Discriminative Single Shot Segmentation Tracker (CVPR 2020)
265 stars 56 forks source link

How to visualize the mask you generate,like the picture in your paper?And question about got10k #8

Closed sherlockedlee closed 4 years ago

sherlockedlee commented 4 years ago

Thanks for your brilliant work.I wonder how to draw picture like this in your paper,can you give me some advise? Thank you very much. 111 And also, can you give the parameter you use to test on got-10k? The result I get is inferior to yours.

alanlukezic commented 4 years ago

Mask can be drawn on image using the following code (m is a binary uint8 numpy array, img is a 3-channel BGR image, alpha is a parameter (0-1) controlling degree of a mask transparency and color is a 3-element array denoting a BGR mask color):

img_r = img[:, :, 2] img_g = img[:, :, 1] img_b = img[:, :, 0] img_r[m > 0] = (1 - alpha) img_r[m > 0] + alpha color[2] img_g[m > 0] = (1 - alpha) img_g[m > 0] + alpha color[1] img_b[m > 0] = (1 - alpha) img_b[m > 0] + alpha color[0]

draw contour around mask

M = (m > 0).astype(np.uint8) if cv2.version[-5] == '4': contours, _ = cv2.findContours(M, cv2.RETR_LIST, cv2.CHAIN_APPROXNONE) else: , contours, _ = cv2.findContours(M, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) cv2.drawContours(img, contours, -1, color, line_width)

sherlockedlee commented 4 years ago

Mask can be drawn on image using the following code (m is a binary uint8 numpy array, img is a 3-channel BGR image, alpha is a parameter (0-1) controlling degree of a mask transparency and color is a 3-element array denoting a BGR mask color):

img_r = img[:, :, 2] img_g = img[:, :, 1] img_b = img[:, :, 0] img_r[m > 0] = (1 - alpha) img_r[m > 0] + alpha color[2] img_g[m > 0] = (1 - alpha) img_g[m > 0] + alpha color[1] img_b[m > 0] = (1 - alpha) img_b[m > 0] + alpha color[0]

draw contour around mask

M = (m > 0).astype(np.uint8) if cv2.version[-5] == '4': contours, _ = cv2.findContours(M, cv2.RETR_LIST, cv2.CHAIN_APPROXNONE) else: , contours, _ = cv2.findContours(M, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) cv2.drawContours(img, contours, -1, color, line_width)

Thank you very much for your patience! And do you use the same parameter in segm_default.py to test on got10k? Mine is inferior to yours. @alanlukezic

alanlukezic commented 4 years ago

Yes, the parameters are the same for experiments on all datasets. We have found out that there might be some differences in performance according to the hardware and library versions.

sherlockedlee commented 4 years ago

Yes, the parameters are the same for experiments on all datasets. We have found out that there might be some differences in performance according to the hardware and library versions.

Thanks alot.