-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.py
34 lines (29 loc) · 1.04 KB
/
stream.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Created by Alex Pereira
# Import Libraries
import ntcore
import numpy as np
from cscore import CameraServer as CS
# Get a default network table
nt = ntcore.NetworkTableInstance.getDefault()
nt.setServerTeam(2199)
nt.startClient3(__file__)
# Creates the Streaming Class
class Streaming:
def __init__(self, camNum: int, path: str = None) -> None:
"""
Constructor for the Streaming class.
@param Camera Number
@param path: It can be found on Linux by running "find /dev/v4l"
"""
# Creates a CameraServer
CS.enableLogging()
# Defines the resolution
streamRes = (640, 480)
# Captures from a specified USB Camera on the system
if (path is not None):
# If path is known, use the path
camera = CS.startAutomaticCapture(name = "Camera" + str(camNum), path = path)
else:
# Path is unknown, use the camera number
camera = CS.startAutomaticCapture(dev = camNum)
camera.setResolution(streamRes[0], streamRes[1])