#!/usr/bin/env python # ./sscan.py input.mov rownumber output.png # This is meant to be hyper-simple and makes # some assumptions like: you want a row (not # a column), the video is RGB (not gray), etc. # Bug: frame_count is sometimes fractional. # int() and the "if not okay" are workarounds. import numpy as np import cv2 from sys import argv movf, row, outf = argv[1:] row = int(row) slice_width=12 viddy = cv2.VideoCapture(movf) width = int(viddy.get(3)) # can you tell this API is by C programmers? height = int(viddy.get(4)) frame_count = int(viddy.get(7)) print width, height, frame_count rows = np.empty((height, frame_count*slice_width, 3)) # 3 channels for frame_n in range(frame_count): print("%s/%s" % (frame_n, frame_count)) # or not okay, frame = viddy.read() if not okay: break for i in range(0, slice_width): rows[:,(slice_width*frame_n)+i] = frame[:,row+i] cv2.imwrite(outf, rows)