Last active
January 13, 2022 12:10
-
-
Save musimab/44c287e225d8e4b02d0aeccd525d472f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pyrealsense2 as rs | |
from matplotlib import pyplot as plt | |
import cv2 | |
from realsense_depth import DepthCamera | |
from utils import createPointCloudO3D | |
from utils import depth2PointCloud | |
from utils import write_point_cloud | |
resolution_width, resolution_height = (640, 480) | |
clip_distance_max = 3.500 ##remove from the depth image all values above a given value (meters). | |
def main(): | |
Realsensed435Cam = DepthCamera(resolution_width, resolution_height) | |
depth_scale = Realsensed435Cam.get_depth_scale() | |
while True: | |
ret , depth_raw_frame, color_raw_frame = Realsensed435Cam.get_raw_frame() | |
if not ret: | |
print("Unable to get a frame") | |
points_xyz_rgb = depth2PointCloud(depth_raw_frame, color_raw_frame, depth_scale, clip_distance_max) | |
create_point_cloud_file2(points_xyz_rgb,"room2.ply") | |
color_frame = np.asanyarray(color_raw_frame.get_data()) | |
depth_frame = np.asanyarray(depth_raw_frame.get_data()) | |
cv2.imshow("Frame", color_frame ) | |
key = cv2.waitKey(1) & 0xFF | |
if key == ord('q'): | |
cv2.imwrite("frame_color.png", color_frame) | |
plt.imsave("vazo.png", depth_frame) | |
break | |
Realsensed435Cam.release() # release rs pipeline | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment