<div dir="ltr"><div dir="ltr">Hi Laurent,<div><br></div><div>Thank you for your feedback.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 15 Jul 2022 at 00:55, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Naush,<br>
<br>
Thank you for the patch.<br>
<br>
On Thu, Jul 14, 2022 at 04:24:08PM +0100, Naushir Patuck via libcamera-devel wrote:<br>
> Use the tuning file conversion script to output the new tuning file format from<br>
> the CTT.<br>
> <br>
> Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> ---<br>
> utils/raspberrypi/ctt/ctt.py | 13 ++++++-------<br>
> 1 file changed, 6 insertions(+), 7 deletions(-)<br>
> <br>
> diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py<br>
> index 15064634c67f..0d91ada15afa 100755<br>
> --- a/utils/raspberrypi/ctt/ctt.py<br>
> +++ b/utils/raspberrypi/ctt/ctt.py<br>
> @@ -15,7 +15,7 @@ from ctt_alsc import *<br>
> from ctt_lux import *<br>
> from ctt_noise import *<br>
> from ctt_geq import *<br>
> -from ctt_pretty_print_json import *<br>
<br>
ctt_pretty_print_json.py isn't used anymore, should it be dropped ?<br>
<br>
> +from convert_tuning import convert_v2<br>
> import random<br>
> import json<br>
> import re<br>
> @@ -511,13 +511,12 @@ class Camera:<br>
> """<br>
> def write_json(self):<br>
> """<br>
> - Write json dictionary to file<br>
> + Write json dictionary to file using our version 2 format<br>
> """<br>
> - jstring = json.dumps(self.json, sort_keys=False)<br>
> - """<br>
> - make it pretty :)<br>
> - """<br>
> - pretty_print_json(jstring, self.jf)<br>
> + out_json = convert_v2(self.json)<br>
<br>
That's cheating :-) I'm OK with it for now, Would it be difficult to<br>
output the v2 format natively though ? It seems that something along the<br>
lines of the following code should do:<br>
<br>
out_json = {<br>
"version": "2.0",<br>
"algorithms": [{name: data} for name, data in self.json.items()],<br>
}<br>
<br>
and then you could import the Encoder class from convert_tuning instead<br>
of the convert_v2 function, and do<br>
<br>
with open(self.jf, 'w') as f:<br>
f.write(json.dumps(out_json, cls=Encoder, indent=4, sort_keys=False))<br>
<br>
Possibly even better, the Encoder class could be moved from<br>
convert_tuning.py to ctt_pretty_print_json and replace the existing<br>
hand-written JSONPrettyPrinter.<br></blockquote><div><br></div><div>I think I would prefer the first suggestion and delete ctt_pretty_print_json.py.</div><div>It pretty much does what convert_tuning.py does, so seems redundant.</div><div><br></div><div>Naush</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +<br>
> + with open(self.jf, 'w') as f:<br>
> + f.write(out_json)<br>
> <br>
> """<br>
> add a new section to the log file<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>