Beispiel #1
0
def main():
	print('Initializing NetworkTables for peg')
	NetworkTables.setClientMode( )
	NetworkTables.setIPAddress( '10.40.96.2' )
	NetworkTables.initialize( )

	print('Creating peg video capture ')
	global pegCapture
	pegCapture = cv2.VideoCapture("/dev/gear_camera")
	pegCapture.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
	pegCapture.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
	capture.set(cv2.CAP_PROP_FPS, 15)

	print('Creating peg pipeline')
	pegPipeline = PegPipeline()
	
	try:
		print("Starting peg server")
		server = ThreadedHTTPServer(('0.0.0.0', 5800), CamHandler)
		
		print('Running peg pipeline')
		table = NetworkTables.getTable('/vision/')
		while True:
			pegOk, pegFrame = pegCapture.read()
			if pegOk:
				print("ok")
				if table.getNumber('gear_camera_mode') == 0:
					print('Switching peg to GRIP mode')
					if Exposure.getExposure("/dev/gear_camera") != 10:
						Exposure.setExposure(10, "/dev/gear_camera")
					while table.getNumber('gear_camera_mode') == 0:
						pegPipeline.process(pegFrame)
						extra_processing(pegPipeline)
				else:
					print('Switching peg to stream mode')
					if Exposure.getExposure("/dev/gear_camera") != 100:
						Exposure.setExposure(100, "/dev/gear_camera")
					while table.getNumber('gear_camera_mode') == 1:
						server.handle_request()

	except KeyboardInterrupt:
		pegCapture.release()
		server.socket.close()
Beispiel #2
0
"""
Ctrl-Z FRC Team 4096
FIRST Robotics Competition
Code for use on Raspberry Pi coprocessor
[email protected]
"""

import sys
from exposure import Exposure
"""
Sets the exposure of /dev/video0 to the first arg passed or 10 if no args are passed
If 2 args are passed it sets the exposure of arg 2 to arg 1
"""
if len(sys.argv) < 3:
    print("Exposure is {0}".format(Exposure.getExposure()))
    Exposure.setExposure(10 if len(sys.argv) < 2 else sys.argv[1])
    print("Exposure is now {0}".format(Exposure.getExposure()))
else:
    print("Exposure is {0}".format(Exposure.getExposure()))
    Exposure.setExposure(10 if len(sys.argv) < 2 else sys.argv[1])
    print("Exposure is now {0}".format(Exposure.getExposure()))