From 3ec32b2fc815e318664cef0052909224e282bbf2 Mon Sep 17 00:00:00 2001 From: YFJack Date: Thu, 27 Nov 2025 23:30:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor(perspective=5Futils):=20Fix=20geometri?= =?UTF-8?q?c=20distortion=20and=20edge=20artifacts=20in=20Perspective=20pr?= =?UTF-8?q?ojection=20=E4=BF=AE=E6=AD=A3FOV=E9=94=99=E8=AF=AF=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=80=BB=E8=BE=91=E5=B9=B6=E4=BF=AE=E6=AD=A3=E8=BE=B9?= =?UTF-8?q?=E7=95=8C=E5=A4=84=E7=90=86=20=E5=B0=86=E8=BE=B9=E7=95=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=A8=A1=E5=BC=8F=E4=BB=8EBORDER=5FWRAP?= =?UTF-8?q?=E6=94=B9=E4=B8=BABORDER=5FCONSTANT=E5=B9=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=BB=91=E8=89=B2=E5=A1=AB=E5=85=85=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hy3dworld/utils/perspective_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hy3dworld/utils/perspective_utils.py b/hy3dworld/utils/perspective_utils.py index 3c75853..fcced24 100755 --- a/hy3dworld/utils/perspective_utils.py +++ b/hy3dworld/utils/perspective_utils.py @@ -37,14 +37,14 @@ def __init__(self, img_name=None, FOV=None, THETA=None, PHI=None, img_width=512, self.THETA = THETA self.PHI = PHI if self._width > self._height: - self.wFOV = FOV - self.hFOV = (float(self._height) / self._width) * FOV + self.w_len = np.tan(np.radians(FOV / 2.0)) + self.h_len = self.w_len * float(self._height) / self._width else: - self.wFOV = (float(self._width) / self._height) * FOV - self.hFOV = FOV + self.h_len = np.tan(np.radians(FOV / 2.0)) + self.w_len = self.h_len * float(self._width) / self._height - self.w_len = np.tan(np.radians(self.wFOV / 2.0)) - self.h_len = np.tan(np.radians(self.hFOV / 2.0)) + self.wFOV = np.degrees(2 * np.arctan(self.w_len)) + self.hFOV = np.degrees(2 * np.arctan(self.h_len)) def GetEquirec(self, height, width, img=None): # @@ -99,7 +99,7 @@ def GetEquirec(self, height, width, img=None): 0) # Remap the image using the longitude and latitude maps persp = cv2.remap(self._img, lon_map.astype(np.float32), lat_map.astype( - np.float32), cv2.INTER_CUBIC, borderMode=cv2.BORDER_WRAP) # BORDER_CONSTANT) #)) + np.float32), cv2.INTER_CUBIC, borderMode=cv2.BORDER_CONSTANT, borderValue=(0, 0, 0)) # Apply the mask to the equirectangular image mask = mask * inverse_mask mask = np.repeat(mask[:, :, np.newaxis], 3, axis=2)