Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Equilib-Wrapper

A simple wrapper for the pyequilib library that simplifies some syntax and adds some features.

Installation

pip install git+https://github.com/Christophernph/equilib-wrapper.git

Usage

Given an input panorama as shown below, we can convert it to a perspective image using the equi2pers function.

fromequilib_wrapperimportequi2persimportnumpyasnpequi=Image.open("assets/panorama.png").convert("RGB")
equi=np.asarray(equi).transpose(2, 0, 1) # expects channels first# parametersheight=1024width=1536hfov=90rotation=np.array([20, 0, 0]) # roll, pitch, yaw# convertresult=equi2pers(
equi,
height,
width,
hfov=hfov,
degrees=True, # all parameters are in degrees (rotation, h/vfov, h/vrange)
)
# saveresult=Image.fromarray(result.transpose(1, 2, 0))
result.save("assets/perspective.png")

The above code will generate the following perspective image.

It is also possible to specify the range of the equirectangular image used, e.g. if only the top-half of the panorama exists, we can specify the range as follows:

fromequilib_wrapperimportequi2persimportnumpyasnpequi=Image.open("assets/panorama.png").convert("RGB")
equi=np.asarray(equi).transpose(2, 0, 1) # expects channels firstequi=equi[:, :equi.shape[1] //2, :] # only use the top half# parametersheight=1024width=1536hfov=90rotation=np.array([20, 0, 0]) # roll, pitch, yawvrange= (-90, 0) # specify range of the equirectangular image# convertresult=equi2pers(
equi,
height,
width,
hfov=hfov,
degrees=True,
vrange=vrange,
)
# saveresult=Image.fromarray(result.transpose(1, 2, 0))
result.save("assets/perspective_range.png")

The above code will generate the following perspective image.

Notice how any region outside the specified range is wrapped around the equirectangular image. If this is not desired, it is also possible to specify fill_mode as pad and then pad_value to the desired RGB value.

fromequilib_wrapperimportequi2persimportnumpyasnpequi=Image.open("assets/panorama.png").convert("RGB")
equi=np.asarray(equi).transpose(2, 0, 1) # expects channels firstequi=equi[:, :equi.shape[1] //2, :] # only use the top half# parametersheight=1024width=1536hfov=90rotation=np.array([20, 0, 0]) # roll, pitch, yawvrange= (-90, 0) # specify range of the equirectangular image# convertresult=equi2pers(
equi,
height,
width,
hfov=hfov,
degrees=True,
vrange=vrange,
fill_mode="pad",
pad_value=(0, 0, 0), # black fill
)
# saveresult=Image.fromarray(result.transpose(1, 2, 0))
result.save("assets/perspective_pad.png")

The above code will generate the following perspective image.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages