ITS: clean up gpylint errors in utils files
bug: 229024916
Change-Id: I60e0c9c1e33c4b7b21b3109f18808bdc3d1a4c75
diff --git a/apps/CameraITS/utils/camera_properties_utils.py b/apps/CameraITS/utils/camera_properties_utils.py
index 966eac7..261c03e 100644
--- a/apps/CameraITS/utils/camera_properties_utils.py
+++ b/apps/CameraITS/utils/camera_properties_utils.py
@@ -582,6 +582,7 @@
return 'android.request.availableCapabilities' in props and 4 in props[
'android.request.availableCapabilities']
+
def stream_use_case(props):
"""Returns whether a device has stream use case capability.
@@ -594,6 +595,7 @@
return 'android.request.availableCapabilities' in props and 19 in props[
'android.request.availableCapabilities']
+
def intrinsic_calibration(props):
"""Returns whether a device supports android.lens.intrinsicCalibration.
@@ -750,7 +752,8 @@
Boolean. True if android.control.postRawSensitivityBoost is supported.
"""
return (
- 'android.control.postRawSensitivityBoostRange' in props['camera.characteristics.keys'] and
+ 'android.control.postRawSensitivityBoostRange' in
+ props['camera.characteristics.keys'] and
props.get('android.control.postRawSensitivityBoostRange') != [100, 100])
@@ -848,8 +851,8 @@
CONTRAST_CURVE (0) or GAMMA_VALUE (3).
"""
return ('android.tonemap.availableToneMapModes' in props and
- (0 in props.get('android.tonemap.availableToneMapModes') or
- 3 in props.get('android.tonemap.availableToneMapModes')))
+ (0 in props.get('android.tonemap.availableToneMapModes') or
+ 3 in props.get('android.tonemap.availableToneMapModes')))
if __name__ == '__main__':
diff --git a/apps/CameraITS/utils/its_session_utils.py b/apps/CameraITS/utils/its_session_utils.py
index 8988af0..722f586 100644
--- a/apps/CameraITS/utils/its_session_utils.py
+++ b/apps/CameraITS/utils/its_session_utils.py
@@ -196,8 +196,8 @@
"""
if check_port not in used_ports:
# Try to run "adb forward" with the port
- command = '%s forward tcp:%d tcp:%d' % \
- (self.adb, check_port, self.REMOTE_PORT)
+ command = ('%s forward tcp:%d tcp:%d' %
+ (self.adb, check_port, self.REMOTE_PORT))
proc = subprocess.Popen(
command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
error = proc.communicate()[1]
@@ -519,9 +519,9 @@
self.sock.settimeout(timeout)
data, _ = self.__read_response_from_socket()
if data['tag'] != 'recordingResponse':
- raise error_util.CameraItsError(
- f'Invalid response for command: {cmd[cmdName]}')
- logging.debug('VideoRecordingObject: %s' % data)
+ raise error_util.CameraItsError(
+ f'Invalid response for command: {cmd["cmdName"]}')
+ logging.debug('VideoRecordingObject: %s', data)
return data['objValue']
def do_preview_recording(self, video_size, duration, stabilize):
@@ -538,8 +538,8 @@
stabilize: boolean; Whether the preview should be stabilized or not
Returns:
video_recorded_object: The recorded object returned from ItsService which
- contains path at which the recording is saved on the device, quality of the
- recorded video which is always set to "preview", video size of the
+ contains path at which the recording is saved on the device, quality of
+ the recorded video which is always set to "preview", video size of the
recorded video, video frame rate.
Ex:
VideoRecordingObject: {
@@ -565,18 +565,22 @@
self.sock.settimeout(timeout)
data, _ = self.__read_response_from_socket()
- logging.debug(f'VideoRecordingObject: {data}')
+ logging.debug('VideoRecordingObject: %s', str(data))
if data['tag'] != 'recordingResponse':
- raise error_util.CameraItsError(f'Invalid response from command{cmd["cmdName"]}')
+ raise error_util.CameraItsError(
+ f'Invalid response from command{cmd["cmdName"]}')
return data['objValue']
def get_supported_video_qualities(self, camera_id):
"""Get all supported video qualities for this camera device.
- Args:
- camera_id: device id
- Returns:
- List of all supported video qualities and corresponding profileIds.
- Ex: ['480:4', '1080:6', '2160:8', '720:5', 'CIF:3', 'HIGH:1', 'LOW:0', 'QCIF:2', 'QVGA:7']
+
+ ie. ['480:4', '1080:6', '2160:8', '720:5', 'CIF:3', 'HIGH:1', 'LOW:0',
+ 'QCIF:2', 'QVGA:7']
+
+ Args:
+ camera_id: device id
+ Returns:
+ List of all supported video qualities and corresponding profileIds.
"""
cmd = {}
cmd['cmdName'] = 'getSupportedVideoQualities'
@@ -585,16 +589,17 @@
data, _ = self.__read_response_from_socket()
if data['tag'] != 'supportedVideoQualities':
raise error_util.CameraItsError('Invalid command response')
- return data['strValue'].split(';')[:-1] # remove the last appended ';'
+ return data['strValue'].split(';')[:-1] # remove the last appended ';'
def get_supported_preview_sizes(self, camera_id):
"""Get all supported preview resolutions for this camera device.
- Args:
- camera_id: int; device id
- Returns:
- List of all supported video resolutions in ascending order.
- Ex: ['640x480', '800x600', '1280x720', '1440x1080', '1920x1080']
+ ie. ['640x480', '800x600', '1280x720', '1440x1080', '1920x1080']
+
+ Args:
+ camera_id: int; device id
+ Returns:
+ List of all supported video resolutions in ascending order.
"""
cmd = {
'cmdName': 'getSupportedPreviewSizes',
diff --git a/apps/CameraITS/utils/sensor_fusion_utils.py b/apps/CameraITS/utils/sensor_fusion_utils.py
index 5085144..19bd48b 100644
--- a/apps/CameraITS/utils/sensor_fusion_utils.py
+++ b/apps/CameraITS/utils/sensor_fusion_utils.py
@@ -648,11 +648,13 @@
file_name = os.path.join(log_path, plot_name)
matplotlib.pyplot.savefig(f'{file_name}_gyro_events.png')
+
def conv_acceleration_to_movement(gyro_events, video_delay_time):
"""Convert gyro_events time and speed to movement during video time.
Args:
gyro_events: sorted dict of entries with 'time', 'x', 'y', and 'z'
+ video_delay_time: time at which video starts
Returns:
'z' acceleration converted to movement for times around VIDEO playing.
diff --git a/apps/CameraITS/utils/video_processing_utils.py b/apps/CameraITS/utils/video_processing_utils.py
index b0fef2c..894729c 100644
--- a/apps/CameraITS/utils/video_processing_utils.py
+++ b/apps/CameraITS/utils/video_processing_utils.py
@@ -19,7 +19,6 @@
import logging
import os.path
import subprocess
-import time
ITS_SUPPORTED_QUALITIES = (
@@ -37,8 +36,7 @@
def extract_key_frames_from_video(log_path, video_file_name):
- """
- Returns a list of extracted key frames.
+ """Returns a list of extracted key frames.
Ffmpeg tool is used to extract key frames from the video at path
os.path.join(log_path, video_file_name).
@@ -51,26 +49,26 @@
Args:
log_path: path for video file directory
video_file_name: name of the video file.
- Ex: VID_20220325_050918_0_CIF_352x288.mp4
Returns:
key_frame_files: A list of paths for each key frame extracted from the
- video.
+ video. Ex: VID_20220325_050918_0_CIF_352x288.mp4
"""
ffmpeg_image_name = f"{video_file_name.split('.')[0]}_key_frame"
- ffmpeg_image_file_path = os.path.join(log_path, ffmpeg_image_name + '_%02d.png')
+ ffmpeg_image_file_path = os.path.join(
+ log_path, ffmpeg_image_name + '_%02d.png')
cmd = ['ffmpeg',
- '-skip_frame',
- 'nokey',
- '-i',
- os.path.join(log_path, video_file_name),
- '-vsync',
- 'vfr',
- '-frame_pts',
- 'true' ,
- ffmpeg_image_file_path,
- ]
- logging.debug('Extracting key frames from: %s' % video_file_name)
- output = subprocess.call(cmd)
+ '-skip_frame',
+ 'nokey',
+ '-i',
+ os.path.join(log_path, video_file_name),
+ '-vsync',
+ 'vfr',
+ '-frame_pts',
+ 'true',
+ ffmpeg_image_file_path,
+ ]
+ logging.debug('Extracting key frames from: %s', video_file_name)
+ _ = subprocess.call(cmd)
arr = os.listdir(os.path.join(log_path))
key_frame_files = []
for file in arr:
@@ -80,8 +78,7 @@
def get_key_frame_to_process(key_frame_files):
- """
- Returns the key frame file from the list of key_frame_files.
+ """Returns the key frame file from the list of key_frame_files.
If the size of the list is 1 then the file in the list will be returned else
the file with highest frame_index will be returned for further processing.
@@ -96,8 +93,7 @@
def extract_all_frames_from_video(log_path, video_file_name, img_format):
- """
- Extracts and returns a list of all extracted frames.
+ """Extracts and returns a list of all extracted frames.
Ffmpeg tool is used to extract all frames from the video at path
<log_path>/<video_file_name>. The extracted key frames will have the name