Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bambulabs_api/camera_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/python3

import cv2

import base64
import struct
import socket
Expand Down Expand Up @@ -167,3 +169,25 @@ def retriever(self):
time.sleep(5)
logging.info("Reconnecting...")
continue


class RTSPSCamera:
"""Camera Client for X1"""
def __init__(
self,
hostname: str,
access_code: str,
port: int = 322,
username: str = 'bblp'
) -> None:
self.rtsps_uri = f"rtsps://{username}:{access_code}@{hostname}:{port}/streaming/live/1" # noqa: E501

def start(self):
self.cap = cv2.VideoCapture(self.rtsps_uri)

def get_frame(self):
_, frame = self.cap.read()
return frame

def stop(self):
self.cap.release()
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies:
- webcolors
- pip:
- paho_mqtt
- pillow
- pillow
- opencv-python
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
dependencies = [
"paho-mqtt>=2.0.0",
"pillow>=11.0.0",
"opencv-python>=4.10.0",
]

[project.urls]
Expand All @@ -31,3 +32,4 @@ Issues = "https://github.com/BambuTools/bambulabs_api/issues"
python = "^3.10"
paho-mqtt = "^2.0.0"
pillow = "^11.0.0"
opencv-python = "^4.10.0"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ sphinx_rtd_theme
paho_mqtt
webcolors
pillow
opencv-python