如何分别保存穿孔的框架零件

时间:2019-10-04 07:02:40

标签: python video-processing

我在这里找到了以下代码,并希望分别保存每个代码。

import cv2
cap = cv2.VideoCapture(yourVideoFile)
n_rows = 2
n_images_per_row = 2
while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    height, width, ch = frame.shape
    roi_height = int(height / n_rows)
    roi_width = int(width / n_images_per_row)
    images = []
    for x in range(0, n_rows):
        for y in range(0,n_images_per_row):
            tmp_image=frame[x*roi_height:(x+1)*roi_height, y*roi_width:(y+1)*roi_width]
            images.append(tmp_image)
    # Display the resulting sub-frame
    for x in range(0, n_rows):
        for y in range(0, n_images_per_row):
            cv2.imshow(str(1+y+x*n_images_per_row), images[x*n_images_per_row+y])
    cv2.moveWindow(str(x * n_images_per_row + y + 1), 100 + (y * roi_width), 50 + (x * roi_height))
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
return_value,image = cap.read()# İlk fotğrafı al
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

我该怎么做?Result Screen for 4 pieces of the video file

0 个答案:

没有答案