Thickness param in cv2.drawContours

Hello everybody, I have a question about the thickness param in cv2.drawContours, is it the number of the pixels took from the abject to draw the boundary ? I searched a lot in the documentation and couldn’t find a relevant information about it.

You could try to draw it and see what you get.

import cv2
import numpy as np

img = np.zeros((10, 10, 3))

points = np.asarray([[(2,2),(7,2),(7,7),(2,7)]])

img = cv2.drawContours(img, points, 0, (0,255,0), 2) # green
img = cv2.drawContours(img, points, 0, (0,0,255), 1) # red

cv2.imshow('image', img)


For single pixel thickness it should be inside object (see red line on image)
but for bigger thickness it should be partially inside and partially outside (see green line on image)

Zrzut ekranu z 2021-06-04 21-40-45

1 Like

Thank you very much for your answer. That’s nice