本文整理汇总了Python中naoqi.ALProxy.raiseEvent方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.raiseEvent方法的具体用法?Python ALProxy.raiseEvent怎么用?Python ALProxy.raiseEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.raiseEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
def main():
memory = ALProxy("ALMemory", NAO_IP, NAO_PORT)
basicVideoProcessing = BasicVideoProcessing()
basicVideoProcessing.connectToCamera()
track = (0,0,0,0)
term = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 1)
try:
while True:
img = basicVideoProcessing.getImageFromCamera()
if (img == None):
print "Img is empty"
break
else:
if basicVideoProcessing.isWindowEmpty(track):
track = basicVideoProcessing.setWindowAsFrameSize(img )
else:
center = retn[1]
memory.raiseEvent("RedBallDetectedEvent", (640-center[0], 480-center[1]))
hsv_w = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
#mask1 = cv2.inRange(hsv_w, (0,204,138), (3,210,254))
#mask2 = cv2.inRange(hsv_w, (171,173,51), (176,209,77))
acmask = cv2.inRange(hsv_w, np.array([110,125,61]), np.array([144,156,136]))
acmask = cv2.erode(acmask, None, iterations=1)
acmask = cv2.dilate(acmask, None, iterations=1)
hist = cv2.calcHist([hsv_w],[0,1],acmask,[180,255],[0,180,0,255])
cv2.normalize(hist,hist,0,255,cv2.NORM_MINMAX)
dst = cv2.calcBackProject([hsv_w],[0,1],hist,[0,180,0,255],1)
retn, track = cv2.CamShift(dst, track, term)
except BaseException, err:
print "Undefined error: " + str(err)
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
def main():
memory = ALProxy("ALMemory", NAO_IP, NAO_PORT)
basicVideoProcessing = BasicVideoProcessing()
basicVideoProcessing.connectToCamera()
try:
while True:
img = basicVideoProcessing.getImageFromCamera()
if (img == None):
print "Img is empty"
break
else:
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edged = basicVideoProcessing.autoCanny(gray)
contours,_ = cv2.findContours(edged, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
if len(contours) > MIN_CONTOURS_DETECTED: # simple condition to prevent constant evaluation of contours when it doesn't make sense
areaMedian, areaMean, ratioMedian, ratioMean = basicVideoProcessing.extractContoursStatistics(contours)
if ratioMedian/ratioMean >= MIN_RATIO_OF_SIMILIAR_OBJECTS and areaMedian/areaMean >= MIN_AREA_OF_SIMILIAR_OBJECTS:
memory.raiseEvent("TextDetectedEvent", 1)
contoursImage = cv2.cvtColor(edged,cv2.COLOR_GRAY2BGR)
both = np.hstack((img,contoursImage))
cv2.imshow("Detection of text", both)
key = cv2.waitKey(25)
if key == ord('a'):
break
except BaseException, err:
print "Undefined error: " + str(err)
示例3: exe
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
def exe(self, args=None, addr=None):
# get proxy
mem = ALProxy("ALMemory", Settings.naoHostName, Settings.naoPort)
# set stiffness
if len(args) > 0:
mem.raiseEvent( str(args[0]), None )
示例4: ConversationModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
class ConversationModule(ALModule):
def __init__(self, name):
ALModule.__init__(self, name)
self.tts = ALProxy("ALTextToSpeech")
self.ears = ALProxy("ALSpeechRecognition")
self.memory = ALProxy("ALMemory")
self.log = ALProxy("ALLogger")
self.ears.subscribe("Conversation")
self.memory.subscribeToEvent("WordRecognized", "Conversation", "onWordRecognized")
def onWordRecognized(self, key, value, message):
"""
Subscribe to change in mood
:param key: memory key
:param value: memory value
:param message: message of the event
:return:
"""
self.ears.unsubscribe("Conversation")
self.tts.say("I recognized %s" % value)
self.ears.subscribe("Conversation")
pass
def setMood(self, value):
"""
Sets the current mood felt by the robot
:param value: Mood value 1=good, 0=neutral, -1=bad
:return:
"""
self.__previousMood = self.__mood
self.__mood = Mood(value)
self.memory.raiseEvent("Brain/Mood/Text", self.__mood.text)
self.memory.raiseEvent("Brain/Mood/Value", self.__mood.value)
pass
def getMood(self):
"""
Gets the current mood
:return:
"""
return self.__mood
def getPreviousMood(self):
"""
Gets the previous mood
:return:
"""
return self.__previousMood
示例5: SpeechRecognitionMemory
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
class SpeechRecognitionMemory(ALModule):
"""
// Unicodeドキュメントはnaoqiライブラリに対応していない...
声の検出用Memory
# Memories
## WordRecognized
[[word:utf-8, confidence:float]*]
変換結果のリストを格納する。
## Status
"running"|"stop"|"error"
プロキシの状態を示す。
"running"を指定すると変換を開始する。
"stop"を指定すると変換を停止する。
## Error
Error|None
エラー情報を格納する。
"""
STATUS_EVENT = "Status"
WORD_EVENT = "WordRecognized"
ERROR_EVENT = "Error"
def __init__(self, name, event_root_path):
ALModule.__init__(self, name)
self.memory = ALProxy("ALMemory")
self.name = name
self.event_root_path = event_root_path
self.status = "stop"
self.status_handler = None
self.subscribed_on_received_status = False
def init_events(self, status_handler=None):
self.memory.raiseEvent(self.event_root_path + self.STATUS_EVENT, "stop")
self.memory.raiseEvent(self.event_root_path + self.WORD_EVENT, [])
self.memory.raiseEvent(self.event_root_path + self.ERROR_EVENT, None)
self.status_handler = status_handler
if not self.subscribed_on_received_status:
key = self.event_root_path + self.STATUS_EVENT
logger.debug("[Memory] subscribe {0} {1}".format(key, self.getName()))
self.subscribed_on_received_status = True
self.memory.subscribeToEvent(key, self.getName(), "on_received_status")
def raise_event(self, name, value):
self.memory.raiseEvent(self.event_root_path + name, value)
def start(self):
self.status = "running"
self.raise_event(self.STATUS_EVENT, "running")
def stop(self):
self.status = "stop"
self.raise_event(self.STATUS_EVENT, "stop")
def error(self, value):
self.status = "error"
self.raise_event(self.STATUS_EVENT, "error")
self.raise_event(self.ERROR_EVENT, value)
def recognize(self, value):
self.raise_event(self.WORD_EVENT, value)
def on_received_status(self, key, value, message):
logger.debug("[Memory] received: {0} {1} {2}".format(key, value, message))
if self.status_handler:
self.status_handler(key, value, message)
示例6: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import raiseEvent [as 别名]
from naoqi import ALProxy
host = "169.254.113.113"
port = 9559
memory = ALProxy("ALMemory", host, port)
memory.raiseEvent("BasicEvent", 19)