Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed Sep 7, 2024
1 parent 4cd0291 commit fcae74b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
29 changes: 20 additions & 9 deletions backend/src/NPMean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ class NPMeanSequential:
def __init__(self):
self.i0 = None
self.i1 = None
def forward(self, img1): #forward method calculates out mean of new img, and saves current img as old
def sceneDetect(self, img1):
if self.i0 is None:
self.i0 = img1
self.image0mean = np.mean(self.i0)
return
self.i1 = img1
self.img1mean = np.mean(self.i1)

def isSceneChange(self):
if self.image0mean > self.img1mean + 20 or self.image0mean < self.img1mean - 20:
self.image0mean = self.img1mean
img1mean = np.mean(self.i1)
if self.image0mean > img1mean + 20 or self.image0mean < img1mean - 20:
self.image0mean = img1mean
return True
self.image0mean = self.img1mean
self.image0mean = img1mean
return False

def isMeanEqual(self):
return self.image0mean == self.img1mean
def isEqualImages(self,img1):
if self.i0 is None:
self.i0 = img1
self.image0mean = np.mean(self.i0)
return
self.i1 = img1
img1mean = np.mean(self.i1)
if (self.i0==self.i1).all():
self.image0mean = img1mean
self.i0 = self.i1
return True
self.i0 = self.i1
self.image0mean = img1mean
return False

3 changes: 1 addition & 2 deletions backend/src/SceneDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def getMeanTransitions(self):
detector = NPMeanSequential()
for frame_num in tqdm(range(self.totalInputFrames - 1)):
frame = bytesTo100x100img(self.readQueue.get())
detector.forward(frame)
if detector.isSceneChange():
if detector.sceneDetect(frame):
sceneChangeQueue.put(frame_num-1)
return sceneChangeQueue

Expand Down

0 comments on commit fcae74b

Please sign in to comment.