コード例 #1
0
    def __init__(self):

        status = 0
        ic = None
        print "hi"

        try:
            # Initializing the Ice run time
            ic = Ice.initialize()
            # Obtaining a proxy for the camera (obj. identity: address)
            obj = ic.stringToProxy('cameraA:default -h localhost -p 9999')

            # We get the first image and print its description
            cam = CameraPrx.checkedCast(obj)
            data = cam.getImageData("RGB8")
            if cam:
                print(data.description)
            else:
                print "no cam"

            # We define the windows that we're going to employ
            cv2.namedWindow("Live video")
            cv2.namedWindow("Processed image")
            cv2.moveWindow("Live video", 60, 60)
            cv2.moveWindow("Processed image", 800, 200)

            while (1):
                # It checks and returns the proxy
                cam = CameraPrx.checkedCast(obj)
                # We get the bytes that contain the image data and convert them
                # into an understandable image
                data = cam.getImageData("RGB8")
                img = self.data_to_image(data)
                # We process the image and display it
                img_proc = self.process_img(img)
                cv2.imshow("Live video", img)
                cv2.imshow("Processed image", img_proc)
                cv2.waitKey(25)

            cv2.destroyAllWindows()

        except:
            traceback.print_exc()
            status = 1

        if ic:

            try:
                ic.destroy()

            except:
                traceback.print_exc()
                status = 1

        sys.exit(status)
コード例 #2
0
    def __init__ (self):
        ''' Camera class gets images from live video and transform them
        in order to predict the digit in the image.
        '''
	print "\nLoading Keras model..."
        self.model = load_model("/home/dpascualhe/workspace/" + 
                                "2016-tfg-david-pascual/Net/Nets/0-1_tuned/" +
                                "net_4conv_patience5.h5")
        print "loaded\n"
        status = 0
        ic = None
        
        # Initializing the Ice run-time.
        ic = EasyIce.initialize(sys.argv)

        properties = ic.getProperties()
        self.lock = threading.Lock()
    
        try:
            # We obtain a proxy for the camera.
            obj = ic.propertyToProxy("Digitclassifier.Camera.Proxy")
            # We get the first image and print its description.
            self.cam = CameraPrx.checkedCast(obj)
            if self.cam:
                self.im = self.cam.getImageData("RGB8")
                self.im_height = self.im.description.height
                self.im_width = self.im.description.width
                print(self.im.description)
            else: 
                print("Interface camera not connected")
                    
        except:
            traceback.print_exc()
            exit()
            status = 1
コード例 #3
0
ファイル: catchTheTurtle.py プロジェクト: reysam93/TFG
	def connectToProxys(self):
		self.ic = Ice.initialize(sys.argv)

		# Contact to Extra
		Extra = self.ic.propertyToProxy('automata.ArDroneExtra.Proxy')
		if(not Extra):
			raise Exception('could not create proxy with Extra')
		self.ExtraPrx = ArDroneExtraPrx.checkedCast(Extra)
		if(not self.ExtraPrx):
			raise Exception('invalid proxy automata.ArDroneExtra.Proxy')
		print 'Extra connected'

		# Contact to CMDVel
		CMDVel = self.ic.propertyToProxy('automata.CMDVel.Proxy')
		if(not CMDVel):
			raise Exception('could not create proxy with CMDVel')
		self.CMDVelPrx = CMDVelPrx.checkedCast(CMDVel)
		if(not self.CMDVelPrx):
			raise Exception('invalid proxy automata.CMDVel.Proxy')
		print 'CMDVel connected'

		# Contact to Camera
		Camera = self.ic.propertyToProxy('automata.Camera.Proxy')
		if(not Camera):
			raise Exception('could not create proxy with Camera')
		self.CameraPrx = CameraPrx.checkedCast(Camera)
		if(not self.CameraPrx):
			raise Exception('invalid proxy automata.Camera.Proxy')
		print 'Camera connected'
コード例 #4
0
    def connectToProxys(self):
        self.ic = Ice.initialize(sys.argv)

        # Contact to Extra
        Extra = self.ic.propertyToProxy('automata.ArDroneExtra.Proxy')
        if (not Extra):
            raise Exception('could not create proxy with Extra')
        self.ExtraPrx = ArDroneExtraPrx.checkedCast(Extra)
        if (not self.ExtraPrx):
            raise Exception('invalid proxy automata.ArDroneExtra.Proxy')
        print 'Extra connected'

        # Contact to CMDVel
        CMDVel = self.ic.propertyToProxy('automata.CMDVel.Proxy')
        if (not CMDVel):
            raise Exception('could not create proxy with CMDVel')
        self.CMDVelPrx = CMDVelPrx.checkedCast(CMDVel)
        if (not self.CMDVelPrx):
            raise Exception('invalid proxy automata.CMDVel.Proxy')
        print 'CMDVel connected'

        # Contact to Camera
        Camera = self.ic.propertyToProxy('automata.Camera.Proxy')
        if (not Camera):
            raise Exception('could not create proxy with Camera')
        self.CameraPrx = CameraPrx.checkedCast(Camera)
        if (not self.CameraPrx):
            raise Exception('invalid proxy automata.Camera.Proxy')
        print 'Camera connected'
コード例 #5
0
ファイル: ardronepy1.1.py プロジェクト: reysam93/TFG
	def connectToProxys(self):
		self.ic = Ice.initialize(sys.argv)

		# Contact to camera
		camera = self.ic.propertyToProxy('automata.Camera.Proxy')
		if(not camera):
			raise Exception('could not create proxy with camera')
		self.cameraPrx = CameraPrx.checkedCast(camera)
		if(not self.cameraPrx):
			raise Exception('invalid proxy automata.Camera.Proxy')
		print 'camera connected'

		# Contact to pose3d
		pose3d = self.ic.propertyToProxy('automata.Pose3D.Proxy')
		if(not pose3d):
			raise Exception('could not create proxy with pose3d')
		self.pose3dPrx = Pose3DPrx.checkedCast(pose3d)
		if(not self.pose3dPrx):
			raise Exception('invalid proxy automata.Pose3D.Proxy')
		print 'pose3d connected'

		# Contact to cmd
		cmd = self.ic.propertyToProxy('automata.CMDVel.Proxy')
		if(not cmd):
			raise Exception('could not create proxy with cmd')
		self.cmdPrx = CMDVelPrx.checkedCast(cmd)
		if(not self.cmdPrx):
			raise Exception('invalid proxy automata.CMDVel.Proxy')
		print 'cmd connected'

		# Contact to extra
		extra = self.ic.propertyToProxy('automata.ArDroneExtra.Proxy')
		if(not extra):
			raise Exception('could not create proxy with extra')
		self.extraPrx = ArDroneExtraPrx.checkedCast(extra)
		if(not self.extraPrx):
			raise Exception('invalid proxy automata.ArDroneExtra.Proxy')
		print 'extra connected'

		# Contact to navdata
		navdata = self.ic.propertyToProxy('automata.Navdata.Proxy')
		if(not navdata):
			raise Exception('could not create proxy with navdata')
		self.navdataPrx = NavdataPrx.checkedCast(navdata)
		if(not self.navdataPrx):
			raise Exception('invalid proxy automata.Navdata.Proxy')
		print 'navdata connected'
コード例 #6
0
ファイル: ardronepy1.1.py プロジェクト: jorgevelap/TFG
    def connectToProxys(self):
        self.ic = Ice.initialize(sys.argv)

        # Contact to camera
        camera = self.ic.propertyToProxy('automata.Camera.Proxy')
        if (not camera):
            raise Exception('could not create proxy with camera')
        self.cameraPrx = CameraPrx.checkedCast(camera)
        if (not self.cameraPrx):
            raise Exception('invalid proxy automata.Camera.Proxy')
        print 'camera connected'

        # Contact to pose3d
        pose3d = self.ic.propertyToProxy('automata.Pose3D.Proxy')
        if (not pose3d):
            raise Exception('could not create proxy with pose3d')
        self.pose3dPrx = Pose3DPrx.checkedCast(pose3d)
        if (not self.pose3dPrx):
            raise Exception('invalid proxy automata.Pose3D.Proxy')
        print 'pose3d connected'

        # Contact to cmd
        cmd = self.ic.propertyToProxy('automata.CMDVel.Proxy')
        if (not cmd):
            raise Exception('could not create proxy with cmd')
        self.cmdPrx = CMDVelPrx.checkedCast(cmd)
        if (not self.cmdPrx):
            raise Exception('invalid proxy automata.CMDVel.Proxy')
        print 'cmd connected'

        # Contact to extra
        extra = self.ic.propertyToProxy('automata.ArDroneExtra.Proxy')
        if (not extra):
            raise Exception('could not create proxy with extra')
        self.extraPrx = ArDroneExtraPrx.checkedCast(extra)
        if (not self.extraPrx):
            raise Exception('invalid proxy automata.ArDroneExtra.Proxy')
        print 'extra connected'

        # Contact to navdata
        navdata = self.ic.propertyToProxy('automata.Navdata.Proxy')
        if (not navdata):
            raise Exception('could not create proxy with navdata')
        self.navdataPrx = NavdataPrx.checkedCast(navdata)
        if (not self.navdataPrx):
            raise Exception('invalid proxy automata.Navdata.Proxy')
        print 'navdata connected'