Update Barcode_Generator.py
This commit is contained in:
parent
fceea38b33
commit
2490642701
|
|
@ -2,9 +2,10 @@ import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
movie = cv2.VideoCapture("movie.mp4") # VideoCapture take as argument any video files, image sequences or cameras
|
movie = cv2.VideoCapture("movie.mp4") # VideoCapture take as argument any video files, image sequences or cameras.
|
||||||
|
|
||||||
|
|
||||||
|
# Returns the vectorized mean of the argument (an image).
|
||||||
def frame_avg(img):
|
def frame_avg(img):
|
||||||
scaled = img.astype('uint32')
|
scaled = img.astype('uint32')
|
||||||
squared = scaled**2
|
squared = scaled**2
|
||||||
|
|
@ -12,13 +13,14 @@ def frame_avg(img):
|
||||||
return np.sqrt(avgsq).astype('uint8')
|
return np.sqrt(avgsq).astype('uint8')
|
||||||
|
|
||||||
|
|
||||||
|
# Returns a multi-dimensional array (ndarray) cointaining a column for every frame taken from the argument (image sequence).
|
||||||
def collect_frames(movie):
|
def collect_frames(movie):
|
||||||
res = []
|
res = []
|
||||||
s, i = movie.read()
|
s, i = movie.read()
|
||||||
while s:
|
while s:
|
||||||
res.append(frame_avg(i))
|
res.append(frame_avg(i))
|
||||||
s, i = movie.read()
|
s, i = movie.read()
|
||||||
for i in range(30):
|
for i in range(30): # The argument of range() is the number of skipped frames for every iteration.
|
||||||
if s:
|
if s:
|
||||||
s, i = movie.read()
|
s, i = movie.read()
|
||||||
return res
|
return res
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue