Skip to content

Commit 234f3ab

Browse files
Output comparison (#14)
UV channel swap feature added in YUV output image saving * automate_execution currently works on config_automate file to generate RTL compatible results. * added in_single_folder flag to set the structure of the out_for_RTL folder. If True, all input files are saved in a single folder. * - automate_execution.py works on configs.yml now instead of a separate config_automate.yml. - added is_save flag in configs.yml * - verified results by matching .npy files, they match. - exception added if ValueError is encountered while loading np arrays. * - foldername(line 63) now specified by datetime obj - added compare_output file (Inprogress) - made chnages to handle new foldername in rename_to_RTL in utils.py * output of the default modules can now by saved using is_save flag in automate_execution script. * To test multiple modules, type of DUT changed from str to list. * added input_ext variable to specify raw file extension. * created Results folder in out_for_RTL. This folder will save the input and output arrays to ISP piepline, whether generted while executing isp_pipeline.py individually or using the auatomation script. * Added functions in utils.py to dump config file in a more readable format. * added .gitkeep file in results * added .gitkeep file in out_for _RTL * verified that key: "value" and key: vlaue pair are the same YAMLObject by setting canonical=True in yaml.dump. * - Added function in utils.py "remove_arr_border" - using sys.execute to reove OS dependency from automation script - improvements in compare_output.py are in progress - renaming RTl files by remove_str. - save log file - remove border or onnly rows * added is_RTL flag in sensor_info * added remove_rows-for_RTL function in utils. * tested remove border and remove rows function in utils. * Added lines to save output of the isp_pipeline.py to a text file. * Cleaned up file and renamed the log file according to datetime stamp * added swap_uv flag in automate file to save yuv or yvu array. --------- Co-authored-by: taimur-10xe <[email protected]> Co-authored-by: taimur-10xe <[email protected]>
1 parent 5f58a5b commit 234f3ab

File tree

4 files changed

+58
-9
lines changed

4 files changed

+58
-9
lines changed

automate_execution.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
AE = {"isEnable": False}
5656

5757
CSC = {"is_save": False}
58-
LDCI = {"isEnable": False}
58+
LDCI = {"isEnable": True}
5959

6060
SHARPEN ={"isEnable": False}
6161
NR2D = {"isEnable": False}
@@ -76,6 +76,9 @@
7676

7777
input_ext = ".raw"
7878

79+
# Setting this flag to True saves yvu array
80+
swap_uv = True
81+
7982
# Set this flag to True if all input files need to be saved in a single folder
8083
in_single_folder = True
8184

@@ -97,7 +100,7 @@
97100
config = yaml.safe_load(file)
98101

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

103106
# Set is_RTl to True to indicate that automation file is being executed
@@ -120,8 +123,13 @@
120123
else:
121124
is_save = False
122125

126+
# 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
129+
123130
if module in DUT and module not in default_modules:
124131
assert new_params[idx]["isEnable"]==True, "DUT not enabled in this script."
132+
125133
utils.update_config(config, module,new_params[idx].keys(), new_params[idx].values(), is_save)
126134
except IndexError:
127135
pass

config/configs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ sensor_info:
1010
height: 1536
1111
hdr: false
1212
is_RTL: False
13+
swap_uv_channels:
14+
color_space_conversion: true
15+
ldci: true
16+
sharpen: false
17+
2d_noise_reduction: false
18+
scale: false
19+
yuv_conversion_format: false
1320
crop:
1421
isEnable: false
1522
isDebug: false

isp_pipeline.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import numpy as np
1313
import yaml
1414
import rawpy
15-
15+
import util.utils as util
1616

1717
from modules.dead_pixel_correction import DeadPixelCorrection as DPC
1818
from modules.hdr_stitching import HdrStitching as HDRS
@@ -81,6 +81,7 @@
8181
parm_sha = c_yaml["sharpen"]
8282
parm_jpg = c_yaml["jpeg_conversion"]
8383
parm_yuv = c_yaml["yuv_conversion_format"]
84+
parm_swap = c_yaml["swap_uv_channels"]
8485

8586
# Get the path to the inputfile
8687
RAW_FOLDER = "./in_frames/normal/"
@@ -311,7 +312,11 @@
311312
# save module output if enabled
312313
if parm_csc["is_save"]:
313314
filename = save_dir + "Out_color_space_conversion_" + inFile.split(".")[0]
314-
np.save(filename, csc_img)
315+
if parm_swap["color_space_conversion"]:
316+
swapped_arr = util.swap_uv(csc_img)
317+
np.save(filename, swapped_arr)
318+
else:
319+
np.save(filename, csc_img)
315320

316321
# x = np.load(save_dir +"Out_color_space_conversion_" + inFile.split(".")[0]+".npy")
317322
# print(np.array_equal(x, csc_img))
@@ -323,7 +328,11 @@
323328
# save module output if enabled
324329
if parm_ldci["is_save"]:
325330
filename = save_dir + "Out_ldci_" + inFile.split(".")[0]
326-
np.save(filename, ldci_img)
331+
if parm_swap["ldci"]:
332+
swapped_arr = util.swap_uv(ldci_img)
333+
np.save(filename, swapped_arr)
334+
else:
335+
np.save(filename, ldci_img)
327336

328337
# x = np.load(save_dir +"Out_ldci_" + inFile.split(".")[0]+".npy")
329338
# print(np.array_equal(x, ldci_img))
@@ -335,7 +344,11 @@
335344
# save module output if enabled
336345
if parm_sha["is_save"]:
337346
filename = save_dir + "Out_sharpen_" + inFile.split(".")[0]
338-
np.save(filename, sharp_img)
347+
if parm_swap["sharpen"]:
348+
swapped_arr = util.swap_uv(sharp_img)
349+
np.save(filename, swapped_arr)
350+
else:
351+
np.save(filename, sharp_img)
339352

340353
# x = np.load(save_dir +"Out_sharpen_" + inFile.split(".")[0]+".npy")
341354
# print(np.array_equal(x, sharp_img))
@@ -347,7 +360,11 @@
347360
# save module output if enabled
348361
if parm_2dn["is_save"]:
349362
filename = save_dir + "Out_2d_noise_reduction_" + inFile.split(".")[0]
350-
np.save(filename, nr2d_img)
363+
if parm_swap["2d_noise_reduction"]:
364+
swapped_arr = util.swap_uv(nr2d_img)
365+
np.save(filename, swapped_arr)
366+
else:
367+
np.save(filename, nr2d_img)
351368

352369
# x = np.load(save_dir +"Out_2d_noise_reduction_" + inFile.split(".")[0]+".npy")
353370
# print(np.array_equal(x, nr2d_img))
@@ -359,7 +376,11 @@
359376
# save module output if enabled
360377
if parm_sca["is_save"]:
361378
filename = save_dir + "Out_scale_" + inFile.split(".")[0]
362-
np.save(filename, scaled_img)
379+
if parm_swap["scale"]:
380+
swapped_arr = util.swap_uv(scaled_img)
381+
np.save(filename, swapped_arr)
382+
else:
383+
np.save(filename, scaled_img)
363384

364385
# x = np.load(save_dir +"Out_scale_" + inFile.split(".")[0]+".npy")
365386
# print(np.array_equal(x, scaled_img))
@@ -372,7 +393,11 @@
372393
# save module output if enabled
373394
if parm_yuv["is_save"]:
374395
filename = save_dir + "Out_yuv_conversion_format_" + inFile.split(".")[0]
375-
np.save(filename, yuv_conv)
396+
if parm_swap["yuv_conversion_format"]:
397+
swapped_arr = util.swap_uv(yuv_conv)
398+
np.save(filename, swapped_arr)
399+
else:
400+
np.save(filename, yuv_conv)
376401

377402
# x = np.load(save_dir +"Out_yuv_conversion_format_" + inFile.split(".")[0]+".npy")
378403
# print(np.array_equal(x, yuv_conv))

util/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,16 @@ def get_approximate(decimal, register_bits, frac_precision_bits):
188188
fixed_float = Fxp(decimal, False, register_bits, frac_precision_bits)
189189
return fixed_float(), fixed_float.bin()
190190

191+
def swap_uv(arr):
192+
"""This function swaps the U and Y channels in yuv image ARR."""
193+
assert len(arr.shape)==3, "Input array must be 3D."
194+
195+
out_arr = np.zeros(arr.shape, arr.dtype)
196+
out_arr[:, :, 0] = arr[:,:,0]
197+
out_arr[:, :, 1] = arr[:,:,2]
198+
out_arr[:, :, 2] = arr[:,:,1]
191199

200+
return out_arr
192201
#automation script related utilities
193202
def arrange_channels(arr):
194203
"""This function changes the sequence of the chnanels in an input

0 commit comments

Comments
 (0)