Ejemplo n.º 1
0
def find_camera():
	global camera
	
	cidx = CAMERA_START_INDEX

	while True :
		try:
			if camera:
				del(camera)

			print(cidx)

			camera = Camera(cidx, 10)
			camera.set(3, CAMERA_WIDTH)
			camera.set(4, CAMERA_HEIGHT)
			camera.set(5, 20)

			cidx = cidx + 1
			if cidx > CAMERA_MAX_INDEX:
				cidx = CAMERA_START_INDEX

			if camera == None:
				print("none")

			im = camera.get_image()

			if im == None:
				continue

			h,w,_ = im.shape

			print("%d, %d" % (h, w))

			if w < 1 or h < 1:
				continue
		
			if SHOW_IMAGE :
				cv2.imshow("image", im)

			break

		except (KeyboardInterrupt, SystemExit):
			sys.exit()
		except:
			time.sleep(0.01)
			pass
Ejemplo n.º 2
0
camera.set(3, CAMERA_WIDTH)
camera.set(4, CAMERA_HEIGHT)
camera.set(5, 20)

NetworkTable.setIPAddress("roboRIO-6731-FRC.local")
NetworkTable.setClientMode()
NetworkTable.initialize()

vtable = NetworkTable.getTable("vision")

NetworkTable.addConnectionListener(connectionListener, immediateNotify=True)

if SHOW_IMAGE :
        cv2.startWindowThread()
        cv2.namedWindow("image")
        cv2.imshow("image", camera.get_image())

# main

while True:
	st = time.time()

	img = camera.capture()

	if USE_VISION:
		img,a1,a2,c1,c2,ct = finder.findPoints(img, SHOW_IMAGE)

		fovh = 30.686  # degrees
		x = 8.0 * 0.0254  # distance between tapes (meters)
		w = 1.0  # meters
		h = w * CAMERA_HEIGHT / CAMERA_WIDTH  # meters
Ejemplo n.º 3
0
import cv2
from networktables import NetworkTables

from vision.camera import Camera
import vision.finder as finder


camera = Camera(0, 10)

img=camera.get_image()

img = finder.findPoints(img)

cv2.imshow("image", img)
cv2.waitKey(0)

cv2.destroyAllWindows()

del(camera)