non_blocking_visualisation.py μμ λ₯Ό κ³ λ €νμμμ€.
μ°λ¦¬κ° μ ννλ©΄
draw_geometries([source_raw])
μ΄ν μΈμ λ μ§
vis = Visualizer()
vis.create_window()
draw_geometriesλ₯Ό μ’ λ£ ν ν visλ₯Ό μ¬μ©νλ €κ³ νλ©΄ λ€μ μ€λ₯κ° μΆλ ₯λ©λλ€.
GLFW μ€λ₯ : GLFW λΌμ΄λΈλ¬λ¦¬κ° μ΄κΈ°νλμ§ μμμ΅λλ€.
κ·Έ μ΄νμλ vis μ°½μ μ무κ²λ νμλμ§ μμ΅λλ€.
λΉ μ°¨λ¨ λ°©μμΌλ‘ ν¬μΈνΈ ν΄λΌμ°λλ₯Ό νμνλ μ±μμμ΄ μλ리μ€λ₯Ό λ°κ²¬νμ΅λλ€. κ·Έλ¬λ λλ²κΉ ν λ μ€κ° κ²°κ³Όλ₯Ό νμνκΈ° μν΄ ipython μΈν°ν리ν°μμ draw_geometries ()λ₯Ό μμ£Ό νΈμΆν©λλ€. λ¬Έμ λ νμ¬μ΄ μμ μ μννλ©΄ λΉ μ°¨λ¨ μκ°νκ° μλμ λ©μΆ€μΌλ‘μ¨ μ±μ κ³μν μ μλ€λ κ²μ λλ€. λΉ μ°¨λ¨ μκ°νλ₯Ό λ€μ λ³΄λ €λ©΄ μ±μ λ€μ μμν΄μΌν©λλ€.
μ΄λ₯Ό λ°©μ§νκΈ° μν΄ ν μμλ μΌμ΄ μμ΅λκΉ?
μλ
νμΈμ @martinakos. draw_geometries
μ κ³ κΈ κΈ°λ₯μ
λλ€. μ°½μ λ§λ€κ³ λνμ μΆκ°ν©λλ€. draw_geometries
λ₯Ό lop λ΄λΆμ λ£μΌλ©΄ λμμ λ§μ μ°½μ΄ λ§λ€μ΄μ§κ³ λ¬Έμ κ° λ°μν μ μμ΅λλ€.
ν΄κ²° λ°©λ²μ Visualizer () ν΄λμ€λ₯Ό μ μνκ³ λ΄λΆ ν¨μλ₯Ό μ¬μ©νλ κ²μ λλ€. non_blocking_visualisation.pyλ₯Ό μ¬μ©νμ¬ μλ₯Ό λ€μ΄ λ³΄κ² μ΅λλ€.
vis = Visualizer()
vis.create_window()
vis.add_geometry(source)
vis.add_geometry(target)
threshold = 0.05
icp_iteration = 100
save_image = False
##################
# this is to display the second example
vis2 = Visualizer()
vis2.create_window()
vis2.add_geometry(source) # replace your geometry
##################
for i in range(icp_iteration):
reg_p2l = registration_icp(source, target, threshold,
np.identity(4), TransformationEstimationPointToPlane(),
ICPConvergenceCriteria(max_iteration = 1))
source.transform(reg_p2l.transformation)
vis.update_geometry()
vis.poll_events()
vis.update_renderer()
##################
# this is to display the second example
vis2.update_geometry()
vis2.poll_events()
vis2.update_renderer()
##################
if save_image:
vis.capture_screen_image("temp_%04d.jpg" % i)
vis.destroy_window()
vis2.destroy_window()
μ΄ μ€ν¬λ¦½νΈλ κ²°ν¨μμ΄ λ κ°μ νλ©΄μ νμν©λλ€.
μ£μ‘ν©λλ€. μ λͺ¨λ₯΄κ² λ€μ. λλ²κΉ λͺ©μ μΌλ‘ λν ν ν둬ννΈμμλ§ draw_geometries ()λ₯Ό νΈμΆν©λλ€. μ€λ¨ μ μμ μ€μ§ λ λμ μ€κ° μμ μ΄ μλ νλλ‘ μλνλμ§ νμΈνκ³ λνμμΌλ‘ κ²μ¬ ν μ μμ΅λλ€. μ λ draw_geometries ()λ₯Ό numpy λ°°μ΄μμ λ§μ ν¬μΈνΈ ν΄λΌμ°λλ₯Ό μμ±νκ³ λ§μ»€λ₯Ό μΆκ° ν μμλ ν¨μλ‘ λννμ΅λλ€. λν ν λλ²κΉ μ λ§€μ° νΈλ¦¬ν©λλ€. λ¬Έμ λμ΄ κΈ°λ₯μ μ¬μ©νλ©΄ λΉ μ°¨λ¨ μκ°νκ° μ€λ¨λλ€λ κ²μ λλ€.
μλ₯Ό λ€μ΄ μ£Όμ
μ κ°μ¬ν©λλ€. μ΄ μμμ λ μ°½ λͺ¨λμ μνΈ μμ©ν μ μμμ μ μ μμ΅λλ€. μ΄κ²μ μ’λ€.
κ·Έλμ μ½λλ₯Ό λ΄ μ¬μ© μ¬λ‘μ λ§κ² μ¬ ν¬μ₯νκ³ μλ ν
μ€νΈλ₯Ό λ§λ€μμ΅λλ€.
from open3d import *
import numpy as np
import copy
def show_drawings(source):
vis2 = Visualizer()
vis2.create_window(window_name='window2',width=640, height=480)
vis2.add_geometry(source) # replace your geometry
e = True
while e:
vis2.update_geometry()
e = vis2.poll_events()
vis2.update_renderer()
#vis2.destroy_window()
return
if __name__ == "__main__":
set_verbosity_level(VerbosityLevel.Debug)
source_raw = read_point_cloud("../../TestData/ICP/cloud_bin_0.pcd")
target_raw = read_point_cloud("../../TestData/ICP/cloud_bin_1.pcd")
source = voxel_down_sample(source_raw, voxel_size = 0.02)
target = voxel_down_sample(target_raw, voxel_size = 0.02)
trans = [[0.862, 0.011, -0.507, 0.0],
[-0.139, 0.967, -0.215, 0.7],
[0.487, 0.255, 0.835, -1.4],
[0.0, 0.0, 0.0, 1.0]]
source.transform(trans)
flip_transform = [[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1]]
source.transform(flip_transform)
target.transform(flip_transform)
vis = Visualizer()
vis.create_window(window_name='window1',width=640, height=480)
vis.add_geometry(source)
vis.add_geometry(target)
threshold = 0.05
icp_iteration = 100
save_image = False
for i in range(icp_iteration):
reg_p2l = registration_icp(source, target, threshold,
np.identity(4), TransformationEstimationPointToPlane(),
ICPConvergenceCriteria(max_iteration = 1))
source.transform(reg_p2l.transformation)
vis.update_geometry()
vis.poll_events()
vis.update_renderer()
#At some point, while running, set a breakpoint here
#and in the interactive prompt call: show_drawings(source)
#after inspecting, press ESC to close the window,
#and continue with the script.
if save_image:
vis.capture_screen_image("temp_%04d.jpg" % i)
vis.destroy_window()
λ΄κ° μνλ κ²μ "if save_image"μ€μ μ€λ¨ μ μμ μ½λλ₯Ό μ€μ§ ν μ μλ€λ κ²μ λλ€. κ·Έλ° λ€μμ΄ μ€ μμ μ£Όμμμ μ€λͺ νλλ‘ λν ν ν둬ννΈμμ λ΄ show_drawings (source)λ₯Ό νΈμΆν©λλ€. ν¬μΈνΈ ν΄λΌμ°λλ₯Ό κ²μ¬νμμμ€. ESCλ₯Ό λλ¬ μ°½μ λ«μΌμμμ€. κ·Έλ° λ€μ μ€ν¬λ¦½νΈ μ€νμ κ³μνμμμ€. κ·Έλ¬λ μ΄λ€ μ΄μ λ‘ window2λ₯Ό λ«μ λ ESCλ₯Ό λλ₯΄λ©΄ window1λ λ«νλλ€! λ€μμ window1μ μ¬μ©ν λ "GLFW μ€λ₯ : GLFW λΌμ΄λΈλ¬λ¦¬κ° μ΄κΈ°νλμ§ μμμ΅λλ€"κ° λ€μ λνλ©λλ€.
λ΄κ° μλ ν κ²μ μ΄λ»κ²νλμ§ μμλκΉ?
κ°μ μ¦μμ΄ λ³΄μ λλ€. glfw window close μ΄λ²€νΈκ° λͺ¨λ μ°½μ λΈλ‘λ μΊμ€νΈλκ³ μλ κ² κ°μ§λ§ μμ§μ΄ λ¬Έμ λ₯Ό ν΄κ²°νλ λ°©λ²μ μ°Ύμ μ μμ΅λλ€.
λ€μκ³Ό κ°μ΄ del vis
μΆκ° :
vis.destroy_window()
del vis
κ°μ₯ μ μ©ν λκΈ
λ€μκ³Ό κ°μ΄
del vis
μΆκ° :