Update: python-rerun-visualize
Open markdown file
Update
Edit Content
## Rerun Python Görselleştirme ### Rerun Computer vision için geliştirilmiş, Rust, Python, Cpp uçları olan pakettir. Farklı OS'lar için native olarak Web için farklı bir renderer'a sahiptir. ### İpuçları #### Bağlantılar Ros'taki TF ağaçları mantığına benzer şekilde, her bir obje tanımı için bir path' tanımlanır. Örneğin /world/object1, bu object1'in world'e göre relatif durumunu açıklar. #### Değişim Animasyonlu bir şekilde gösterilmek istendiğinde yani işin içerisine t (zaman) girdiğinde rerun syntax'ı yeni durumları overwrite etmek ister. Yani kümülatif bir girdi parçası değil t zamanındaki relatif durum toplamlarını bekler. #### Zaman Zaman farklı şekillerde ele alınabilir. Aşağıdaki örnekte busy-wait yaklaşımı kullanılmıştır. İterated bir şekilde de sağlanabilir. #### UI Farklı paneller eklemek için rerun içerisindeki blueprint kısmını kullanır. Bir daire ve etrafında 3 boyutta daire çizen bir dikdörtgen (Aynı zamanda dönen) Örneği ``` import math import rerun as rr import rerun.blueprint as rrb import numpy as np import time as pytime rr.init("example", spawn=True) rr.log("/", rr.ViewCoordinates.RIGHT_HAND_Z_UP, static=True) time = 0.0 rr.set_time_seconds("sim_time", seconds=time) # Center Elipsoid rr.log( "/world/center", rr.Ellipsoids3D( centers=[[0,0,0]], half_sizes=[[0.5,0.5,0.5]], colors=[[0,120,255]], fill_mode="solid" ), static=True ) # edge rectangle rr.log( "/world/edge", rr.Boxes3D( centers=[[0.0, 0.0, 0.0]], # <- burada 0,0,0 olmalı half_sizes=[[0.2, 0.2, 0.4]], fill_mode="solid", ), static=True ) # saniyede 20 # animation target_dt = 0.02 start = pytime.time() animation_duration = 10 coeff_orbital_x_radius = 1.5 coeff_orbital_y_radius = 2 coeff_orbital_z_radius = 3 animation_start = pytime.time() while True: if animation_duration <= pytime.time() - animation_start: print("Animation Ended") break frame_start = pytime.time() time_sim = frame_start - start rr.set_time_seconds("sim_time", seconds=time_sim) degree = 90 * time_sim x_translation = coeff_orbital_x_radius * math.sin(time_sim * math.pi * 2) # value olarak radyan verilir y_translation = coeff_orbital_y_radius * math.cos(time_sim * math.pi * 2) # value olarak radyan verilir z_translation = coeff_orbital_z_radius * math.sin(time_sim * math.pi * 2) # value olarak radyan verilir rr.log( "/world/edge", rr.Transform3D( translation=[x_translation, y_translation, z_translation], rotation=rr.RotationAxisAngle( axis=(1, 1, 1), degrees=degree, ), ) ) # busy wait while pytime.time() - frame_start < target_dt: pass ``` **Image Örneği** ``` def image_3d(): rr.init("image_example", spawn=True) rr.log("/", rr.ViewCoordinates.RIGHT_HAND_Z_UP, static=True) rr.send_blueprint( rrb.Blueprint( rrb.Spatial3DView(origin="/world") ) ) # Image img = np.ones((100, 100, 3), dtype=np.uint8) * 255 img[30:70, 30:70] = [255, 0, 0] # Image 2d oldugu için 3d düzelmde göstermek istendiğinde onu bir mesh ile # temsil etmeliyiz. rr.log( "/world/image_plane", rr.Mesh3D( vertex_positions=[ [-1, -1, 0], [ 1, -1, 0], [ 1, 1, 0], [-1, 1, 0], ], vertex_texcoords=[ [0, 0], [1, 0], [1, 1], [0, 1], ], triangle_indices=[ [0,1,2], [0,2,3], ], albedo_texture=img, ), ) def image_2d(): img = cv2.imread("/home/enes/Desktop/somelearning/rerun/example.jpg") rr.init("image_example_2d", spawn=True) # 🔵 2D layout blueprint rr.send_blueprint( rrb.Blueprint( rrb.Vertical( rrb.Horizontal( rrb.Spatial2DView(origin="image/rgb"), rrb.Spatial2DView(origin="image/gray"), ), rrb.Spatial2DView(origin="image/canny"), ) ) ) # Log the original image rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) rr.log("image/rgb", rr.Image(rgb)) # Convert to grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) rr.log("image/gray", rr.Image(gray)) # Run the canny edge detector canny = cv2.Canny(gray, 50, 200) rr.log("image/canny", rr.Image(canny)) image_2d() ``` **Points Örneği** ``` import rerun as rr rr.log("/", rr.ViewCoordinates.RIGHT_HAND_Z_UP, static=True) rr.init("rerun_example_points3d", spawn=True) positions = [[0,0,1],[1,0,0],[0,1,0]] colors = [[255,0,0],[0,0,255],[0,255,0]] radii = [0.01,0.02,0.03] rr.log("points", rr.Points3D(positions, colors=colors, radii=radii)) ``` **Skaler Değer** ``` rr.log("metrics/frame_index", rr.Scalar(frame_index)) ```
Save
Remove: python-rerun-visualize
Delete Note