Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit ee0b0a54 authored by Hachemin Pierre-Yves's avatar Hachemin Pierre-Yves

Merge branch 'PY/InputYears' into 'master'

Py/input years

See merge request !21
parents 839450a6 5b60da5c
......@@ -17,11 +17,11 @@ import moviepy.editor as mp
follow = True
queue = Queue()
linkFile = './link-dictionnaries/link-dictionnary20071.txt' # TODO: Input dict of trailers
linkFile = './link-dictionaries/link-dictionary20082.txt' # Input dict of trailers
linkDict = {}
exceptDict = {}
videoDir = './video/' # Folder to store temporarely the videos
spectrumDir = './spectrumImages/spectrumImages2007/' # TODO: Output folder to store the spectrums
videoDir = './video/' # Folder to store temporarely the videos
spectrumDir = '../spectrumImages/spectrumImages2008/' # Output folder to store the spectrums
countDownload = 1
countSpectrum = 1
......@@ -126,18 +126,18 @@ def tableSpectrum(video): # called by imgSpectrum()
"""Find if the trailer is in 4:3 or 21:9 --> borders to crop"""
success, image = vidcrop.read()
countcrop = 0
while success and countcrop < 240:
success, image = vidcrop.read()
countcrop += 1
try:
cropdim = crop_image_dim(image, 0)
except cv2.error:
vidcrop = cv2.VideoCapture(video)
success, image = vidcrop.read()
cropdim = (0, image.shape[0], 0, image.shape[1])
print("image size : {}".format(image.shape))
print("cropped dim : {}".format(cropdim))
cropdim = (0, image.shape[0], 0, image.shape[1])
countcrop=0
while success and countcrop<240:
success,image=vidcrop.read()
countcrop+=1
if success==True:
try:
cropdim=crop_image_dim(image,0)
except cv2.error:
cropdim = (0, image.shape[0], 0, image.shape[1])
print("image size : {}".format(image.shape))
print("cropped dim : {}".format(cropdim))
"""Read every images of the trailer and out the mean color of each"""
vidcap = cv2.VideoCapture(video)
......@@ -195,10 +195,10 @@ def meanImage(img, cropdim): # called by tableSpectrum()
for i in range(cropdim[0], cropdim[1]):
for j in range(cropdim[2], cropdim[3]):
res0 = res0 + lab[i][j]
try:
res0 = res0 / ((cropdim[1] - cropdim[0] + 1) * (cropdim[3] - cropdim[2] + 1))
except TypeError:
res0 = res0 / (lab.shape[0] * lab.shape[1])
sumpix=(cropdim[1]-cropdim[0]+1)*(cropdim[3]-cropdim[2]+1)
res0[0]= res0[0] / sumpix
res0[1]= res0[1] / sumpix
res0[2]= res0[2] / sumpix
res[0] = int(res0[0])
res[1] = int(res0[1])
res[2] = int(res0[2])
......
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment