103
20.2 Specific Code
import
os
import
cv2
from
base_camera
import
import
numpy
as
np
import
time
import
threading
import
imutils
'''
Set the color of the line, 255 is the white line, 0 is the black line
'''
lineColorSet =
255
'''
Set the horizontal position of the reference, the larger the value, the lower, but not greater than the vertical resolution
of the video (default 480)
'''
linePos =
380
class
Camera(BaseCamera):
video_source = 0
def
__init__(self):
if
os.environ.get('OPENCV_CAMERA_SOURCE'):
Camera.set_video_source(int(os.environ['OPENCV_CAMERA_SOURCE']))
super(Camera, self).__init__()
@staticmethod
def
set_video_source(source):
Camera.video_source = source
@staticmethod
def
frames():
camera = cv2.VideoCapture(Camera.video_source)
if not
camera.isOpened():
raise
RuntimeError('Could not start camera.')
while True:
img = camera.read()
'''
BaseCamera
#Get the picture captured by the camera
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?