def to_cv2_image(surface):
        """
        convert the pygame.surface to image
        Args:
            surface: pygame.surface

        Returns: image in numpy array

        """
        img_array = np.array(pygame.surfarray.pixels3d(surface))
        image_object = np.transpose(img_array, (1, 0, 2))
        # image_object[:, :, [0, 2]] = image_object[:, :, [2, 0]]
        return image_object

        convert the pygame.surface to image
        Args:
            surface: pygame.surface

        Returns: image in numpy array

        
metadrive/obs/top_down_obs_impl.py