in machine-learning-notebooks/camera.py [0:0]
def configure_preview(self, resolution=None, encode=None, bitrate=None, framerate=None, display_out=None):
"""
This method is for setting preview params.
Parameters
----------
resolution : str
A value from resolutions attribute
encode : str
A value from encodetype attribute
bitrate : str
A value from bitrates attribute
framerate : int
A value from framerates attribute
display_out : {0, 1}
For enabling or disabling HDMI output
Returns
-------
bool
True if the request is successful. False on failure.
"""
if resolution and self.resolutions and resolution in self.resolutions:
res = self.resolutions.index(resolution)
else:
res = 1 # 1080P
if encode and self.encodetype and encode in self.encodetype:
enc = self.encodetype.index(encode)
else:
enc = 0 # HEVC
if bitrate and self.bitrates and bitrate in self.bitrates:
bit = self.bitrates.index(bitrate)
else:
bit = 6 # 4Mbps
if framerate and self.framerates and framerate in self.framerates:
fps = self.framerates.index(framerate)
else:
fps = 1 # 30
if display_out > 1 and display_out < 0:
print("Invalid value: display_out should 0/1, using default 0")
display_out = 0
path = "/video"
payload = {
"resolutionSelectVal": res,
"encodeModeSelectVal": enc,
"bitRateSelectVal": bit,
"fpsSelectVal": fps,
"displayOut": display_out
}
response = self.connection.post(path, payload)
return response["status"]