import cv2
import pyrealsense2 as rs
import numpy as np
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
profile = pipeline.start(config)
camera = cv2.VideoCapture(0)
flag = camera.isOpened()
index = 0
imgname = 0
while (True):
index += 1
reg, img = camera.read()
cv2.imshow('Camera', img)
if index == 2:
imgname += 1
fname = str(imgname) + '.jpg'
cv2.imwrite('C:/Users/yons/Desktop/2020.9.11/img' + fname, img)
print("saved sucessful")
index = 0