-
-
Save blech/add7a12ef4b0b72e3d2e3485c9e6aa64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment