Skip to content

Commit

Permalink
fix motion detector
Browse files Browse the repository at this point in the history
  • Loading branch information
sr99622 committed Jul 1, 2024
1 parent 8d0a495 commit 6891758
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion onvif-gui/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import shutil
import avio

VERSION = "2.1.0"
VERSION = "2.1.1"

class PipeManager():
def __init__(self, mw, uri):
Expand Down
12 changes: 5 additions & 7 deletions onvif-gui/modules/video/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ def __init__(self, mw, camera=None):
self.id = camera.serial_number()
self.show = False
self.gain = self.getModelOutputGain()
self.limit = 0

def getModelOutputGain(self):
key = f'{self.id}/{MODULE_NAME}/ModelAlarmLimit'
key = f'{self.id}/{MODULE_NAME}/MotionGain'
return int(self.mw.settings.value(key, 50))

def setModelOutputGain(self, value):
key = f'{self.id}/{MODULE_NAME}/ModelAlarmLimit'
key = f'{self.id}/{MODULE_NAME}/MotionGain'
self.gain = value
self.mw.settings.setValue(key, value)

Expand Down Expand Up @@ -108,7 +107,7 @@ def setCamera(self, camera):
if not self.isModelSettings(camera.videoModelSettings):
camera.videoModelSettings = MotionSettings(self.mw, camera)
self.mw.videoPanel.lblCamera.setText(f'Camera - {camera.name()}')
self.sldGain.setValue(camera.videoModelSettings.limit)
self.sldGain.setValue(camera.videoModelSettings.gain)
self.barLevel.setLevel(0)
self.indAlarm.setState(0)
profile = self.mw.cameraPanel.getProfile(camera.uri())
Expand All @@ -122,7 +121,7 @@ def setFile(self, file):
if not self.isModelSettings(self.mw.filePanel.videoModelSettings):
self.mw.filePanel.videoModelSettings = MotionSettings(self.mw)
self.mw.videoPanel.lblCamera.setText(f'File - {os.path.split(file)[1]}')
self.sldGain.setValue(self.mw.filePanel.videoModelSettings.limit)
self.sldGain.setValue(self.mw.filePanel.videoModelSettings.gain)
self.barLevel.setLevel(0)
self.indAlarm.setState(0)
self.enableControls(self.mw.videoPanel.chkEnableFile.isChecked())
Expand All @@ -140,7 +139,6 @@ def __init__(self, mw):
self.last_ex = ""
self.last_img = None
self.first_pass = True
self.gain = 1.0
self.kernel = np.array((9, 9), dtype=np.uint8)
self.last_alarm_state = False

Expand Down Expand Up @@ -183,7 +181,7 @@ def __call__(self, F, player):
diff = cv2.morphologyEx(diff, cv2.MORPH_CLOSE, self.kernel, iterations=1)

motion = diff.sum() / (diff.shape[0] * diff.shape[1])
level = math.exp(0.2 * (player.videoModelSettings.limit - 50)) * motion
level = math.exp(0.2 * (player.videoModelSettings.gain - 50)) * motion

player.last_image = img

Expand Down
2 changes: 1 addition & 1 deletion onvif-gui/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

[project]
name = "onvif-gui"
version = "2.1.0"
version = "2.1.1"
dynamic = ["gui-scripts"]
description = "A client gui for Onvif"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion onvif-gui/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name="onvif-gui",
version="2.1.0",
version="2.1.1",
author="Stephen Rhodes",
author_email="sr99622@gmail.com",
description="GUI program for onvif",
Expand Down

0 comments on commit 6891758

Please sign in to comment.