Given an image and uv coordinates how can we generate an unwrapped texture map of specified resolution? Is there any way to get this done in Python?
image - 1440, 1080, 3 (Can be any size)
UV Coordinates - 1220, 2 (2D array of texture coordinates)
Texture size - 1024 (New size of texture)
I wrote a code to convert uv coordinates to texture map size.
def get_x_y_uv(uv_coords, texture_h, texture_w):
x = uv_obj[:, 0] * texture_w - 0.5
y = (1 - uv_obj[:, 1]) * texture_h - 0.5
return np.dstack((x, y))[0]
This gives me uv coords converted to texture map size coordinates.
This is the image what I get when I view uv coordinates for texture size 1024.
One method I found is it to use OpenCV remap function for which I need to replace each uv coordinate on the above image with x, y, z pixel location from image. But in order for the method to work, the above mask has to be filled completely with pixel location of image, but I only have 1220 points on that map for which I know the pixel location of. In this case each of the 1220 points will have a value like (459, 375, 53) depicting pixel location in main image.
Any suggestions of already available libraries which generates unwrapped textures are greatly appreciated.