Example #1
0
def setup():
	global cam, theBlobDetection, numPixels, backgroundPixels, newFrame, mode, bg, img
	mode = 0
	size(640/2, 480/2)
	cameras = Capture.list()
	
	if len(cameras) == 0:
		print("There are no cameras available for capture.")
		exit()
	else:
		print("Available cameras:")
		for i,camera in enumerate(cameras):
			print(i,camera)
	
	# The camera can be initialized directly using an 
	# element from the array returned by list():
	cam = Capture(this, cameras[7])
	cam.start()
	newFrame = False	# is the frame ready yet?
	
	# BlobDetection
	img = PImage(width,height)
	bg = PImage(width,height)  
	theBlobDetection = BlobDetection(img.width, img.height)
	theBlobDetection.setPosDiscrimination(True)
	theBlobDetection.setThreshold(0.2) # will detect bright areas whose luminosity > 0.2f;
  
  	# Background subtraction
	numPixels = width * height;
	backgroundPixels = [0]*numPixels  # Create a list to store the background image
	loadPixels();
Example #2
0
def setup():
	global cam
	size(640, 480)
	cameras = Capture.list()
	
	if len(cameras) == 0:
		print("There are no cameras available for capture.")
		exit()
	else:
		print("Available cameras:")
		for i,camera in enumerate(cameras):
			print(i,camera)
	
	# The camera can be initialized directly using an 
	# element from the array returned by list():
	cam = Capture(this, cameras[1])
	cam.start()