Win10 RealSense L515 SDK官网下载与安装教程

背景介绍

首次接触使用Inter RealSense L515这一款英特尔的实感激光雷达摄像头网上大部分的资料都是安装在ros系统中或者是Ubuntu系统中的,少有资料是是关于安装在win10系统中的,于是在自己的摸索过程中遇到的问题做一个总结,以便后来者少踩一些我以踩过之坑。撰写此博客以备不时之需。

1.下载SDK安装包

从官网可知在我学习使用Inter RealSense L515已经停产,目前已经离其停产许久但实际上官方仍有其SDK的安装包。在下载SDK的安装包时也遇到了一些问题

搜索l515sdk,选择sdk2.0

可以看到Intel RealSense SDK 2.0可以在Windows  Linux/Ubuntu macOS Android OS中安装由于目前我使用的是Windows所以选择Windows的图标可以见到在我写这篇博客时sdk的版本出到了beta v2.56.1但是强调一点一定不要下载这个版本。

我一开始不知道就下载了这个版本但是最后使用时发现如下图一样怎么都无法连接摄像头,从设备管理器中可以看到摄像头确实已经连接到了电脑上但是Intel.RealSense.Viewer中始终看不到图像,同时也确定了我是用官方的数据线连接的也是usb3.2,但是不管怎么调整都无法使用,最后换成v2.54.2.5684就好了(也有可能是我的摄像头的固件问题)

不知道官网下载为啥有时候可以打开有时候又无法打开,所以下面的连接采用gethub加速计划可能可以选择发行版然后向下划找到v2.54.2
Release Intel® RealSense™ SDK 2.0 (v2.54.2) · IntelRealSense/librealsenseicon-default.png?t=O83Ahttps://github.com/IntelRealSense/librealsense/releases/tag/v2.54.2

如果还是无法打开可以使用别的方法下载,下面是我上传的网盘资料,如果实在打不开可以试试这个,不过时间久了可能会被我清理了


这里可以通过百度网盘链接下载(如果时间久了可能会失效):

通过网盘分享的文件:Intel.RealSense.SDK-WIN10-2.54.2.5684.exe
链接: https://pan.baidu.com/s/19rgQv1SsteBcyWhVmZPhsg?pwd=4anx 提取码: 4anx 

我这里选择intel.RealSense.SDK-WIN10-2.54.2.5684.exe如果需要别的可以下载别的就我使用情况而言intel.RealSense.SDK-WIN10-2.54.2.5684.exe安装的东西比较全,如果只希望使用Intel.RealSense.Viewer观察也可以只下载那个

这个东西安装就是傻瓜式操作一直NEXT就好了,这里就不放图片了,等他安装好后就可以看到这两个软件了,我主要是使用右边的进行使用,如果看到如右图样子的这个说明可以正常使用了,只要把三个off改成on摄像头就可以使用了。

2.python使用用摄像头

通过pycharm使用摄像头时需要安装单独的包,即pyrealsense2此时的版本也要选择2.54.2.5684要不然使用时就会报错
Traceback (most recent call last):
  File "E:\PycharmProjects\PycharmProjects3\main8.py", line 10, in <module>
    pipeline.start(config)
RuntimeError: No device connected

如果成功就可以看到一幅rgb图和一幅深度图像

3.示例代码

下面是示例代码(来源于官方对齐和背景移除的代码):

使用前要有opencv-python(cv2)、numpy、pyrealsense2三个库

## License: Apache 2.0. See LICENSE file in root directory.
## Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#####################################################
##              Align Depth to Color               ##
#####################################################

# First import the library
import pyrealsense2 as rs
# Import Numpy for easy array manipulation
import numpy as np
# Import OpenCV for easy image rendering
import cv2

# Create a pipeline
pipeline = rs.pipeline()

# Create a config and configure the pipeline to stream
#  different resolutions of color and depth streams
config = rs.config()

# Get device product line for setting a supporting resolution
pipeline_wrapper = rs.pipeline_wrapper(pipeline)
pipeline_profile = config.resolve(pipeline_wrapper)
device = pipeline_profile.get_device()
device_product_line = str(device.get_info(rs.camera_info.product_line))

found_rgb = False
for s in device.sensors:
    if s.get_info(rs.camera_info.name) == 'RGB Camera':
        found_rgb = True
        break
if not found_rgb:
    print("The demo requires Depth camera with Color sensor")
    exit(0)

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

# Start streaming
profile = pipeline.start(config)

# Getting the depth sensor's depth scale (see rs-align example for explanation)
depth_sensor = profile.get_device().first_depth_sensor()
depth_scale = depth_sensor.get_depth_scale()
print("Depth Scale is: " , depth_scale)

# We will be removing the background of objects more than
#  clipping_distance_in_meters meters away
clipping_distance_in_meters = 1 #1 meter
clipping_distance = clipping_distance_in_meters / depth_scale

# Create an align object
# rs.align allows us to perform alignment of depth frames to others frames
# The "align_to" is the stream type to which we plan to align depth frames.
align_to = rs.stream.color
align = rs.align(align_to)

# Streaming loop
try:
    while True:
        # Get frameset of color and depth
        frames = pipeline.wait_for_frames()
        # frames.get_depth_frame() is a 640x360 depth image

        # Align the depth frame to color frame
        aligned_frames = align.process(frames)

        # Get aligned frames
        aligned_depth_frame = aligned_frames.get_depth_frame() # aligned_depth_frame is a 640x480 depth image
        color_frame = aligned_frames.get_color_frame()

        # Validate that both frames are valid
        if not aligned_depth_frame or not color_frame:
            continue

        depth_image = np.asanyarray(aligned_depth_frame.get_data())
        color_image = np.asanyarray(color_frame.get_data())

        # Remove background - Set pixels further than clipping_distance to grey
        grey_color = 153
        depth_image_3d = np.dstack((depth_image,depth_image,depth_image)) #depth image is 1 channel, color is 3 channels
        bg_removed = np.where((depth_image_3d > clipping_distance) | (depth_image_3d <= 0), grey_color, color_image)

        # Render images:
        #   depth align to color on left
        #   depth on right
        depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
        images = np.hstack((bg_removed, depth_colormap))

        cv2.namedWindow('Align Example', cv2.WINDOW_NORMAL)
        cv2.imshow('Align Example', images)
        key = cv2.waitKey(1)
        # Press esc or 'q' to close the image window
        if key & 0xFF == ord('q') or key == 27:
            cv2.destroyAllWindows()
            break
finally:
    pipeline.stop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值