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

improve

parent ab315492
......@@ -17,11 +17,11 @@ import moviepy.editor as mp
follow = True
queue = Queue()
linkFile = './link-dictionnaries/link-dictionnary2004.txt'
linkFile = './link-dictionnaries/link-dictionnary20062.txt'
linkDict = {}
exceptDict = {}
videoDir = './video/'
spectrumDir = '../../spectrumImages/spectrumImages2004/'
spectrumDir = '../spectrumImages/spectrumImages2006/'
countDownload = 1
countSpectrum = 1
......@@ -115,16 +115,17 @@ def crop_image_dim(img,tol):
leftBorder=j-1
if mask[midV][j-1]!=mask[midV][j] and mask[midV][j]==False:
rightBorder=j
return (upBorder,downBorder, leftBorder, rightBorder)
def meanImage(img,cropdim): # Return the mean LAB array
res0 = [0, 0, 0]
res = [0, 0, 0]
lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
for i in range(cropdim[0], cropdim[1]):
for j in range(cropdim[2], cropdim[3]):
for i in range(lab.shape[0]):
for j in range(lab.shape[1]):
res0 = res0 + lab[i][j]
res0 = res0 / (img.shape[0] * img.shape[1])
res0 = res0 / (lab.shape[0]*lab.shape[1])
res[0] = int(res0[0])
res[1] = int(res0[1])
res[2] = int(res0[2])
......@@ -143,10 +144,12 @@ def tableSpectrum(video):
while success and countcrop<240:
success,image=vidcrop.read()
countcrop+=1
cropdim=crop_image_dim(image,0)
print(image.shape)
cropdim=(0,image.shape[0],0,image.shape[1])
print(cropdim)
vidcap = cv2.VideoCapture(video)
length = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT) / ratioFrame)
width = int(length * 3 / 16)
......@@ -176,11 +179,11 @@ def imgSpectrum(vidPath, spectrumOut):
res2 = tableSpectrum(resizeVideo(vidPath, vidPath))
else:
res2 = tableSpectrum(vidPath)
output = cv2.cvtColor(res2, cv2.COLOR_LAB2BGR)
cv2.imwrite(spectrumOut, res2)
output = cv2.cvtColor(res2, cv2.COLOR_Lab2BGR)
cv2.imwrite(spectrumOut, output)
print()
print("--------------------------------------------------------")
print("Duration : {} s".format(time() - start))
print("Duration for {} : {} s".format(vidPath[:-3],time() - start))
print("--------------------------------------------------------")
......
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