numpy if I have a half equirectangular image how do I create a fish eye image?

so examples are in (https://blog.mikeswanson.com/apples-mysterious-fisheye-projection/)
not the apple propritery fisheye projection just where it talks about standard fisheye and half equirectuagular projection for just aa 180 degree hemesphere view

I looked at the code in omnicv:


def equirect2Fisheye(self,
                     img,
                     outShape,
                     f=50,
                     xi=1.2,
                     angles=[0, 0, 0]
                     ):

    self.Hd = outShape[0]
    self.Wd = outShape[1]
    self.f = f
    self.xi = xi

    Hs, Ws = img.shape[:2]

    self.Cx = self.Wd / 2.0
    self.Cy = self.Hd / 2.0

    x = np.linspace(0, self.Wd - 1, num=self.Wd, dtype=np.float32)
    y = np.linspace(0, self.Hd - 1, num=self.Hd, dtype=np.float32)

    x, y = np.meshgrid(range(self.Wd), range(self.Hd))
    xref = 1
    yref = 1

    self.fmin = (
        np.sqrt(
            -(1 - self.xi ** 2) * ((xref - self.Cx) ** 2 +
                                   (yref - self.Cy) ** 2)
        )
        * 1.0001
    )

    x_hat = (x - self.Cx) / self.f
    y_hat = (y - self.Cy) / self.f

    x2_y2_hat = x_hat ** 2 + y_hat ** 2

    omega = np.real(
        self.xi + np.lib.scimath.sqrt(1 + (1 - self.xi ** 2) * x2_y2_hat)
    ) / (x2_y2_hat + 1)
    # print(np.max(x2_y2_hat))

    Ps_x = omega * x_hat
    Ps_y = omega * y_hat
    Ps_z = omega - self.xi

    self.alpha = angles[0]
    self.beta = angles[1]
    self.gamma = angles[2]

    R = np.matmul(
        rmat(self.alpha, self.beta, self.gamma),
        np.matmul(rmat(0, -90, 45), rmat(0, 90, 90)),
    )

    Ps = np.stack((Ps_x, Ps_y, Ps_z), -1)
    Ps = np.matmul(Ps, R.T)

    Ps_x, Ps_y, Ps_z = np.split(Ps, 3, axis=-1)
    Ps_x = Ps_x[:, :, 0]
    Ps_y = Ps_y[:, :, 0]
    Ps_z = Ps_z[:, :, 0]

    theta = np.arctan2(Ps_y, Ps_x)
    phi = np.arctan2(Ps_z, np.sqrt(Ps_x ** 2 + Ps_y ** 2))

    a = 2 * np.pi / (Ws - 1)
    b = np.pi - a * (Ws - 1)
    self.map_x = (1.0 / a) * (theta - b)

    a = -np.pi / (Hs - 1)
    b = np.pi / 2
    self.map_y = (1.0 / a) * (phi - b)

    output = cv2.remap(
        img,
        self.map_x.astype(np.float32),
        self.map_y.astype(np.float32),
        cv2.INTER_CUBIC,
        borderMode=cv2.BORDER_WRAP,
    )

    if self.f < self.fmin:
        r = np.sqrt(-(self.f ** 2) / (1 - self.xi ** 2))
        mask = np.zeros_like(output[:, :, 0])
        mask = cv2.circle(
            mask, (int(self.Cx), int(self.Cy)), int(r), (255, 255, 255), -1
        )
        output = cv2.bitwise_and(output, output, mask=mask)

    return output


but it does not seem to be for half equiretangular I think and it seems like you need to put in camera parameters?
but its not well documented so I cant tell.

so do you know how I would just do a simple function that just deals with the case of a square equirectangular image so width == height representing a 180 degree view horozontaly and vertically and I want it to output a image of the same size that is a fish eye projection of 180 degrees so making it as simple as possible.

so do you know how I would just do a simple function that just deals with the case of a square equirectangular image so width == height representing a 180 degree view horozontaly and vertically and I want it to output a image of the same size that is a fish eye projection of 180 degrees so making it as simple as possible. I have loaded the half equirectagular image into a numpy array named at "hequirect" where hequirect has shape (1600, 1600, 3) and hequirect dtype is uint8.