Parcourir la source

Added minor support for CV2.UMat in Details and Tonemap tools

Billy Barrow il y a 7 ans
Parent
commit
9677b47bac
2 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 3 1
      PF2/Tools/Details.py
  2. 2 2
      PF2/Tools/Tonemap.py

+ 3 - 1
PF2/Tools/Details.py

@@ -54,6 +54,8 @@ class Details(Tool.Tool):
             # Apply Brightness and Contrast
             edged = self.contrast_tool.on_update(edged)
 
+            edged = cv2.UMat(edged)
+
             # Blur
             if(detail > 0):
                 height, width = image.shape[:2]
@@ -69,7 +71,7 @@ class Details(Tool.Tool):
             # Overlay
             colour = cv2.cvtColor(blurred, cv2.COLOR_GRAY2BGR)
             bpp = int(str(im.dtype).replace("uint", "").replace("float", ""))
-            blended = self._overlay(colour, im, float((2 ** bpp) - 1), im.dtype)
+            blended = self._overlay(colour.get(), im, float((2 ** bpp) - 1), im.dtype)
 
             # Restore Contrast
             self.contrast_tool_restore.props["highlight_contrast"].set_value(pcont * 0.25)

+ 2 - 2
PF2/Tools/Tonemap.py

@@ -35,7 +35,7 @@ class Tonemap(Tool.Tool):
                 gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
 
                 # Invert Grayscale Image
-                inverted = self._invert(gray)
+                inverted = cv2.UMat(self._invert(gray))
 
                 # Blur
                 if(blur > 0):
@@ -52,7 +52,7 @@ class Tonemap(Tool.Tool):
 
                 # First round of Blending
                 colour = cv2.cvtColor(blurred, cv2.COLOR_GRAY2BGR)
-                colouredMap = cv2.addWeighted(colour, (first_opacity / 100), im, 1 - (first_opacity / 100), 0)
+                colouredMap = cv2.addWeighted(colour, (first_opacity / 100), im, 1 - (first_opacity / 100), 0).get()
 
                 # Overlay
                 bpp = int(str(im.dtype).replace("uint", "").replace("float", ""))