Skip to content

Commit b555665

Browse files
modifications
1 parent 8a0c688 commit b555665

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.pyc
2+
/static-files/
3+
/virenv/
4+
/env/
5+
/venv/
6+
/media-files/
7+
db.sqlite3
8+
migrations
9+
.vscode/
10+
*.jpg

app/frames/frame0.jpg

-50.8 KB
Loading

app/frames/frame1.jpg

26.7 KB
Loading

app/frames/frame2.jpg

19.9 KB
Loading

app/frames/removed_noise.png

-69 KB
Loading

app/frames/thresh.png

-9.9 KB
Loading

app/views.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from django.http import JsonResponse
33
from .models import Video
44

5+
6+
from skimage.measure import structural_similarity as ssim
7+
import matplotlib.pyplot as plt
58
import cv2
69
import math
710
import numpy as np
@@ -66,8 +69,8 @@ def VidProc(videoPath):
6669
success, image = vidcap.read()
6770
count = 0
6871
while success:
69-
if(count == 300):
70-
break
72+
# if(count == 300):
73+
# break
7174
success, image = vidcap.read()
7275
frameId = vidcap.get(1) # current frame number
7376

@@ -78,7 +81,14 @@ def VidProc(videoPath):
7881

7982
# Write frame in frames folder
8083
cv2.imwrite(src_path+ "frame%d.jpg" % count, image) # save frame as JPEG file
81-
84+
if(count>0):
85+
img1 = cv2.imread(src_path + "frame" + str(count - 1) + ".jpg", 0)
86+
img2 = cv2.imread(src_path + "frame" + str(count) + ".jpg", 0)
87+
SSIM = ssim(img1, img2)
88+
print("ssim: ",count, " ", SSIM )
89+
if(SSIM > .90 ):
90+
print("inside here")
91+
continue
8292
# Convert Frame Into Text
8393
# print ("\n\nImage Into String :", get_string("/home/arjun/Desktop/majorProject/frames/frame{0}.jpg".format(count)))
8494
get_string(src_path + "frame{0}.jpg".format(count))
@@ -98,7 +108,6 @@ def index(request):
98108
def searchView(request):
99109
toSearch = request.GET.get("toSearch")
100110
print (toSearch)
101-
print ("here")
102111
videos = Video.objects.all()
103112
return render(request, "list.html", {
104113
"toSearch": toSearch,
@@ -109,13 +118,18 @@ def searchView(request):
109118
def videoProc(request):
110119
print("here in videoProc")
111120
videos = Video.objects.all()
121+
videosProcessed = 0
112122
for video in videos:
123+
if(video.data != None):
124+
continue
125+
print("Video Title", video.title)
113126
VidProc("/home/arjun/Desktop/majorProjectDjango/ContentBasedVideoExtraction/media-files/" + str(video.videoFile))
114-
print("/home/arjun/Desktop/majorProjectDjango/ContentBasedVideoExtraction/media-files/" + str(video.videoFile))
127+
# print("/home/arjun/Desktop/majorProjectDjango/ContentBasedVideoExtraction/media-files/" + str(video.videoFile))
115128
print("\n\ndictOfWords:\n")
116129
for k, v in dictOfWords.items():
117130
print (k, " => ", v)
118131
video.data = dictOfWords
119132
video.save()
120-
dictOfWords = {}
121-
return JsonResponse({"name": "videoProc"})
133+
dictOfWords.clear()
134+
videosProcessed += 1
135+
return JsonResponse({"videosProcessed": videosProcessed})

0 commit comments

Comments
 (0)