当前位置: 首页>>代码示例>>Python>>正文


Python Camera.shutdown方法代码示例

本文整理汇总了Python中Camera.Camera.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.shutdown方法的具体用法?Python Camera.shutdown怎么用?Python Camera.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera.Camera的用法示例。


在下文中一共展示了Camera.shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HeliosController

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import shutdown [as 别名]
class HeliosController(Observable):
    md = None
    ds = None
    acl = None
    cam = None
    status = {}

    def __init__(self, conffile):
        Observable.__init__(self)
	cp = ConfigParser()
	cp.read(conffile)

	if not Globals.globSimulate:
	    wiringpi.wiringPiSetupGpio()

	self.md = MotorDriver([
		    cp.getint("MotorDriver", "LEFT_L"),
		    cp.getint("MotorDriver", "LEFT_R"),
		    cp.getint("MotorDriver", "RIGHT_L"),
		    cp.getint("MotorDriver", "RIGHT_R"),
		    cp.getint("MotorDriver", "VERTICAL_L"),
		    cp.getint("MotorDriver", "VERTICAL_R"),
		    ])
	self.md.start()

	self.ds = DistanceSensor(
		    cp.getint("DistanceSensor", "TRIGGER"),
		    cp.getint("DistanceSensor", "ECHO")
		    )
	self.ds.start()

	self.acl = AltitudeControlLoop(self.md, self.ds)

	self.update("MotorDriver", self.md)
	self.update("DistanceSensor", self.ds)
	self.update("AltitudeControlLoop", self.acl)

	self.md.subscribe(self.update)
	self.ds.subscribe(self.update)
	self.acl.subscribe(self.update)

	self.setCamera(False)
	#self.acl.debug = True
	#self.md.debug = True

    def shutdown(self):
	self.md.shutdown()
	self.md.join()
	self.ds.shutdown()
	self.ds.join()
	self.setCamera(False)

    def turnLeft(self):
        self.md.turnLeft()
    def turnRight(self):
        self.md.turnRight()

    def forward(self):
        self.md.forward()
    def backward(self):
        self.md.backward()
    def up(self):
        self.md.up()
    def down(self):
        self.md.down()

    def setSpeed(self, val):
    	self.md.setSpeed(val)
    def setAuto(self, val):
    	self.acl.setAuto(val)
    def setHeight(self, val):
    	self.acl.setHeight(val)
    def setForceDescent(self, val):
        self.acl.setForceDescent(val)
    def setSingleSteerMode(self, val):
    	self.md.setSingleSteerMode(val)

    def setCamera(self, val):
	if self.cam == None:
	    if val:
		print "HeliosController enabling camera"
		self.cam = Camera()
		self.cam.subscribe(self.updateImage)
		self.cam.start()
	    else:
		print "HeliosController tried to disable camera, but is not active"
	else:
	    if val:
		print "HeliosController tried to enable camera, but is already active"
	    else:
		print "HeliosController disabling camera"
		self.cam.shutdown()
		self.cam.join()
		self.cam = None
		self.status["cameraImage"] = "data:image/jpeg;base64," + base64.b64encode(open("nocam.jpg","rb").read())

	self.status["cameraActive"] = True if self.cam != None else False
	self.emit("HeliosController", self)

    def updateImage(self, id, cam):
#.........这里部分代码省略.........
开发者ID:StevenVanAcker,项目名称:ProjectHelios,代码行数:103,代码来源:HeliosController.py


注:本文中的Camera.Camera.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。