Added all remaining gists.

This commit is contained in:
Miguel Astor
2023-06-21 21:40:51 -04:00
parent 22ff5bfa25
commit b0ca706a25
26 changed files with 892 additions and 0 deletions

View File

@@ -0,0 +1 @@
A naive movie color barcode generator.

View 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()