From 586ff5b3fbe50ec189d1e588589b248d6b9f3e1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:59:14 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/draw/utils.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/supervision/draw/utils.py b/supervision/draw/utils.py index 2bc26e6b..56740377 100644 --- a/supervision/draw/utils.py +++ b/supervision/draw/utils.py @@ -1,4 +1,3 @@ -import os from typing import Optional, Union import cv2 @@ -196,20 +195,16 @@ def draw_image( alpha_channel = cv2.convertScaleAbs(alpha_channel * opacity) # Get the ROI from the scene - scene_roi = scene[rect.y:rect.y + rect.height, rect.x:rect.x + rect.width] + scene_roi = scene[rect.y : rect.y + rect.height, rect.x : rect.x + rect.width] # Manually apply alpha blending alpha_float = alpha_channel.astype(np.float32) / 255.0 - blended_roi = ((1.0 - alpha_float[..., np.newaxis]) * scene_roi.astype(np.float32)) + (alpha_float[..., np.newaxis] * image.astype(np.float32)) + blended_roi = ( + (1.0 - alpha_float[..., np.newaxis]) * scene_roi.astype(np.float32) + ) + (alpha_float[..., np.newaxis] * image.astype(np.float32)) blended_roi = blended_roi.astype(np.uint8) # Insert blended ROI back into the scene - scene[rect.y:rect.y + rect.height, rect.x:rect.x + rect.width] = blended_roi + scene[rect.y : rect.y + rect.height, rect.x : rect.x + rect.width] = blended_roi return scene - - - - - -