コード例 #1
0
	def run(self):
		sc_logger.text(sc_logger.GENERAL, 'running {0}'.format(self.name()))

		#start a video capture
		sc_video.start_capture(self.camera_index)

		#create an image processor
		detector = CircleDetector()

		#create a queue for images
		imageQueue = Queue.Queue()

	 	while True:

	 		#update how often we dispatch a command
	 		sc_dispatcher.calculate_dispatch_schedule()

	 		# grab an image
			capStart = current_milli_time()
			frame = sc_video.get_image()
			capStop = current_milli_time()

	 		
	 		#update capture time
	 		sc_dispatcher.update_capture_time(capStop-capStart)


	 		
			#Process image
			#We schedule the process as opposed to waiting for an available core
			#This brings consistancy and prevents overwriting a dead process before
			#information has been grabbed from the Pipe
			if sc_dispatcher.is_ready():
				#queue the image for later use: displaying image, overlays, recording
				imageQueue.put(frame)

				#the function must be run directly from the class
				sc_dispatcher.dispatch(target=detector.analyze_frame, args=(frame,None,))
	 			


	 		#retreive results
	 		if sc_dispatcher.is_available():
	 			#results of image processor
	 			results = sc_dispatcher.retreive()
	 			# get image that was passed with the image processor
	 			img = imageQueue.get()
	 			#overlay gui
	 			rend_Image = gui.add_target_highlights(img, results[3])
	 			#show/record images
	 			sc_logger.image(sc_logger.RAW, img)
	 			sc_logger.image(sc_logger.GUI, rend_Image)
コード例 #2
0
	def run(self):
		sc_logger.text(sc_logger.GENERAL, 'running {0}'.format(self.name()))

		#start a video capture
		'''
		if(self.simulator):
			sc_logger.text(sc_logger.GENERAL, 'Using simulator')
			sim.set_target_location(veh_control.get_home())
			#sim.set_target_location(Location(0,0,0))

		else:'''

		sc_video.start_capture(self.camera_index)

		#camera = balloon_video.get_camera()
        	video_writer = balloon_video.open_video_writer()

		#create an image processor
		detector = CircleDetector()

		#create a queue for images
		imageQueue = Queue.Queue()

		#create a queue for vehicle info
		vehicleQueue = Queue.Queue()

	 	while veh_control.is_connected():

			#get info from autopilot
			location = veh_control.get_location()
			attitude = veh_control.get_attitude()

			print location
			print attitude


			# Take each frame
            		#_, frame = camera.read()
			#update how often we dispatch a command
		 	sc_dispatcher.calculate_dispatch_schedule()
			# grab an image
			capStart = current_milli_time()
			frame = sc_video.get_image()
			capStop = current_milli_time()
			#frame = sc_video.undisort_image(frame)
			#cv2.imshow('frame',frame)
			# write the frame
            		video_writer.write(frame)
			#update capture time
			sc_dispatcher.update_capture_time(capStop-capStart)

			#Process image
			#We schedule the process as opposed to waiting for an available core
			#This brings consistancy and prevents overwriting a dead process before
			#information has been grabbed from the Pipe
			if sc_dispatcher.is_ready():
				#queue the image for later use: displaying image, overlays, recording
				imageQueue.put(frame)
				#queue vehicle info for later use: position processing
				vehicleQueue.put((location,attitude))

				#the function must be run directly from the class

				#######
				sc_dispatcher.dispatch(target=balloon_finder.analyse_frame, args=(frame,))
	 			


			 #retreive results
			if sc_dispatcher.is_available():
			 	sc_logger.text(sc_logger.GENERAL, 'Frame {0}'.format(self.frame_count))
			 	self.frame_count += 1


			 	#results of image processor
			 	results = sc_dispatcher.retreive()
			 	# get image that was passed with the image processor
			 	img = imageQueue.get()
			 			#get vehicle position that was passed with the image processor
			 	location, attitude = vehicleQueue.get()
			
					
			 	#overlay gui
			 	#rend_Image = gui.add_target_highlights(img, results[3])


			 	#show/record images
			 	sc_logger.image(sc_logger.RAW, img)
			 	#sc_logger.image(sc_logger.GUI, rend_Image)
			
			 	#display/log data
			 	sc_logger.text(sc_logger.ALGORITHM,'found: {0} x: {1} y: {2} radius: {3}'.format(results[0],results[1],results[2],results[3]))
コード例 #3
0
 def get_frame(self):
     if (self.simulator):
         return sim.get_frame()
     else:
         return sc_video.get_image()
コード例 #4
0
	def get_frame(self):
		if(self.simulator):
			return sim.get_frame()
		else:
			return sc_video.get_image()
コード例 #5
0
 def get_frame(self):
     frame = sc_video.get_image()
     return frame
コード例 #6
0
 def get_frame(self):
     frame = sc_video.get_image()
     return frame