def _runImp(self): image = self._scene.image() A_8U = alpha(image) N_32F = self._scene.normal() if N_32F is None: return h_high, w_high = image.shape[:2] w_low = min(256, w_high) h_low = w_low * h_high / w_high N_32F = cv2.resize(N_32F, (w_low, h_low)) if A_8U is not None: A_8U = cv2.resize(A_8U, (w_low, h_low)) D_32F = depthFromNormal(N_32F, A_8U) d_scale = w_high / float(w_low) D_32F = d_scale * D_32F D_32F = cv2.resize(D_32F, (w_high, h_high)) self._scene.setDepth(D_32F) self._scene.setDisplayMode(Scene.DisplayDepth) self._output_info = "(%s, %s)" % (np.min(D_32F), np.max(D_32F)) print self._output_info
def _runImp(self): image = self._scene.image() A_8U = alpha(image) N_32F = self._scene.normal() if N_32F is None: return h_high, w_high = image.shape[:2] w_low = min(256, w_high) h_low = w_low * h_high / w_high N_32F = cv2.resize(N_32F, (w_low, h_low)) if A_8U is not None: A_8U = cv2.resize(A_8U, (w_low, h_low)) D_32F = depthFromNormal(N_32F, A_8U) d_scale = w_high / float(w_low) D_32F = d_scale * D_32F D_32F = cv2.resize(D_32F, (w_high, h_high)) self._scene.setDepth(D_32F) self._scene.setDisplayMode(Scene.DisplayDepth) self._output_info = "(%s, %s)" %(np.min(D_32F), np.max(D_32F)) print self._output_info
def _runImp(self): # file_path = self._data_file file_path = self.resultFile(self._data_file_name, result_name="Wu08") normal_data = loadNormal(file_path) if normal_data is None: return N0_32F, A_8U = normal_data D_32F = depthFromNormal(N0_32F, A_8U) fig, axes = plt.subplots(figsize=(11, 5)) font_size = 15 fig.subplots_adjust(left=0.05, right=0.95, top=0.9, hspace=0.05, wspace=0.05) fig.suptitle("Depth From Normal", fontsize=font_size) plt.subplot(1, 4, 1) plt.title(r'Initial Normal: $N_0$') plt.imshow(normalToColor(N0_32F, A_8U)) plt.axis('off') plt.subplot(1, 4, 2) plt.title(r'Estimated Depth: $D$') plt.gray() plt.imshow(D_32F) plt.axis('off') N_32F = depthToNormal(D_32F) plt.subplot(1, 4, 3) plt.title(r'Recovered Normal: $N$') plt.imshow(normalToColor(N_32F, A_8U)) plt.axis('off') h, w = N_32F.shape[:2] N_diff = angleErros(N_32F.reshape(-1, 3), N0_32F.reshape(-1, 3)).reshape(h, w) N_diff[A_8U < np.max(A_8U)] = 0.0 plt.subplot(1, 4, 4) plt.title(r'Angle Error: $N, N_0$') plt.imshow(N_diff, cmap=plt.cm.jet, vmin=0, vmax=30.0) plt.axis('off') plt.colorbar() #out_file_path = self.resultFile(self._data_file_name) out_file_path = self.resultFile(self._data_file_name, result_name="Wu08Depth") plt.savefig(out_file_path)