Skip to content

Commit efbeeea

Browse files
3A (#11)
* RTL Modifications for AE and AWB * Bug Fixing for 3A in RTL * Pylint error fixing * Moved AWB before WB module * Bug Fixing for AWB-3A * RTl Modifications in AE * Made pixel limit calculated through approximations * Restoration of YUV image from 422 and 444 formats * Bug Fixing in restore YUV Function * Bug Fixing for 3A * Rolled Back YUV changes * 3A BUG FIXING * modified automation file according to new position of AWB in isp_pipeline and generated test vector. * Removed Linting Errors. * modified automation file with no linting errors. * Finalized Code for YUV Format Conversion * Removed Linting Errors * resolved linting errors and removed test_func file from util. * Removed AE Redundant Code * Bug Fixing in AE * Removed wbg_gen.py --------- Co-authored-by: Maria_Nadeem-10x <[email protected]>
1 parent 234f3ab commit efbeeea

15 files changed

+863
-667
lines changed

.pylintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[MESSAGES CONTROL]
2-
disable=unsubscriptable-object,E1136, E1137, R,E0401, C3001, E1121
2+
disable=unsubscriptable-object,E1136, E1137, R,E0401, C3001, E1121, W0106
33

44
# E0401: Unable to import 'util.utils' (import-error)
55
# C3001: Lambda expression assigned to a variable.
66
# Define a function using the "def" keyword instead. (unnecessary-lambda-assignment)
77
# E1121: Too many positional arguments for method call (too-many-function-args)
8+
# W0106: Expression not assigned to anything (expression-not-assigned).
-58 KB
Loading

automate_execution.py

+95-65
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,67 @@
11
"""
2+
DESCRIPTION: ...
23
"""
34

45
import os
56
import sys
67
import subprocess
78
from pathlib import Path
89
import shutil
9-
import numpy as np
10+
from datetime import datetime
1011
import yaml
1112
from util import utils
12-
from datetime import datetime
1313

1414
# define module under test, must be the same as defined in the config
15-
# DUT options = ['crop', 'dead_pixel_correction', 'hdr_stitching', 'black_level_correction', 'OECF', 'digital_gain', 'lens_shading_correction',
16-
# 'bayer_noise_reduction', 'white_balance', 'demosaic', 'auto_white_balance', 'color_correction_matrix', 'gamma_correction',
17-
# 'auto_exposure', 'color_space_conversion', 'ldci', 'sharpen', '2d_noise_reduction', 'scale', 'yuv_conversion_format']
15+
# DUT options = ['crop', 'dead_pixel_correction', 'hdr_stitching', 'black_level_correction',
16+
# 'OECF', 'digital_gain', 'lens_shading_correction','bayer_noise_reduction',
17+
# 'auto_white_balance', 'white_balance', 'demosaic', 'color_correction_matrix',
18+
# 'gamma_correction', 'auto_exposure', 'color_space_conversion', 'ldci', 'sharpen',
19+
# '2d_noise_reduction', 'scale', 'yuv_conversion_format']
1820

1921

20-
DUT = ["dead_pixel_correction", "black_level_correction", "digital_gain"]
22+
DUT = ["dead_pixel_correction"]
2123

2224

2325
# Modules:
24-
CROP = {"isEnable": False,
25-
"new_width": 1280,
26-
"new_height": 720}
26+
CROP = {"isEnable": False, "new_width": 1280, "new_height": 720}
27+
28+
DPC = {"isEnable": True, "dp_threshold": 80}
2729

28-
DPC = {"isEnable": True,
29-
"dp_threshold": 80}
30-
3130

3231
HDR = {"isEnable": False}
3332

34-
BLC = {"isEnable": True,
35-
"isLinear": True,
36-
"r_offset": 200,
37-
"gr_offset": 200,
38-
"gb_offset": 200,
39-
"b_offset": 200}
33+
BLC = {
34+
"isEnable": False,
35+
"isLinear": True,
36+
"r_offset": 200,
37+
"gr_offset": 200,
38+
"gb_offset": 200,
39+
"b_offset": 200,
40+
}
4041

4142
OECF = {"isEnable": False}
42-
DG = {"is_save": True}
43+
DG = {"is_save": False}
4344

4445
LSC = {"isEnable": False}
4546

46-
BNR = {"isEnable": False,
47-
"filt_window": 9}
47+
BNR = {"isEnable": False, "filt_window": 9}
4848

49-
WB = {"isEnable": False,
50-
"isAuto": False}
49+
AWB = {"isEnable": False}
50+
WB = {"isEnable": False}
5151
DEM = {"is_save": False}
52-
AWB = {}
5352
CCM = {"isEnable": False}
54-
GC = {"isEnable": True}
53+
GC = {"isEnable": False}
5554
AE = {"isEnable": False}
5655

5756
CSC = {"is_save": False}
58-
LDCI = {"isEnable": True}
57+
LDCI = {"isEnable": False}
5958

60-
SHARPEN ={"isEnable": False}
59+
SHARPEN = {"isEnable": False}
6160
NR2D = {"isEnable": False}
6261

63-
SCALE = {"isEnable": False,
64-
"isHardware": True}
62+
SCALE = {"isEnable": False, "isHardware": True}
6563

66-
YUV= {"isEnable": False,
67-
"conv_type": '444'}
64+
YUV = {"isEnable": False, "conv_type": "444"}
6865

6966
# These modules are currently not a part of isp pipeline, but are included in config
7067
# PRE_GAMMA = {"isEnable": False}
@@ -74,19 +71,19 @@
7471
# define folder name to save outputs
7572
folder_name = datetime.now().strftime("%Y%m%d_%H%M%S")
7673

77-
input_ext = ".raw"
74+
INPUT_EXT = ".raw"
7875

7976
# Setting this flag to True saves yvu array
80-
swap_uv = True
77+
SWAP_UV = False
8178

8279
# Set this flag to True if all input files need to be saved in a single folder
83-
in_single_folder = True
80+
IN_SINGLE_FOLDER = True
8481

8582
# The path of the dataset
8683
DATASET_PATH = "./in_frames/normal/data/"
8784

8885
# Parent folder for Images (Path is relative to ./in_frames/normal/)
89-
PARENT_FOLDER = DATASET_PATH.rsplit('./in_frames/normal/', maxsplit=1)[-1]
86+
PARENT_FOLDER = DATASET_PATH.rsplit("./in_frames/normal/", maxsplit=1)[-1]
9087

9188
# The path of the default config file
9289
CONFIG_PATH = "./config/configs.yml"
@@ -97,52 +94,79 @@
9794

9895
# load, update and resave config file according to above parameters
9996
with open(CONFIG_PATH, "r", encoding="utf-8") as file:
100-
config = yaml.safe_load(file)
97+
config = yaml.safe_load(file)
10198

10299
module_tags = list(config.keys())[2:]
103-
remove = ["swap_uv_channels","pre_gamma", "tone_mapping", "jpeg_conversion"]
100+
remove = ["swap_uv_channels", "pre_gamma", "tone_mapping", "jpeg_conversion"]
104101
[module_tags.remove(module) for module in remove]
105102

106103
# Set is_RTl to True to indicate that automation file is being executed
107104
config["sensor_info"]["is_RTL"] = True
108105

109106
# ensure that the modules are in same order as they are in the config file
110-
new_params = [CROP, DPC, HDR, BLC, OECF, DG, LSC, BNR, WB, DEM, AWB, CCM, GC, AE,
111-
CSC, LDCI, SHARPEN, NR2D, SCALE, YUV]
107+
new_params = [
108+
CROP,
109+
DPC,
110+
HDR,
111+
BLC,
112+
OECF,
113+
DG,
114+
LSC,
115+
BNR,
116+
AWB,
117+
WB,
118+
DEM,
119+
CCM,
120+
GC,
121+
AE,
122+
CSC,
123+
LDCI,
124+
SHARPEN,
125+
NR2D,
126+
SCALE,
127+
YUV,
128+
]
112129

113130
default_modules = ["digital_gain", "demosaic", "color_space_conversion"]
114131

115132
for idx, module in enumerate(module_tags):
116133
# save the input and output arrays of module under test with is_save flag
117-
try:
118-
if module in DUT or module_tags[idx+1] in DUT:
119-
is_save = True
134+
try:
135+
if module in DUT or module_tags[idx + 1] in DUT:
136+
IS_SAVE = True
120137
elif module in default_modules:
121138

122-
is_save = new_params[idx]["is_save"]
123-
else:
124-
is_save = False
125-
139+
IS_SAVE = new_params[idx]["is_save"]
140+
else:
141+
IS_SAVE = False
142+
126143
# update swap_uv flag to save yuv or yvu array
127-
if module in module_tags[module_tags.index("color_space_conversion"):] and is_save:
128-
config["swap_uv_channels"][str(module)] = swap_uv
144+
if (
145+
module in module_tags[module_tags.index("color_space_conversion") :]
146+
and IS_SAVE
147+
):
148+
config["swap_uv_channels"][str(module)] = SWAP_UV
129149

130150
if module in DUT and module not in default_modules:
131-
assert new_params[idx]["isEnable"]==True, "DUT not enabled in this script."
132-
133-
utils.update_config(config, module,new_params[idx].keys(), new_params[idx].values(), is_save)
151+
assert (
152+
new_params[idx]["isEnable"] is True
153+
), "DUT not enabled in this script."
154+
155+
utils.update_config(
156+
config, module, new_params[idx].keys(), new_params[idx].values(), IS_SAVE
157+
)
134158
except IndexError:
135159
pass
136160

137-
# Empty the Results folder in temp folder
161+
# Empty the Results folder in temp folder
138162
shutil.copytree("./out_for_RTL/Results", "./out_for_RTL/temp")
139163
shutil.rmtree("./out_for_RTL/Results")
140164
os.mkdir("./out_for_RTL/Results")
141165

142166
# save the config file along with its results
143167
yaml.add_representer(list, utils.represent_list)
144168

145-
with open(f"./out_for_RTL/Results/configs_automate.yml", "w", encoding="utf-8") as file:
169+
with open("./out_for_RTL/Results/configs_automate.yml", "w", encoding="utf-8") as file:
146170
yaml.dump(config, file, sort_keys=False, Dumper=utils.CustomDumper, width=17000)
147171

148172
# loop over images
@@ -157,14 +181,20 @@
157181
for i, raw_filename in enumerate(RAW_FILENAMES):
158182
# update filename in config
159183
config["platform"]["filename"] = PARENT_FOLDER + raw_filename
160-
184+
161185
# update the config file in cofig file
162-
with open(f"config/configs.yml", "w", encoding="utf-8") as file:
186+
with open("config/configs.yml", "w", encoding="utf-8") as file:
163187
yaml.safe_dump(config, file, sort_keys=False, default_flow_style=False)
164-
188+
165189
# direct standard output stream to a text file
166-
with open(f"./out_for_RTL/Results/{folder_name}_isp_pipeline_log.txt", "a") as text_file:
167-
subprocess.run([sys.executable, "isp_pipeline.py"], check=True, stdout=text_file, text=True)
190+
with open(
191+
f"./out_for_RTL/Results/{folder_name}_isp_pipeline_log.txt",
192+
"a",
193+
encoding="utf-8",
194+
) as text_file:
195+
subprocess.run(
196+
[sys.executable, "isp_pipeline.py"], check=True, stdout=text_file, text=True
197+
)
168198

169199
shutil.copy(RETAINED_CONFIG, CONFIG_PATH)
170200
os.remove(RETAINED_CONFIG)
@@ -174,22 +204,22 @@
174204
path = f"./out_for_RTL/{folder_name}/"
175205

176206
if "crop" in DUT:
177-
utils.rename_for_RTL(path, "Inpipeline_crop_")
207+
utils.rename_for_rtl(path, "Inpipeline_crop_")
178208
else:
179-
input_module = module_tags[module_tags.index(DUT[0])-1]
180-
utils.rename_for_RTL(path, "Out_" + input_module + "_")
209+
input_module = module_tags[module_tags.index(DUT[0]) - 1]
210+
utils.rename_for_rtl(path, "Out_" + input_module + "_")
181211

182-
# restructure the directory
183-
utils.restructure_dir(path, in_single_folder, DUT[-1])
212+
# restructure the directory
213+
utils.restructure_dir(path, IN_SINGLE_FOLDER, DUT[-1])
184214

185215

186216
# convert the saved numpy arrays to bin files as required by the RTL
187-
utils.get_RTL_input(path, in_single_folder, input_ext)
217+
utils.get_rtl_input(path, IN_SINGLE_FOLDER, INPUT_EXT)
188218

189219
# place back the contents of the Results folder
190220
shutil.copytree("./out_for_RTL/temp", "./out_for_RTL/Results")
191221
shutil.rmtree("./out_for_RTL/temp")
192222

193223

194224
# with open(f"./out_for_RTL/{folder_name}/{folder_name}_comparison_log.txt", "a") as text_file:
195-
# subprocess.run([sys.executable, "compare_output.py"], stdout=text_file, text= True)
225+
# subprocess.run([sys.executable, "compare_output.py"], stdout=text_file, text= True)

0 commit comments

Comments
 (0)