|
3 | 3 | import cv2
|
4 | 4 | from ultralytics import YOLO
|
5 | 5 |
|
6 |
| -model = YOLO('yolov8s.pt') |
| 6 | +model = YOLO('model.pt') |
7 | 7 | print(model.names)
|
8 | 8 | webcamera = cv2.VideoCapture(0)
|
9 | 9 | # webcamera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
|
|
22 | 22 | webcamera.release()
|
23 | 23 | cv2.destroyAllWindows()
|
24 | 24 |
|
| 25 | +# For Realsense camera |
| 26 | + # def initialize_realsense(): |
| 27 | + # import pyrealsense2 as rs |
| 28 | + # pipeline = rs.pipeline() |
| 29 | + # camera_aconfig = rs.config() |
| 30 | + # camera_aconfig.enable_stream(rs.stream.depth, *config.DEPTH_CAMERA_RESOLUTION, rs.format.z16, config.DEPTH_CAMERA_FPS) |
| 31 | + # camera_aconfig.enable_stream(rs.stream.color, *config.COLOR_CAMERA_RESOLUTION, rs.format.bgr8, config.COLOR_CAMERA_FPS) |
| 32 | + # pipeline.start(camera_aconfig) |
| 33 | + # return pipeline |
| 34 | +# try: |
| 35 | +# # Try to initialize RealSense Camera |
| 36 | +# camera = initialize_realsense() |
| 37 | +# get_frame = get_frame_realsense |
| 38 | +# except Exception as e: |
| 39 | +# print("RealSense camera not found, using default webcam.") |
| 40 | +# camera = initialize_webcam() |
| 41 | +# get_frame = get_frame_webcam |
| 42 | + |
| 43 | +# Function to get frames from RealSense |
| 44 | +# def get_frame_realsense(pipeline): |
| 45 | +# import pyrealsense2 as rs |
| 46 | +# frames = pipeline.wait_for_frames() |
| 47 | +# depth_frame = frames.get_depth_frame() |
| 48 | +# color_frame = frames.get_color_frame() |
| 49 | +# if not depth_frame or not color_frame: |
| 50 | +# return None, None |
| 51 | +# depth_image = np.asanyarray(depth_frame.get_data()) |
| 52 | +# color_image = np.asanyarray(color_frame.get_data()) |
| 53 | +# return depth_image, color_image |
| 54 | + |
| 55 | +# # Function to get frame from webcam |
| 56 | +# def get_frame_webcam(cap): |
| 57 | +# ret, frame = cap.read() |
| 58 | +# return None, frame if ret else None |
0 commit comments