Upload project files
This commit is contained in:
32
stream.py
Normal file
32
stream.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import cv2
|
||||
|
||||
# Stream URL
|
||||
stream_url = "https://ls.tkchopin.pl:9043/live/wejherowo_skrzyzowanie_rybacka_k6_static.stream/playlist.m3u8"
|
||||
|
||||
# Open video stream with reduced buffer size for low latency
|
||||
cap = cv2.VideoCapture(stream_url)
|
||||
cap.set(cv2.CAP_PROP_BUFFERSIZE, 1) # Reduce frame buffering for lower latency
|
||||
|
||||
if not cap.isOpened():
|
||||
print("Error: Could not open stream")
|
||||
else:
|
||||
# Read and discard old frames (capture only the latest available one)
|
||||
for _ in range(5): # Adjust this number for better latency
|
||||
ret, frame = cap.read()
|
||||
|
||||
if ret:
|
||||
# Define the cropping region (modify these values as needed)
|
||||
x, y, width, height = 640, 0, 640, 130 # Upper-right corner
|
||||
|
||||
# Crop the frame
|
||||
cropped_frame = frame[y:y+height, x:x+width]
|
||||
|
||||
# Save the cropped frame
|
||||
cv2.imwrite("cropped_frame.jpg", cropped_frame)
|
||||
print("Cropped frame saved as 'cropped_frame.jpg'")
|
||||
else:
|
||||
print("Error: Could not capture frame")
|
||||
|
||||
# Release resources
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
Reference in New Issue
Block a user