forked from tanveer-hussain/Video-Summarization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Postprocessing2.py
60 lines (49 loc) · 1.69 KB
/
Postprocessing2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 6 00:49:54 2018
@author: Tanveer
"""
import glob
import cv2
import numpy as np
import time
start_t=time.time()
root_dir = 'Keyframes/'
pth = root_dir + "*.png"
tt = glob.glob(pth)
print(len(tt))
#for i in range(1,len(tt)):
# query_img = cv2.imread(tt[i])
# image_name = tt[i].split('\\')
# for j in range(i+1,len(tt)):
# compare_img = cv2.imread(tt[j])
# (score,diff) = compare_ssim(query_img,compare_img,full=True,multichannel=True)
# #print ("Score = " , score)
# pathh = 'Keyframes\\v11\\VS11\\',image_name[2]
# print (pathh)
# if score > 0.7: #means SSIM
# cv2.imwrite(pathh, query_img)
count = 0
for i in range(1,len(tt)):
query_img = cv2.imread(tt[i])
image_name = tt[i].split('/')
# query_histt = cv2.calcHist([query_img],[0],None,[255],[0,256])
for j in range(i+1,len(tt)):
compare_img = cv2.imread(tt[j])
# compare_histt = cv2.calcHist([compare_img],[0],None,[255],[0,256])
# distt = cv2.compareHist(query_histt,compare_histt,0)
# print (" distance = " , distt)
difference = np.sum((query_img.astype("float") - compare_img.astype("float")) ** 2)
difference /= float(query_img.shape[0] * compare_img.shape[1])
#print ("Score = " , score)
pathh = root_dir + 'kf/' + image_name[1]
# print (pathh)
if difference < 2000:
print ("Writing Image ", pathh)
cv2.imwrite(pathh, query_img)
# print ("Different images",count)
count = count + 1
break
end_t=time.time()
total_t=end_t-start_t
print ("Time consumed ", total_t)