本文整理汇总了Python中naoqi.ALProxy.setResolution方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.setResolution方法的具体用法?Python ALProxy.setResolution怎么用?Python ALProxy.setResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.setResolution方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeviceVision
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
class DeviceVision(Vision):
# Initialization of NAO proxies
def __init__(self, parameters):
self.nao_ip = parameters["nao_ip"]
self.nao_port = int(parameters["nao_port"])
# Intializing NAOQi proxies
self.photo = ALProxy("ALPhotoCapture", self.nao_ip, self.nao_port)
self.video = ALProxy("ALVideoDevice", self.nao_ip, self.nao_port)
# Assistive function to return errors
def ret_exc(self, text):
print text
return {'error': text}
# Captures a photo and stores it LOCALLY in NAO.
# The filepath must be absolute (not relative)
# The camera_id must be one of ['front', 'front_down']. If it is anything
# else the 'front' camera is assumed, which is the default value.
# Resolution must be one of '40x30', '80x60', '160x120', '320x240', '640x480'
# and '1280x960'. If it is anything else '640x480 is assumed, being the
# default value.
def capturePhoto(self, filepath, camera_id = 'front', resolution = '640x480'):
if '/home/nao/' not in filepath:
return self.ret_exc('vision.capturePhoto: Erroneous filepath')
head, tail = os.path.split(filepath)
cam_id = 0
if camera_id not in ['front', 'front_down']:
cam_id = 0
if camera_id == "front_down":
cam_id = 1
l_resolution = resolution
if resolution not in ['40x30', '80x60', '160x120', '320x240', \
'640x480', '1280x960']:
l_resolution = '640x480'
resol = {}
resol['40x30'] = 8
resol['80x60'] = 7
resol['160x120'] = 0
resol['320x240'] = 1
resol['640x480'] = 2
resol['1280x960'] = 3
try:
self.photo.setCameraID(cam_id)
self.photo.setResolution(resol[l_resolution])
self.photo.takePicture(head, tail)
except Exception as e:
return self.ret_exc("vision.capturePhoto: Unrecognized exception: " + \
e.message)
return {'error': None}
示例2: store
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
def store(filename,imagetype):
try:
photoCaptureProxy = ALProxy("ALPhotoCapture", "127.0.0.1", 9559)
photoCaptureProxy.setResolution(2)
photoCaptureProxy.setPictureFormat(imagetype) #jpg png etc..
photoCaptureProxy.takePictures(1,"/orbital/media/", filename)
except Exception, e:
print " *** Error: vision.py , when creating ALPhotoCapture proxy:"
print str(e)
示例3: take_pic
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
def take_pic():
"""remove and permute old pic, save the new one."""
os.remove("./pics/2.png")
os.rename("./pics/1.png", "./pics/2.png")
os.rename("./pics/0.png", "./pics/1.png")
photoCaptureProxy = ALProxy("ALPhotoCapture", "192.168.1.8", 9559)
photoCaptureProxy.setResolution(2)
photoCaptureProxy.setPictureFormat("png")
photoCaptureProxy.takePictures(1, "/home/nao/NaoAccueil/www/Modules/python/pics", "_0")
img = Image.open("./pics/_0.png")
resultat = img.rotate(90, expand=1)
resultat.save("./pics/0.png")
return send_file("./pics/0.png", mimetype='image/png')
示例4: takePicture
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
def takePicture(self):
absoluteFilename = tempfile.mktemp()
directoryName = "/" + absoluteFilename.split('/')[1]
filename = absoluteFilename[-1]
photoCapture = ALProxy("ALPhotoCapture")
photoCapture.setResolution(3)
photoCapture.setPictureFormat('jpg')
theFilename = photoCapture.takePicture(directoryName, filename)
img_bin = ''
with open(theFilename[0], "rb") as f:
img_bin = f.read()
os.unlink(theFilename[0])
reactions = ["That's a fantastic picture!",
"Great photo!",
"Nice one!"]
self.leds.on("FaceLeds")
self.tts.say(random.choice(reactions))
self.motion.setStiffnesses("Arms", 0.0)
if self.onCompleteCallback:
self.onCompleteCallback()
return img_bin
示例5: MainWindow
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
#.........这里部分代码省略.........
# checkboxes for sonar and tactile sensors readings
frame_checkboxes = tk.Frame(self)
frame_checkboxes.pack(fill=tk.X)
tk.Checkbutton(frame_checkboxes, text="Record tactile sensors",
variable=self.recordTactile).pack(side=tk.RIGHT, padx=5, pady=5)
tk.Checkbutton(frame_checkboxes, text="Record sonar readings",
variable=self.recordSonar).pack(side=tk.RIGHT, padx=5, pady=5)
# frame for record and stop buttons
frame_buttons = tk.Frame(self)
frame_buttons.pack(fill=tk.X)
start_button = tk.Button(frame_buttons, text='Start recording', command=self.start)
stop_button = tk.Button(frame_buttons, text='Stop recording', command=self.stop)
close_button = tk.Button(frame_buttons, text='Close', command=self.close, width=10)
close_button.grid(row=0, column=2, padx=5, pady=5)
stop_button.grid(row=0, column=1, padx=5, pady=5)
start_button.grid(row=0, column=0, padx=5, pady=5)
# frame for status display
frame_label = tk.Frame(self)
frame_label.pack(fill=tk.X)
self.label = tk.Label(frame_label, text="Not connected")
self.label.pack(fill=tk.X)
def clear_label(self):
""" Clears label for the video """
self.video_label.set("")
def connect(self):
""" Connect with the robot """
# try to establish a connection
try:
self.videoRecorderProxy = ALProxy("ALVideoRecorder", self.ip.get(), self.port.get())
self.videoRecorderProxy.setResolution(2)
self.videoRecorderProxy.setFrameRate(30)
self.videoRecorderProxy.setVideoFormat("MJPG")
self.videoRecorderProxy.setCameraID(0)
self.audioRecorderProxy = ALProxy("ALAudioDevice", self.ip.get(), self.port.get())
self.memoryProxy = ALProxy("ALMemory", self.ip.get(), self.port.get())
self.sonarProxy = ALProxy("ALSonar", self.ip.get(), self.port.get())
self.isConnected = True
self.label.config(text='Ready')
# connecting with robot failed
except:
self.isConnected = False
self.label.config(text='Not connected')
def switch_camera(self):
""" Change the recording device on the robot """
# switch camera if connected
if self.isConnected and not self.isRecordingVideo:
self.videoRecorderProxy.setCameraID(1 - self.videoRecorderProxy.getCameraID())
self.camera_label.config(text=self.camera_dict[self.videoRecorderProxy.getCameraID()])
def switch_audio(self):
""" Change the format of audio recording
.ogg is a single channel recording from the front microphone
.wav (default) is a 4-channel recording from all microphones
"""
if not self.isRecordingAudio:
self.audio_id = 1 - self.audio_id
self.audio_label.config(text=self.audio_dict[self.audio_id])
def start(self):
""" Start recording if connected """
if not self.isConnected:
示例6: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
import sys
import time
from naoqi import ALProxy
IP = "nao.local"
PORT = 9559
videoRecorderProxy = ALProxy("ALVideoRecorder", IP, PORT)
# This records a 320*240 MJPG video at 10 fps.
# Note MJPG can't be recorded with a framerate lower than 3 fps.
videoRecorderProxy.setResolution(1)
videoRecorderProxy.setFrameRate(10)
videoRecorderProxy.setVideoFormat("MJPG")
videoRecorderProxy.startVideoRecord("/home/nao/recordings/cameras", "myvideo")
time.sleep(5)
# Video file is saved on the robot in the
# /home/nao/recordings/cameras/ folder.
videoInfo = videoRecorderProxy.stopVideoRecord()
print "Video was saved on the robot: ", videoInfo[1]
print "Num frames: ", videoInfo[0]
示例7: range
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
fps = 30
nameId = camProxy.register("python_GVM", resolution, colorSpace, fps)
print nameId
print 'getting direct raw images in local'
for i in range(0, 50):
camProxy.getDirectRawImageLocal(nameId)
camProxy.releaseDirectRawImage(nameId)
print 'getting direct raw images in remote'
for i in range(0, 50):
camProxy.getDirectRawImageRemote(nameId)
resolution = 2 #kVGA
camProxy.setResolution(nameId, resolution)
print 'getting images in local'
for i in range(0, 50):
camProxy.getImageLocal(nameId)
camProxy.releaseImage(nameId)
print 'getting images in remote'
for i in range(0, 50):
camProxy.getImageRemote(nameId)
camProxy.unRegister(nameId)
print 'end of gvm_getImageLocal python script'
示例8: print
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
# From sensors_getInertialValues.py
# Get the Compute Torso Angle in radian
# TorsoAngleX = memoryProxy.getData("Device/SubDeviceList/InertialSensor/AngleX/Sensor/Value")
# TorsoAngleY = memoryProxy.getData("Device/SubDeviceList/InertialSensor/AngleY/Sensor/Value")
# print ("Torso Angles [radian] X: %.3f, Y: %.3f" % (TorsoAngleX, TorsoAngleY))
try:
videoRecorderProxy = ALProxy("ALVideoRecorder", robotIP, PORT)
except Exception, e:
print "Could not create proxy to ALVideoRecorder; error was: ", e
# This records a 320*240 MJPG video at 10 fps. (CHANGED)
# Note MJPG can't be recorded with a framerate lower than 3 fps.
videoRecorderProxy.setResolution(2) # 640x480; 3 = 1280*960
videoRecorderProxy.setFrameRate(20) # Max 30
videoRecorderProxy.setVideoFormat("MJPG")
videoRecorderProxy.startRecording("/home/nao/recordings/cameras", "videoN10m")#+str(time.time()) )
#for i in xrange(0,10):
# n = raw_input("Type 'stop' to stop recording\n")
# while n.strip() != "stop":
# time.sleep(1)
# n = raw_input("Type 'stop' to stop recording")
raw_input("Recording started. Press Enter when done...")
# Video file is saved on the robot in the
# /home/nao/recordings/cameras/ folder.
示例9: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import setResolution [as 别名]
#.........这里部分代码省略.........
#CameraIndex= 0(Top), 1(Bottom)
#Resolution= 0(160*120), 1(320*240), VGA=2(640*480), 3(1280*960)
#ColorSpace= AL::kYuvColorSpace (index=0, channels=1), AL::kYUV422ColorSpace (index=9,channels=3),
#AL::kRGBColorSpace RGB (index=11, channels=3), AL::kBGRColorSpace BGR (to use in OpenCV) (index=13, channels=3)
#Fps= OV7670 VGA camera can only run at 30, 15, 10 and 5fps. The MT9M114 HD camera run from 1 to 30fps.
#Settings for resolution 1 (320x240)
resolution_type = 1
fps=15
cam_w = 320
cam_h = 240
#Settigns for resolution 2 (320x240)
#resolution_type = 2
#fps = 15
#cam_w = 640
#cam_h = 480
camera_name_id = _al_video_proxy.subscribeCamera("Test_Video", 0, resolution_type, 13, fps)
print("[STATE " + str(STATE) + "] " + "Connected to the camera with resolution: " + str(cam_w) + "x" + str(cam_h) + "\n")
except BaseException, err:
print("[ERROR] connectToCamera: catching error " + str(err))
return
#Adding to the speech recognition proxy a vocabulary
#_al_speechrecognition_proxy.setLanguage("English")
#vocabulary = ["good", "bad", "nao"]
#_al_speechrecognition_proxy.setVocabulary(vocabulary, False)
#_al_speechrecognition_proxy.setVocabulary(vocabulary, False) #If you want to enable word spotting
#_al_speechrecognition_proxy.subscribe("Test_ASR")
#Initialise the OpenCV video recorder
if(RECORD_VIDEO == True):
print("[STATE " + str(STATE) + "] " + "Starting the video recorder..." + "\n")
fourcc = cv2.cv.CV_FOURCC(*'XVID')
video_out = cv2.VideoWriter("./output.avi", fourcc, 20.0, (cam_w,cam_h))
#Record also the NAO session
_al_video_rec_proxy.setResolution(2) #Resolution VGA 640*480
_al_video_rec_proxy.setFrameRate(30)
#_al_video_rec_proxy.setVideoFormat("MJPG")
#self._video_proxy.startVideoRecord(complete_path)
_al_video_rec_proxy.startRecording("/home/nao/recordings/cameras", "last_session", True) #It worked saving in this path!
#Save all the sentences inside the NAO memory
#it is usefull if you want a clean audio
#to present in a video.
if(RECORD_VOICE == True):
print("[STATE " + str(STATE) + "] " + "Saving the voice in '/home/nao/recordings/microphones'" + "\n")
_al_tts_proxy.sayToFile("Hello world!", "/home/nao/recordings/microphones/hello_wolrd.wav")
_al_tts_proxy.sayToFile("I see only one object! It's a " , "/home/nao/recordings/microphones/i_see_only_one.wav")
_al_tts_proxy.sayToFile("One object here! It's a " , "/home/nao/recordings/microphones/one_object.wav")
_al_tts_proxy.sayToFile("There is one object! It's a " , "/home/nao/recordings/microphones/there_is_one.wav")
_al_tts_proxy.sayToFile("I am sorry, I don't see any object!", "/home/nao/recordings/microphones/i_dont_see_any.wav")
_al_tts_proxy.sayToFile("No objects here!", "/home/nao/recordings/microphones/no_objects.wav")
_al_tts_proxy.sayToFile("There is nothing around!", "/home/nao/recordings/microphones/there_is_nothing.wav")
_al_tts_proxy.sayToFile("I am doing better!", "/home/nao/recordings/microphones/im_doing_better.wav")
_al_tts_proxy.sayToFile("Very good!", "/home/nao/recordings/microphones/very_good.wav")
_al_tts_proxy.sayToFile("Catch it!", "/home/nao/recordings/microphones/catch_it.wav")
_al_tts_proxy.sayToFile("I will do better nex time!", "/home/nao/recordings/microphones/i_will_do_better.wav")
_al_tts_proxy.sayToFile("Sorry, I'm still learning.", "/home/nao/recordings/microphones/still_learning.wav")
_al_tts_proxy.sayToFile("I miss it!", "/home/nao/recordings/microphones/miss_it.wav")
#Wake up the robot
print("[STATE " + str(STATE) + "] " + "Waking up the NAO..." + "\n")
_al_motion_proxy.wakeUp()
#_al_motion_proxy.rest()
time.sleep(2)
print("[STATE " + str(STATE) + "] " + "Go to Crouch Pose..." + "\n")
_al_posture_proxy.goToPosture("Crouch", 0.5)
#_al_posture_proxy.goToPosture("StandZero", 0.5)