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 8afa5c9a authored by Hachemin Pierre-Yves's avatar Hachemin Pierre-Yves

new Extract_spectrum

parent 712903ac
...@@ -17,11 +17,11 @@ import moviepy.editor as mp ...@@ -17,11 +17,11 @@ import moviepy.editor as mp
follow = True follow = True
queue = Queue() queue = Queue()
linkFile = './link-dictionnaries/link-dictionnary20062.txt' # Input dict of trailers linkFile = './link-dictionaries/link-dictionary20082.txt' # Input dict of trailers
linkDict = {} linkDict = {}
exceptDict = {} exceptDict = {}
videoDir = './video/' # Folder to store temporarely the videos videoDir = './video/' # Folder to store temporarely the videos
spectrumDir = '../spectrumImages/spectrumImages2006/' # Output folder to store the spectrums spectrumDir = '../spectrumImages/spectrumImages2008/' # Output folder to store the spectrums
countDownload = 1 countDownload = 1
countSpectrum = 1 countSpectrum = 1
...@@ -122,14 +122,18 @@ def tableSpectrum(video): #called by imgSpectrum() ...@@ -122,14 +122,18 @@ def tableSpectrum(video): #called by imgSpectrum()
"""Find if the trailer is in 4:3 or 21:9 --> borders to crop""" """Find if the trailer is in 4:3 or 21:9 --> borders to crop"""
success, image = vidcrop.read() success, image = vidcrop.read()
cropdim = (0, image.shape[0], 0, image.shape[1])
countcrop=0 countcrop=0
while success and countcrop<240: while success and countcrop<240:
success,image=vidcrop.read() success,image=vidcrop.read()
countcrop+=1 countcrop+=1
if success==True:
cropdim=crop_image_dim(image,0) try:
print("image size : {}".format(image.shape)) cropdim=crop_image_dim(image,0)
print("cropped dim : {}".format(cropdim)) 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""" """Read every images of the trailer and out the mean color of each"""
vidcap = cv2.VideoCapture(video) vidcap = cv2.VideoCapture(video)
...@@ -186,7 +190,10 @@ def meanImage(img,cropdim): #called by tableSpectrum() ...@@ -186,7 +190,10 @@ def meanImage(img,cropdim): #called by tableSpectrum()
for i in range(cropdim[0],cropdim[1]): for i in range(cropdim[0],cropdim[1]):
for j in range(cropdim[2],cropdim[3]): for j in range(cropdim[2],cropdim[3]):
res0 = res0 + lab[i][j] res0 = res0 + lab[i][j]
res0 = res0 / ((cropdim[1]-cropdim[0]+1)*(cropdim[3]-cropdim[2]+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[0] = int(res0[0])
res[1] = int(res0[1]) res[1] = int(res0[1])
res[2] = int(res0[2]) res[2] = int(res0[2])
......
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