[v4,06/23] libtuning: Fix imports
diff mbox series

Message ID 20240705144209.418906-7-stefan.klug@ideasonboard.com
State Accepted
Headers show
Series
  • Add ccm calibration to libtuning
Related show

Commit Message

Stefan Klug July 5, 2024, 2:41 p.m. UTC
Fix imports to match new structure in the files copied from Raspberry
Pi. Add missing imports in macbeth.py.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/tuning/libtuning/ctt_awb.py |  4 +++-
 utils/tuning/libtuning/ctt_ccm.py | 12 +++++++-----
 utils/tuning/libtuning/macbeth.py |  5 +++++
 3 files changed, 15 insertions(+), 6 deletions(-)

Comments

Dan Scally July 5, 2024, 2:51 p.m. UTC | #1
Hi Stefan

On 05/07/2024 15:41, Stefan Klug wrote:
> Fix imports to match new structure in the files copied from Raspberry
> Pi. Add missing imports in macbeth.py.


Should numpy, scipy and sklearn be added to the new requirements.txt as part of this?

> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>   utils/tuning/libtuning/ctt_awb.py |  4 +++-
>   utils/tuning/libtuning/ctt_ccm.py | 12 +++++++-----
>   utils/tuning/libtuning/macbeth.py |  5 +++++
>   3 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py
> index 5ba6f978a228..f3a1ce779e21 100644
> --- a/utils/tuning/libtuning/ctt_awb.py
> +++ b/utils/tuning/libtuning/ctt_awb.py
> @@ -4,10 +4,12 @@
>   #
>   # camera tuning tool for AWB
>   
> -from ctt_image_load import *
>   import matplotlib.pyplot as plt
>   from bisect import bisect_left
>   from scipy.optimize import fmin
> +import numpy as np
> +
> +from .image import Image
>   
>   
>   """
> diff --git a/utils/tuning/libtuning/ctt_ccm.py b/utils/tuning/libtuning/ctt_ccm.py
> index 59753e332ee9..f37adaf45538 100644
> --- a/utils/tuning/libtuning/ctt_ccm.py
> +++ b/utils/tuning/libtuning/ctt_ccm.py
> @@ -4,12 +4,14 @@
>   #
>   # camera tuning tool for CCM (colour correction matrix)
>   
> -from ctt_image_load import *
> -from ctt_awb import get_alsc_patches
> -import colors
> -from scipy.optimize import minimize
> -from ctt_visualise import visualise_macbeth_chart
>   import numpy as np
> +from scipy.optimize import minimize
> +
> +from . import ctt_colors as colors
> +from .image import Image
> +from .ctt_awb import get_alsc_patches
> +from .utils import visualise_macbeth_chart
> +
>   """
>   takes 8-bit macbeth chart values, degammas and returns 16 bit
>   """
> diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py
> index 81f3e87c9088..265a33d68378 100644
> --- a/utils/tuning/libtuning/macbeth.py
> +++ b/utils/tuning/libtuning/macbeth.py
> @@ -1,6 +1,7 @@
>   # SPDX-License-Identifier: BSD-2-Clause
>   #
>   # Copyright (C) 2019, Raspberry Pi Ltd
> +# Copyright (C) 2024, Ideas on Board Oy
>   #
>   # Locate and extract Macbeth charts from images
>   # (Copied from: ctt_macbeth_locator.py)
> @@ -11,6 +12,10 @@ import cv2
>   import os
>   from pathlib import Path
>   import numpy as np
> +import warnings
> +from sklearn import cluster as cluster
> +
> +from .ctt_ransac import get_square_verts, get_square_centres
>   
>   from libtuning.image import Image
>
Stefan Klug July 5, 2024, 3:19 p.m. UTC | #2
Hi Dan,

Thanks for the review.

On Fri, Jul 05, 2024 at 03:51:12PM +0100, Dan Scally wrote:
> Hi Stefan
> 
> On 05/07/2024 15:41, Stefan Klug wrote:
> > Fix imports to match new structure in the files copied from Raspberry
> > Pi. Add missing imports in macbeth.py.
> 
> 
> Should numpy, scipy and sklearn be added to the new requirements.txt as part of this?

You are absolutely right. That got lost somehow. I rechecked with a new venv and
added the following hunk to this commit:

diff --git a/utils/tuning/requirements.txt b/utils/tuning/requirements.txt
index d1dc589d0329..b287552452c7 100644
--- a/utils/tuning/requirements.txt
+++ b/utils/tuning/requirements.txt
@@ -1,5 +1,8 @@
+matplotlib
 numpy
 opencv-python
 py3exiv2
 pyyaml
 rawpy
+scikit-learn
+scipy


Best regards,
Stefan

> 
> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >   utils/tuning/libtuning/ctt_awb.py |  4 +++-
> >   utils/tuning/libtuning/ctt_ccm.py | 12 +++++++-----
> >   utils/tuning/libtuning/macbeth.py |  5 +++++
> >   3 files changed, 15 insertions(+), 6 deletions(-)
> > 
> > diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py
> > index 5ba6f978a228..f3a1ce779e21 100644
> > --- a/utils/tuning/libtuning/ctt_awb.py
> > +++ b/utils/tuning/libtuning/ctt_awb.py
> > @@ -4,10 +4,12 @@
> >   #
> >   # camera tuning tool for AWB
> > -from ctt_image_load import *
> >   import matplotlib.pyplot as plt
> >   from bisect import bisect_left
> >   from scipy.optimize import fmin
> > +import numpy as np
> > +
> > +from .image import Image
> >   """
> > diff --git a/utils/tuning/libtuning/ctt_ccm.py b/utils/tuning/libtuning/ctt_ccm.py
> > index 59753e332ee9..f37adaf45538 100644
> > --- a/utils/tuning/libtuning/ctt_ccm.py
> > +++ b/utils/tuning/libtuning/ctt_ccm.py
> > @@ -4,12 +4,14 @@
> >   #
> >   # camera tuning tool for CCM (colour correction matrix)
> > -from ctt_image_load import *
> > -from ctt_awb import get_alsc_patches
> > -import colors
> > -from scipy.optimize import minimize
> > -from ctt_visualise import visualise_macbeth_chart
> >   import numpy as np
> > +from scipy.optimize import minimize
> > +
> > +from . import ctt_colors as colors
> > +from .image import Image
> > +from .ctt_awb import get_alsc_patches
> > +from .utils import visualise_macbeth_chart
> > +
> >   """
> >   takes 8-bit macbeth chart values, degammas and returns 16 bit
> >   """
> > diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py
> > index 81f3e87c9088..265a33d68378 100644
> > --- a/utils/tuning/libtuning/macbeth.py
> > +++ b/utils/tuning/libtuning/macbeth.py
> > @@ -1,6 +1,7 @@
> >   # SPDX-License-Identifier: BSD-2-Clause
> >   #
> >   # Copyright (C) 2019, Raspberry Pi Ltd
> > +# Copyright (C) 2024, Ideas on Board Oy
> >   #
> >   # Locate and extract Macbeth charts from images
> >   # (Copied from: ctt_macbeth_locator.py)
> > @@ -11,6 +12,10 @@ import cv2
> >   import os
> >   from pathlib import Path
> >   import numpy as np
> > +import warnings
> > +from sklearn import cluster as cluster
> > +
> > +from .ctt_ransac import get_square_verts, get_square_centres
> >   from libtuning.image import Image
Dan Scally July 5, 2024, 3:35 p.m. UTC | #3
Hi Stefan

On 05/07/2024 16:19, Stefan Klug wrote:
> Hi Dan,
>
> Thanks for the review.
>
> On Fri, Jul 05, 2024 at 03:51:12PM +0100, Dan Scally wrote:
>> Hi Stefan
>>
>> On 05/07/2024 15:41, Stefan Klug wrote:
>>> Fix imports to match new structure in the files copied from Raspberry
>>> Pi. Add missing imports in macbeth.py.
>>
>> Should numpy, scipy and sklearn be added to the new requirements.txt as part of this?
> You are absolutely right. That got lost somehow. I rechecked with a new venv and
> added the following hunk to this commit:
>
> diff --git a/utils/tuning/requirements.txt b/utils/tuning/requirements.txt
> index d1dc589d0329..b287552452c7 100644
> --- a/utils/tuning/requirements.txt
> +++ b/utils/tuning/requirements.txt
> @@ -1,5 +1,8 @@
> +matplotlib
>   numpy
Oops, missed that that was already there.
>   opencv-python
>   py3exiv2
>   pyyaml
>   rawpy
> +scikit-learn
> +scipy
>
Great - with that: Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>


Thanks

Dan

> Best regards,
> Stefan
>
>>> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
>>> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>    utils/tuning/libtuning/ctt_awb.py |  4 +++-
>>>    utils/tuning/libtuning/ctt_ccm.py | 12 +++++++-----
>>>    utils/tuning/libtuning/macbeth.py |  5 +++++
>>>    3 files changed, 15 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py
>>> index 5ba6f978a228..f3a1ce779e21 100644
>>> --- a/utils/tuning/libtuning/ctt_awb.py
>>> +++ b/utils/tuning/libtuning/ctt_awb.py
>>> @@ -4,10 +4,12 @@
>>>    #
>>>    # camera tuning tool for AWB
>>> -from ctt_image_load import *
>>>    import matplotlib.pyplot as plt
>>>    from bisect import bisect_left
>>>    from scipy.optimize import fmin
>>> +import numpy as np
>>> +
>>> +from .image import Image
>>>    """
>>> diff --git a/utils/tuning/libtuning/ctt_ccm.py b/utils/tuning/libtuning/ctt_ccm.py
>>> index 59753e332ee9..f37adaf45538 100644
>>> --- a/utils/tuning/libtuning/ctt_ccm.py
>>> +++ b/utils/tuning/libtuning/ctt_ccm.py
>>> @@ -4,12 +4,14 @@
>>>    #
>>>    # camera tuning tool for CCM (colour correction matrix)
>>> -from ctt_image_load import *
>>> -from ctt_awb import get_alsc_patches
>>> -import colors
>>> -from scipy.optimize import minimize
>>> -from ctt_visualise import visualise_macbeth_chart
>>>    import numpy as np
>>> +from scipy.optimize import minimize
>>> +
>>> +from . import ctt_colors as colors
>>> +from .image import Image
>>> +from .ctt_awb import get_alsc_patches
>>> +from .utils import visualise_macbeth_chart
>>> +
>>>    """
>>>    takes 8-bit macbeth chart values, degammas and returns 16 bit
>>>    """
>>> diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py
>>> index 81f3e87c9088..265a33d68378 100644
>>> --- a/utils/tuning/libtuning/macbeth.py
>>> +++ b/utils/tuning/libtuning/macbeth.py
>>> @@ -1,6 +1,7 @@
>>>    # SPDX-License-Identifier: BSD-2-Clause
>>>    #
>>>    # Copyright (C) 2019, Raspberry Pi Ltd
>>> +# Copyright (C) 2024, Ideas on Board Oy
>>>    #
>>>    # Locate and extract Macbeth charts from images
>>>    # (Copied from: ctt_macbeth_locator.py)
>>> @@ -11,6 +12,10 @@ import cv2
>>>    import os
>>>    from pathlib import Path
>>>    import numpy as np
>>> +import warnings
>>> +from sklearn import cluster as cluster
>>> +
>>> +from .ctt_ransac import get_square_verts, get_square_centres
>>>    from libtuning.image import Image

Patch
diff mbox series

diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py
index 5ba6f978a228..f3a1ce779e21 100644
--- a/utils/tuning/libtuning/ctt_awb.py
+++ b/utils/tuning/libtuning/ctt_awb.py
@@ -4,10 +4,12 @@ 
 #
 # camera tuning tool for AWB
 
-from ctt_image_load import *
 import matplotlib.pyplot as plt
 from bisect import bisect_left
 from scipy.optimize import fmin
+import numpy as np
+
+from .image import Image
 
 
 """
diff --git a/utils/tuning/libtuning/ctt_ccm.py b/utils/tuning/libtuning/ctt_ccm.py
index 59753e332ee9..f37adaf45538 100644
--- a/utils/tuning/libtuning/ctt_ccm.py
+++ b/utils/tuning/libtuning/ctt_ccm.py
@@ -4,12 +4,14 @@ 
 #
 # camera tuning tool for CCM (colour correction matrix)
 
-from ctt_image_load import *
-from ctt_awb import get_alsc_patches
-import colors
-from scipy.optimize import minimize
-from ctt_visualise import visualise_macbeth_chart
 import numpy as np
+from scipy.optimize import minimize
+
+from . import ctt_colors as colors
+from .image import Image
+from .ctt_awb import get_alsc_patches
+from .utils import visualise_macbeth_chart
+
 """
 takes 8-bit macbeth chart values, degammas and returns 16 bit
 """
diff --git a/utils/tuning/libtuning/macbeth.py b/utils/tuning/libtuning/macbeth.py
index 81f3e87c9088..265a33d68378 100644
--- a/utils/tuning/libtuning/macbeth.py
+++ b/utils/tuning/libtuning/macbeth.py
@@ -1,6 +1,7 @@ 
 # SPDX-License-Identifier: BSD-2-Clause
 #
 # Copyright (C) 2019, Raspberry Pi Ltd
+# Copyright (C) 2024, Ideas on Board Oy
 #
 # Locate and extract Macbeth charts from images
 # (Copied from: ctt_macbeth_locator.py)
@@ -11,6 +12,10 @@  import cv2
 import os
 from pathlib import Path
 import numpy as np
+import warnings
+from sklearn import cluster as cluster
+
+from .ctt_ransac import get_square_verts, get_square_centres
 
 from libtuning.image import Image