本文整理汇总了Python中scanner.Scanner.switch_camara方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.switch_camara方法的具体用法?Python Scanner.switch_camara怎么用?Python Scanner.switch_camara使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.switch_camara方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import switch_camara [as 别名]
class Controller(object):
"""Docstring for Controller. """
def __init__(self, settings):
"""TODO: to be defined1. """
self.cubo = Cubo()
self.cuboescaneado = CuboEscaneado()
self.settings = settings
self.scanner = Scanner(self.cubo, self.settings)
self.robot = Robot()
self.solver = Solver(self.cubo)
# camara a of (primero true y luego switch)
def set_view(self, view):
self.view = view
self.view.setImg(cv2.imread('novideo.png'))
def change_setting(self, widget, scroll, value):
print "en change setting"
print "rango ", widget.get_name()
print "scrll ", scroll
print "value ", value
value = int(value)
self.settings[widget.get_name()] = value
def showSettings(self):
result = gtk.RESPONSE_CANCEL
settings = Settings()
for w in settings:
print w
widget = self.view.wTree.get_widget(w)
widget.set_value(settings[w])
print 'on_'+w+'_change_value'
#widget.connect('on_'+w+'_change_value', self.change_setting)
widget.connect('change_value', self.change_setting)
print "Muestro"
#run the dialog and store the response
result = self.view.dlg_settings.run()
if (result==gtk.RESPONSE_OK):
#get the value of the entry fields
print "grabaria la configuracion"
self.settings.save()
elif (result==gtk.RESPONSE_CANCEL):
print "cancelo"
self.settings.load()
else:
print "Result = ",result
#we are done with the dialog, destroy it
self.view.dlg_settings.hide()
#return the result
return result
def camara_off(self):
self.view.setTxtSolver("Camara apagada")
self.scanner.reset()
time.sleep(2/24.0) # por si esta pendiente el thread
self.view.setImg(cv2.imread('novideo.png'))
def switch_camara(self):
self.scanner.switch_camara()
if self.scanner.activo:
threading.Thread(target=self.scanner_thread, args=(self.scanner,)).start()
else:
self.camara_off()
def resolver(self):
if self.solver.is_running():
logging.debug("Aguanta! Estoy en ello!")
pass
else:
print self.solver
self.solver.scramble(30)
#obj = ObjetoRedirect(s)
threading.Thread(target=self.resolver_thread, args=(self.solver,)).start()
# threads
def scanner_thread(self, scanner, data=None):
# pillo el primer frame para no entrar en la chisma
#self.cuboescaneado.carasescaneadas = 0
self.robot.reset()
scanner.reset()
scanner.activar()
self.view.setTxtSolver("Comienza escaneo")
print self.scanner.activo
while self.scanner.activo:
self.robot.reset()
#scanner.reset()
#.........这里部分代码省略.........