Skip to content

Instantly share code, notes, and snippets.

@begnini
Last active June 30, 2019 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save begnini/0194ba7f26e23a8c18d37f6188062922 to your computer and use it in GitHub Desktop.
Save begnini/0194ba7f26e23a8c18d37f6188062922 to your computer and use it in GitHub Desktop.
ROI nao retangulo
import cv2
import numpy as np
image = cv2.imread('QWO9Y.jpg')
mask = np.zeros(image.shape, dtype=np.uint8)
# pontos do poligono
pts = [
[150, 124],
[327, 135],
[340, 181],
[582, 274],
[510, 344],
[168, 240]
]
pts = np.array(pts, np.int32)
pts = pts.reshape((-1,1,2))
mask = cv2.fillPoly(mask, [pts], (255, 255, 255))
masked = cv2.bitwise_and(image, mask)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment