Added all remaining gists.
This commit is contained in:
1
colorbarcode1.py/README.md
Normal file
1
colorbarcode1.py/README.md
Normal file
@@ -0,0 +1 @@
|
||||
A naive movie color barcode generator.
|
40
colorbarcode1.py/colorbarcode1.py
Normal file
40
colorbarcode1.py/colorbarcode1.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import os
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
def colorbarcode( path ):
|
||||
if not os.access( path, os.R_OK ):
|
||||
raise Exception( "File " + path + " does not exists or is not readable." )
|
||||
|
||||
video = cv2.VideoCapture( path )
|
||||
|
||||
if not video.isOpened():
|
||||
raise Exception( "File " + path + " is not a valid video file." )
|
||||
|
||||
barcode = []
|
||||
|
||||
ret = True
|
||||
i = 1
|
||||
while ret:
|
||||
ret, frame = video.read()
|
||||
|
||||
if frame is None:
|
||||
break
|
||||
|
||||
col = cv2.resize( frame, ( 1, 480 ), fx = 0, fy = 0, interpolation = cv2.INTER_AREA )
|
||||
barcode.append( col )
|
||||
|
||||
if i % 100 == 0:
|
||||
print "Processed %d frames " % i
|
||||
i += 1
|
||||
|
||||
print "Processed %d frames " % i
|
||||
|
||||
out = np.zeros( ( 480, 0, 3), dtype = barcode[ 0 ].dtype )
|
||||
|
||||
for i in xrange( len( barcode ) ):
|
||||
out = np.hstack( ( out, barcode[ i ] ) )
|
||||
|
||||
cv2.imwrite( "barcode.png", out )
|
||||
|
||||
video.release()
|
Reference in New Issue
Block a user