This section contains examples recording video from NAO in different formats.
Record the video taken by NAO’s camera on the robot in .avi format.
#
# This example demonstrates how to use VisionToolbox module to record a video
# file on the robot.
#
# Usage: python vision_videorecord.py "robot_ip"
#
import sys
import time
from naoqi import ALProxy
if __name__ == "__main__":
IP = "nao.local" # Replace here with your NaoQi's IP address.
PORT = 9559
# Read IP address from first argument if any.
if len(sys.argv) > 1:
IP = sys.argv[1]
visionToolboxProxy = ALProxy("ALVisionToolbox", 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.
visionToolboxProxy.startVideoRecord_adv("myvideo.avi", 10, "MJPG", 1, -1)
time.sleep(5)
# Video file is saved on the robot in the
# /home/nao/naoqi/share/naoqi/vision/ folder.
videoInfo = visionToolboxProxy.stopVideoRecord()
print "Video was saved on the robot: ", videoInfo[1]
print "Num frames: ", videoInfo[0]
Record the video taken by NAO’s camera without any filtering and store it in a .arv format on the robot.
getImageLocal_and_recordArv.py
"""
This is a simple python script to easily record .arv files.
We create a video client to get images.
We call "recordVideo" on our video client, so that each image that is retrieved
by the client is saved to disk.
"""
import time
from naoqi import ALProxy
IP = "nao.local" # Enter your NAOqi's IP address here.
PORT=9559
#________________________________
# Generic Proxy creation
#________________________________
camProxy = ALProxy("ALVideoDevice",IP,PORT)
#________________________________
# Vision module creation
#________________________________
resolution = 1 #0:QVGA 1:QVGA 2:VGA (camera doesn't provide QQVGA that is obtained through CPU processing)
colorSpace = 9 #kYUV422InterlacedColorSpace
fps = 30 #not activated
# We subscrive our video client.
nameId = "pythonGVM"
nameId = camProxy.subscribe(nameId, resolution, colorSpace, fps)
#________________________________
# Ask to grab a maximum of 3500
# images obtained by the vision module
# After this call, all images we will retrieved using "nameId" will be saved
# to disk.
#________________________________
recording = camProxy.recordVideo(nameId, "/home/nao/naoqi/001_VGA", 3500, 1)
print "launch recording"
print recording
#________________________________
# The vision module requests 300 images
#________________________________
for i in range(0, 500):
image = camProxy.getImageLocal(nameId)
camProxy.releaseImage(nameId)
time.sleep(0.003)
#________________________________
# Stop manually the recording
# after 300 images
#________________________________
print "finishing"
camProxy.stopVideo(nameId)
camProxy.unsubscribe(nameId)
print 'end of script'