我在Python3中使用Python3。
我正在为新闻视频编写“镜头边界检测”程序。
刚开始的时候,我只需要把一个视频帧分割成9个片段。但是,我不知道该怎么做,因为我是这个领域的新手。我是用剪裁做的,但在我看来,把一个框架分割成几块是不对的。
注意:当我用“我的标题”搜索时,我无法到达ROI的答案。但现在看来这是ROI。
发布于 2017-05-05 16:03:21
例如,您需要使用ROI并在数组中添加不同的图像。
我用我的猫测试:

这里有代码:(按'q‘键完成它)
import cv2
cap = cv2.VideoCapture(0)
n_rows = 3
n_images_per_row = 3
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
height, width, ch = frame.shape
roi_height = height / n_rows
roi_width = 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(x*n_images_per_row+y+1), 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
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()https://stackoverflow.com/questions/43808353
复制相似问题