Skip to content
Snippets Groups Projects
Commit 856986fb authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Add flip to SDK image write

parent dbc7bd9e
No related branches found
No related tags found
No related merge requests found
Pipeline #23018 passed
...@@ -137,6 +137,7 @@ ftlError_t ftlImageWrite( ...@@ -137,6 +137,7 @@ ftlError_t ftlImageWrite(
} }
if (tmp2.empty()) return FTLERROR_STREAM_NO_DATA; if (tmp2.empty()) return FTLERROR_STREAM_NO_DATA;
cv::flip(tmp2, tmp2, 0); // Flip to get opencv form.
img.upload(tmp2); img.upload(tmp2);
ftl::codecs::Channels<0> channels; ftl::codecs::Channels<0> channels;
......
...@@ -8,6 +8,15 @@ Camera = namedtuple("Camera", ["fx", "fy", "cx", "cy", "width", "height", ...@@ -8,6 +8,15 @@ Camera = namedtuple("Camera", ["fx", "fy", "cx", "cy", "width", "height",
_d_max = 65504.0 _d_max = 65504.0
def lin2s(x):
a = 0.055
if x <=0.0031308:
y = x * 12.92
elif 0.0031308 < x <= 1 :
y = 1.055*(x**(1.0/2.4)) - 0.055
return y
################################################################################ ################################################################################
# https://blender.stackexchange.com/a/120063 # https://blender.stackexchange.com/a/120063
...@@ -183,7 +192,19 @@ def render(): ...@@ -183,7 +192,19 @@ def render():
bpy.ops.render.render() bpy.ops.render.render()
pixels = bpy.data.images['Viewer Node'] pixels = bpy.data.images['Viewer Node']
im = np.array(pixels.pixels[:]).reshape((pixels.size[1], pixels.size[0], pixels.channels)) pix = np.array(pixels.pixels[:])
# sRGB conversion
pix2 = np.zeros(pix.shape[:], dtype=np.float)
np.copyto(pix2, 1.055*(pix**(1.0/2.4)) - 0.055, where=pix <= 1)
np.copyto(pix2, pix * 12.92, where=pix <= 0.0031308)
# Clamp?
pix2[pix2 > 1.0] = 1.0
im = pix2.reshape((pixels.size[1], pixels.size[0], pixels.channels))
depthim = (np.array(pixels.pixels[:]).reshape((pixels.size[1], pixels.size[0], pixels.channels))[:,:,3]).astype(np.float32) depthim = (np.array(pixels.pixels[:]).reshape((pixels.size[1], pixels.size[0], pixels.channels))[:,:,3]).astype(np.float32)
# set invalid depth values to 0.0 # set invalid depth values to 0.0
depthim[depthim >= _d_max] = 0.0 depthim[depthim >= _d_max] = 0.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment