Refactor image settings from recording to new mixin

This commit is contained in:
Karl Moos
2020-10-30 06:06:25 -05:00
parent dd86eaca2e
commit e1eabf535d
4 changed files with 70 additions and 64 deletions

View File

@@ -7,6 +7,7 @@ from .system import SystemAPIMixin
from .user import UserAPIMixin from .user import UserAPIMixin
from .ptz import PtzAPIMixin from .ptz import PtzAPIMixin
from .alarm import AlarmAPIMixin from .alarm import AlarmAPIMixin
from .image import ImageAPIMixin
from resthandle import Request from resthandle import Request
@@ -18,7 +19,8 @@ class APIHandler(SystemAPIMixin,
RecordingAPIMixin, RecordingAPIMixin,
ZoomAPIMixin, ZoomAPIMixin,
PtzAPIMixin, PtzAPIMixin,
AlarmAPIMixin): AlarmAPIMixin,
ImageAPIMixin):
""" """
The APIHandler class is the backend part of the API, the actual API calls The APIHandler class is the backend part of the API, the actual API calls
are implemented in Mixins. are implemented in Mixins.

65
api/image.py Normal file
View File

@@ -0,0 +1,65 @@
class ImageAPIMixin:
"""API calls for image settings."""
def set_advanced_imaging(self,
anti_flicker='Outdoor',
exposure='Auto',
gain_min=1,
gain_max=62,
shutter_min=1,
shutter_max=125,
blue_gain=128,
red_gain=128,
white_balance='Auto',
day_night='Auto',
back_light='DynamicRangeControl',
blc=128,
drc=128,
rotation=0,
mirroring=0,
nr3d=1) -> object:
"""
Sets the advanced camera settings.
:param anti_flicker: string
:param exposure: string
:param gain_min: int
:param gain_max: string
:param shutter_min: int
:param shutter_max: int
:param blue_gain: int
:param red_gain: int
:param white_balance: string
:param day_night: string
:param back_light: string
:param blc: int
:param drc: int
:param rotation: int
:param mirroring: int
:param nr3d: int
:return: response
"""
body = [{
"cmd": "SetIsp",
"action": 0,
"param": {
"Isp": {
"channel": 0,
"antiFlicker": anti_flicker,
"exposure": exposure,
"gain": {"min": gain_min, "max": gain_max},
"shutter": {"min": shutter_min, "max": shutter_max},
"blueGain": blue_gain,
"redGain": red_gain,
"whiteBalance": white_balance,
"dayNight": day_night,
"backLight": back_light,
"blc": blc,
"drc": drc,
"rotation": rotation,
"mirroring": mirroring,
"nr3d": nr3d
}
}
}]
return self._execute_command('SetIsp', body)

View File

@@ -69,68 +69,6 @@ class RecordingAPIMixin:
}}] }}]
return self._execute_command('SetEnc', body) return self._execute_command('SetEnc', body)
def set_advanced_imaging(self,
anti_flicker='Outdoor',
exposure='Auto',
gain_min=1,
gain_max=62,
shutter_min=1,
shutter_max=125,
blue_gain=128,
red_gain=128,
white_balance='Auto',
day_night='Auto',
back_light='DynamicRangeControl',
blc=128,
drc=128,
rotation=0,
mirroring=0,
nr3d=1) -> object:
"""
Sets the advanced camera settings.
:param anti_flicker: string
:param exposure: string
:param gain_min: int
:param gain_max: string
:param shutter_min: int
:param shutter_max: int
:param blue_gain: int
:param red_gain: int
:param white_balance: string
:param day_night: string
:param back_light: string
:param blc: int
:param drc: int
:param rotation: int
:param mirroring: int
:param nr3d: int
:return: response
"""
body = [{
"cmd": "SetIsp",
"action": 0,
"param": {
"Isp": {
"channel": 0,
"antiFlicker": anti_flicker,
"exposure": exposure,
"gain": {"min": gain_min, "max": gain_max},
"shutter": {"min": shutter_min, "max": shutter_max},
"blueGain": blue_gain,
"redGain": red_gain,
"whiteBalance": white_balance,
"dayNight": day_night,
"backLight": back_light,
"blc": blc,
"drc": drc,
"rotation": rotation,
"mirroring": mirroring,
"nr3d": nr3d
}
}
}]
return self._execute_command('SetIsp', body)
########### ###########
# RTSP Stream # RTSP Stream
########### ###########

View File

@@ -66,6 +66,7 @@ setup(name=NAME,
'api.system', 'api.system',
'api.user', 'api.user',
'api.zoom', 'api.zoom',
'api.alarm' 'api.alarm',
'api.image'
] ]
) )