Items with no label
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
3338 Discussions

generate pointclouds and draw it in python

tguan
New Contributor I
1,634 Views

# encoding:utf-8

 

import numpy as np

import cv2

import pyrealsense2 as rs

pipeline = rs.pipeline()

config = rs.config()

config.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 30)

config.enable_stream(rs.stream.depth,640, 480, rs.format.z16, 30)

# 深度存储为每像素一个无符号 16 位整数,在摄像机特定单位中线性映射到深度

 

 

pipeline.start(config)

while True:

 

frames = pipeline.wait_for_frames()

color = frames.get_color_frame()

depth = frames.get_depth_frame()

if (not depth) or (not color):

 

print("Color or Depth not available!")

break

# color

 

color_img = np.asanyarray(color.get_data())

color_img = cv2.cvtColor(color_img, cv2.COLOR_BGR2RGB)

# depth

c = rs.colorizer()

colorized_depth = np.asanyarray(c.colorize(depth).get_data())

# pointclouds I HAVE PROBLEMS HERE??????

pc = rs.pointcloud()

points = pc.calculate(depth)

pc.map_to(color)

app_state.tex.upload(color) ?

draw_pointcloud(app, app_state, points) How to show the pointcloud?

cv2.imshow("color",color_img)

cv2.imshow("depth",colorized_depth)

if cv2.waitKey(1) & 0xFF == ord('q'):

 

break

 

pipeline.stop()
0 Kudos
1 Reply
AlHill
Super User
692 Views

Only one thread please. Stay with your other thread:

Doc

0 Kudos
Reply