IntelRealSense d415深度相机拍照制作数据集python脚本

IntelRealSense d415深度相机拍照制作数据集python脚本

最近想做一个阴影数据集,手上d415相机像素好一点,就用来调用拍照啦。
上源码:

import pyrealsense2 as rs
import numpy as np
import cv2

# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 1280, 720, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 1280, 720, rs.format.bgr8, 30)

# Start streaming
pipeline.start(config)

# 每种样本50个图像,一共八种,50*8=400个初始图像,之后再做数据增广
filePath = "/home/qyt/DataSet/Shadow/"
id = "1"

i = 0
j=0
#只是采集图像,不用深度信息
while  i<=50:

        frames = pipeline.wait_for_frames()
        color_frame = frames.get_color_frame()
        # Convert images to numpy arrays 把图像转换为numpy data
        color_image = np.asanyarray(color_frame.get_data())

        cv2.namedWindow('MyD415')
        cv2.imshow('MyD415', color_image)

        key = cv2.waitKey(0)


        if i < 10:
            imageName = "shadow" + id + "_0" + str(i) + ".jpg"

        else:
            imageName = "shadow" + id + "_" + str(i) + ".jpg"

        imagePath = filePath + imageName



        if key & 0xFF == ord('q') or key == 27:
            cv2.destroyAllWindows()
            pipeline.stop()
            break
        elif key == ord('s'):  # 按下s键时保存并退出
            cv2.imwrite(imagePath, color_image)
            i += 1
            #cv2.destroyAllWindows()

        j=j+1
        #方便看保存到第几张图了
        print("iter:",j,"i:", i)


  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值