[PATCH v4 08/23] libtuning: Fix visualize_macbeth_chart()

Stefan Klug stefan.klug at ideasonboard.com
Fri Jul 5 16:41:44 CEST 2024


The old function uses PIL to save the image, which is not in the
requirements file. As we are already requiring opencv, use that to save
images instead of an additional dependency

Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 utils/tuning/libtuning/utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py
index 872341407b7b..90fd7072a0fd 100644
--- a/utils/tuning/libtuning/utils.py
+++ b/utils/tuning/libtuning/utils.py
@@ -5,6 +5,7 @@
 #
 # Utilities for libtuning
 
+import cv2
 import decimal
 import math
 import numpy as np
@@ -162,6 +163,6 @@ def visualise_macbeth_chart(macbeth_rgb, original_rgb, new_rgb, output_filename)
                 for g in range(100):
                     image[xlocation + i, ylocation + g] = new_rgb[colorindex]
 
-    img = Image.fromarray(image, 'RGB')
-    img.save(str(output_filename) + 'Generated Macbeth Chart.png')
+    im_bgr = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
+    cv2.imwrite(f'{output_filename} Generated Macbeth Chart.png', im_bgr)
 
-- 
2.43.0



More information about the libcamera-devel mailing list