OpenCV Crop Frame and Save

OpenCV Crop Frame and Save

1
2
3
count = 0
cv2.imwrite("frame%d.jpg" % count, frame)
count = count+1
1
2
3
4
5
6
import cv2
img = cv2.imread("lenna.png")
crop_img = img[200:400, 100:300] # Crop from x, y, w, h -> 100, 200, 300, 400
# NOTE: its img[y: y + h, x: x + w] and *not* img[x: x + w, y: y + h]
cv2.imshow("cropped", crop_img)
cv2.waitKey(0)

출처

공유하기