Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yasumat committed Feb 22, 2019
1 parent 878ff25 commit b0a36dd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions psutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,26 @@ def load_npyimages(foldername=None):
return M, height, width


def disp_normalmap(normal=None, height=None, width=None, delay=0):
def disp_normalmap(normal=None, height=None, width=None, delay=0, name=None):
"""
Visualize normal as a normal map
:param normal: array of surface normal (p \times 3)
:param height: height of the image (scalar)
:param width: width of the image (scalar)
:param delay: duration (ms) for visualizing normal map. 0 for displaying infinitely until a key is pressed.
:param name: display name
:return: None
"""
if normal is None:
raise ValueError("Surface normal `normal` is None")
N = np.reshape(normal, (height, width, 3)) # Reshape to image coordinates
N[:, :, 0], N[:, :, 2] = N[:, :, 2], N[:, :, 0].copy() # Swap RGB <-> BGR
N = (N + 1.0) / 2.0 # Rescale
cv2.imshow('normal map', N)
if name is None:
name = 'normal map'
cv2.imshow(name, N)
cv2.waitKey(delay)
cv2.destroyWindow('normal map')
cv2.destroyWindow(name)
cv2.waitKey(1) # to deal with frozen window...


Expand Down

0 comments on commit b0a36dd

Please sign in to comment.