ALVideoDevice API¶
NAOqi Vision - Overview | API
Namespace : AL
#include <alproxies/alvideodeviceproxy.h>
Method list¶
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
-
class
ALVideoDeviceProxy
¶
- Module Subscription Management
- Camera Management
ALVideoDeviceProxy::getCameraIndexes
ALVideoDeviceProxy::hasDepthCamera
ALVideoDeviceProxy::getCameraModel
ALVideoDeviceProxy::getCameraName
- ALVideoDeviceProxy::getActiveCamera()
ALVideoDeviceProxy::setActiveCamera
- ALVideoDeviceProxy::getFrameRate()
- ALVideoDeviceProxy::getColorSpace()
ALVideoDeviceProxy::getHorizontalFOV
ALVideoDeviceProxy::getVerticalFOV
ALVideoDeviceProxy::getParameter
ALVideoDeviceProxy::getParameterRange
ALVideoDeviceProxy::setParameter
ALVideoDeviceProxy::setParameterToDefault
ALVideoDeviceProxy::setAllParametersToDefault
ALVideoDeviceProxy::openCamera
ALVideoDeviceProxy::closeCamera
ALVideoDeviceProxy::isCameraOpen
ALVideoDeviceProxy::startCamera
ALVideoDeviceProxy::stopCamera
ALVideoDeviceProxy::isCameraStarted
- Mono Stream Management
- ALVideoDeviceProxy::getActiveCamera()
ALVideoDeviceProxy::setActiveCamera
- ALVideoDeviceProxy::getFrameRate()
ALVideoDeviceProxy::setFrameRate
ALVideoDeviceProxy::setResolution
- ALVideoDeviceProxy::getColorSpace()
ALVideoDeviceProxy::setColorSpace
ALVideoDeviceProxy::getCameraParameter
ALVideoDeviceProxy::getCameraParameterRange
ALVideoDeviceProxy::setCameraParameter
ALVideoDeviceProxy::setCameraParameterToDefault
ALVideoDeviceProxy::setAllCameraParametersToDefault
ALVideoDeviceProxy::getImageLocal
ALVideoDeviceProxy::getImageRemote
ALVideoDeviceProxy::releaseImage
- Multi Stream Management
ALVideoDeviceProxy::getActiveCameras
ALVideoDeviceProxy::setActiveCameras
ALVideoDeviceProxy::setResolutions
ALVideoDeviceProxy::getColorSpaces
ALVideoDeviceProxy::setColorSpaces
ALVideoDeviceProxy::getCamerasParameter
ALVideoDeviceProxy::setCamerasParameter
ALVideoDeviceProxy::setCamerasParameterToDefault
ALVideoDeviceProxy::getImagesLocal
ALVideoDeviceProxy::getImagesRemote
ALVideoDeviceProxy::releaseImages
- Simulation
- Conversion
ALVideoDeviceProxy::getAngularPositionFromImagePosition
ALVideoDeviceProxy::getImagePositionFromAngularPosition
ALVideoDeviceProxy::getAngularSizeFromImageSize
ALVideoDeviceProxy::getImageSizeFromAngularSize
ALVideoDeviceProxy::getImageInfoFromAngularInfo
ALVideoDeviceProxy::getImageInfoFromAngularInfoWithResolution
- Deprecated Methods
- ALVideoDeviceProxy::getResolution()
ALVideoDeviceProxy::getResolutions
ALVideoDeviceProxy::setParamDefault
ALVideoDeviceProxy::getHorizontalAperture
ALVideoDeviceProxy::getVerticalAperture
Module Subscription Management¶
-
std::string
ALVideoDeviceProxy::
subscribeCamera
(const std::string& Name, const int& CameraIndex, const int& Resolution, const int& ColorSpace, const int& Fps)¶ Subscribes to ALVideoDevice. When a Video Module registers to ALVideoDevice, a buffer of the requested image format is added to the buffers list. Returns an handle which identifies the module in ALVideoDevice. (This handle is based on the name parameter, e.g. the 3rd one getting _3 added to its name for instance to build this handle).
Parameters: - Name – Name of the subscribing module.
- CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- Resolution – Resolution requested. For further details, see: Cameras specifications.
- ColorSpace – Colorspace requested. For further details, see: Cameras specifications.
- Fps – Fps (frames per second) requested to the video source. For further details, see: Cameras specifications.
Returns: String handle under which the module is known from ALVideoDevice, empty string if error occurred.
Warning
The same Name could be used only six time.
Note
Compared to a local module, the obtained framerate for a remote module will depend on the network available bandwith (e.g. we can reach raw
1280x960@10fps
using a Gigabit Ethernet connection with the HD camera).
-
std::string
ALVideoDeviceProxy::
subscribeCameras
(const std::string& Name, const AL::ALValue& CameraIndexes, const AL::ALValue& Resolutions, const AL::ALValue& ColorSpaces, const int& Fps)¶ Subscribes to Video Input System. When a Video Module subscribes to ALVideoDevice, a buffer of the requested image resolution is added to the list of buffers for each camera.
Parameters: - Name – Name of the subscribing module.
- CameraIndexes – Array of the requested camera indexes. You can’t have the same camera index several time. For further details, see: Cameras specifications.
- Resolutions – Array of the resolutions requested. For further details, see: Cameras specifications.
- ColorSpaces – Array of the color spaces requested. For further details, see: Cameras specifications.
- Fps – Fps (frames per second) requested to the video source. For further details, see: Cameras specifications.
Returns: String handle under which the module is known from ALVideoDevice.
Warning
The same Name could be used only six time.
Note
- By default the active camera will be the first camera in the array.
- Returned registered name could be different to the subscribing module name.
-
bool
ALVideoDeviceProxy::
unsubscribe
(const std::string& Handle)¶ Unregisters a module from ALVideoDevice.
Parameters: - Handle – Handle to identify the subscriber.
Returns: true if success, false otherwise.
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_subscribe pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Subscribe a Vision Module to ALVideoDevice, starting the
// frame grabber if it was not started before.
std::string subscriberID = "subscriberID";
int fps = 5;
// The subscriberID can be altered if other instances are already running
subscriberID = cameraProxy.subscribe(subscriberID, AL::kVGA, AL::kRGBColorSpace, fps);
// Do something...
// Unsubscribe the V.M.
cameraProxy.unsubscribe(subscriberID);
return 0;
}
-
AL::ALValue
ALVideoDeviceProxy::
getSubscribers
()¶ Gets a list containing all the handle name of the subscribers.
Returns: Array of string containing the subscriber names.
Camera Management¶
-
AL::ALValue
ALVideoDeviceProxy::
getCameraIndexes
()¶ Gets list of available camera indexes.
Returns: Array of camera index. For further details, see: Cameras specifications.
-
bool
ALVideoDeviceProxy::
hasDepthCamera
()¶ Asks if a depth camera was detected by ALVideoDevice. If present, a depth camera can be accessed with the index kDepthCamera.
Returns: true if a depth camera is present, false otherwise.
-
int
ALVideoDeviceProxy::
getCameraModel
(const int& CameraIndex)¶ Gets the camera model of the specified camera.
Parameters: - CameraIndex –
Index of the camera in the video system.
For further details, see: Cameras specifications.
Returns: Camera model. For further details, see: Cameras specifications.
- CameraIndex –
-
std::string
ALVideoDeviceProxy::
getCameraName
(const int& CameraIndex)¶ Gets the name of the specified camera.
Parameters: - CameraIndex – Index of the camera in the video system (see: Cameras specifications).
Returns: name of the camera (sensor name used by motion).
-
int
ALVideoDeviceProxy::
getActiveCamera
()¶ Gets the index of the current default active camera.
Returns: Camera index. For further details, see: Cameras specifications. #include <alproxies/alvideodeviceproxy.h> #include <iostream> int main(int argc, char **argv) { if (argc < 2) { std::cerr << "Usage: videodevice_getactivecamera pIp" << std::endl; return 1; } const std::string pIp = argv[1]; // Proxy to ALVideoDevice. AL::ALVideoDeviceProxy cameraProxy(pIp); int activeCam = cameraProxy.getActiveCamera(); std::cout << "Active camera is " << activeCam << std::endl; return 0; }
-
bool
ALVideoDeviceProxy::
setActiveCamera
(const int& ActiveCamera)¶ Sets the current default active camera for the system.
Parameters: - ActiveCamera – Camera index. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
int
ALVideoDeviceProxy::
getFrameRate
(const int& CameraIndex)¶ Gets the internal frame rate of the video source.
Parameters: - CameraIndex – Index of the camera in the video system (see: Cameras specifications).
Returns: video source framerate. -1: can’t access video source.
-
int
ALVideoDeviceProxy::
getColorSpace
(const int& CameraIndex)¶ Get the color space of the video source before eventual conversion.
Parameters: - CameraIndex – Index of the camera in the video system (see: Cameras specifications).
Returns: Colorspace (see: Cameras specifications) or -1: can’t access video source.
-
float
ALVideoDeviceProxy::
getHorizontalFOV
(const int& CameraIndex)¶ Gets the camera horizontal field of view for the specified camera.
Parameters: - CameraIndex – Index to the camera in the video system. For further details, see: Cameras specifications.
Returns: Horizontal field of view of the camera (in radian).
-
float
ALVideoDeviceProxy::
getVerticalFOV
(const int& CameraIndex)¶ Gets the camera vertical field of view for the specified camera.
Parameters: - CameraIndex – Index to the camera in the video system. For further details, see: Cameras specifications.
Returns: Vertical field of view of the camera (in radian).
-
int
ALVideoDeviceProxy::
getParameter
(const int& CameraIndex, const int& parameter)¶ Gets camera internal parameter.
Parameters: - CameraIndex – Index to the camera whose module wants image. For further details, see: Cameras specifications.
- parameter – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: Value of the camera parameter. Returns 0xDEAD404 (233493508) in case of error (internal or invalid parameter).
-
AL::ALValue
ALVideoDeviceProxy::
getParameterRange
(const int& CameraIndex, const int& Id)¶ Gets the range of a camera’s parameter.
Parameters: - CameraIndex – Index to the camera whose module wants image. For further details, see: Cameras specifications.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: An ALValue containing the minimum and maximum value for the requested parameter.
-
bool
ALVideoDeviceProxy::
setParameter
(const int& CameraIndex, const int& parameter, const int& newValue)¶ Modifies camera internal parameter.
Parameters: - CameraIndex – index to the camera whose module wants image. For further details, see: Cameras specifications.
- parameter – Id of the camera parameter. For further details, see: Cameras specifications.
- newValue – value to set.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
setParameterToDefault
(const int& CameraIndex, const int& parameter)¶ Resets camera internal parameter to its default value.
Parameters: - CameraIndex – Index to the camera whose module wants image. For further details, see: Cameras specifications.
- parameter – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
setAllParametersToDefault
(const int& CameraIndex)¶ Resets all camera internal parameters to their default value.
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
openCamera
(const int& CameraIndex)¶ Opens and initializes the video source device.
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
closeCamera
(const int& CameraIndex)¶ Closes the video source device, releasing resources.
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
isCameraOpen
(const int& CameraIndex)¶ Detects if the video device is open (i.e. locked).
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
startCamera
(const int& CameraIndex)¶ Starts the video capture of the specified video device.
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
stopCamera
(const int& CameraIndex)¶ Stops the video capture of the specified video device.
Parameters: - CameraIndex – Index to the camera. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
isCameraStarted
(const int& CameraIndex)¶ Detects if the video device is running (i.e. capture images).
Parameters: - CameraIndex – Index to the camera (see: Cameras specifications).
Returns: true if success, false otherwise.
Mono Stream Management¶
-
int
ALVideoDeviceProxy::
getActiveCamera
(const std::string& Handle)¶ Gets the current active camera for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: camera Index (see: Cameras specifications) or -1: can’t access video source.
-
bool
ALVideoDeviceProxy::
setActiveCamera
(const std::string& Handle, const int& ActiveCamera)¶ Sets the current active camera for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- ActiveCamera – Camera index (see: Cameras specifications).
Returns: true if success, false otherwise.
-
int
ALVideoDeviceProxy::
getFrameRate
(const std::string& Handle)¶ Gets the frame rate that a particular Vision Module has requested to the camera. This doesn’t mean the video source is able to run at this frame rate (see
ALVideoDeviceProxy::getFrameRate
to know the video source framerate). This doesn’t either mean that a remote module will obtain images at this framerate due to network bandwith limitations.Parameters: - Handle – Handle to identify the subscriber.
Returns: module framerate or -1: can’t access video source.
-
bool
ALVideoDeviceProxy::
setFrameRate
(const std::string& Handle, const int& Fps)¶ Changes the framerate requested to the video source by the subscribed module.
Parameters: - Handle – Handle to identify the subscriber.
- Fps – Fps (frames per second) requested to the video source. For further details, see: Cameras specifications.
Note
The requested framerate will be achieved locally. Remotely, the achieved framerate will depend on the network available bandwith (e.g. we can reach raw
1280x960@10fps
using a Gigabit Ethernet connection with the HD camera).Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
setResolution
(const std::string& Handle, const int& Resolution)¶ Sets the size of the output image for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- Resolution – Resolution requested (see: Cameras specifications).
Returns: true if success, false otherwise.
-
int
ALVideoDeviceProxy::
getColorSpace
(const std::string& Handle)¶ Gets the current color space requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Colorspace. For further details, see: Cameras specifications or -1: can’t access video source.
-
bool
ALVideoDeviceProxy::
setColorSpace
(const std::string& Handle, const int& ColorSpace)¶ Sets the current color space requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- ColorSpace – Colorspace requested. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
int
ALVideoDeviceProxy::
getCameraParameter
(const std::string& Handle, const int& Id)¶ Gets a camera’s parameter from the module current active camera. This method will probe for value of the current active camera of the module.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: Parameter’s value. Returns 0xDEAD404 (233493508) in case of error (internal or invalid parameter).
-
AL::ALValue
ALVideoDeviceProxy::
getCameraParameterRange
(const std::string& Handle, const int& Id)¶ Gets the range of a camera’s parameter from the module current active camera.
Parameters: - Handle – Handle under which the module is known from the video system.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: An ALValue containing the minimum and maximum of the requested parameter.
-
bool
ALVideoDeviceProxy::
setCameraParameter
(const std::string& Handle, const int& Id, const int& NewValue)¶ Sets the value of a specific parameter for the module current active camera.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
- NewValue – New value to set.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
setCameraParameterToDefault
(const std::string& Handle, const int& Id)¶ Sets a camera’s parameter to its default value.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: true if success, false otherwise.
-
bool
ALVideoDeviceProxy::
setAllCameraParametersToDefault
(const std::string& Handle)¶ Resets all camera internal parameters to their default value.
Parameters: - Handle – Handle under which the module is known from the video system.
Returns: true if successful, false otherwise.
-
AL::ALImage*
ALVideoDeviceProxy::
getImageLocal
(const std::string& Handle)¶ Retrieves the latest image from the video source, applies eventual transformations to the image to provide the format requested by the vision module and returns a pointer to a locked
AL::ALImage
.Warning
- When the image is not necessary anymore, a call to releaseImage() is requested. If the module didn’t release the previous image, returns NULL.
- Image pointer is valid only if your module is running locally, not for remote modules.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Pointer to the locked image buffer, NULL if error (e.g. if the previous image was not released).
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_imageremote pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Subscribe a Vision Module to ALVideoDevice, starting the
// frame grabber if it was not started before.
std::string subscriberID = "subscriberID";
int fps = 5;
// The subscriberID can be altered if other instances are already running
subscriberID = cameraProxy.subscribe(subscriberID, AL::kVGA, AL::kRGBColorSpace, fps);
// Retrieve the current image.
const ALImage* image = cameraProxy.getImageLocal(subscriberID);
if (image == NULL) {
std::cerr << "Could not retrieve current image." << std::endl;
return 0;
}
else {
std::cout << "Image retrieved." << std::endl;
}
cameraProxy.releaseImage(subscriberID);
// Unsubscribe the V.M.
cameraProxy.unsubscribe(subscriberID);
return 1;
}
-
AL::ALValue
ALVideoDeviceProxy::
getImageRemote
(const std::string& Handle)¶ Retrieves the latest image from the video source, applies eventual transformations to the image to provide the format requested by the vision module and send it as an ALValue through the network.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Container of image.
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_imageremote pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Subscribe a Vision Module to ALVideoDevice, starting the
// frame grabber if it was not started before.
std::string subscriberID = "subscriberID";
int fps = 5;
// The subscriberID can be altered if other instances are already running
subscriberID = cameraProxy.subscribe(subscriberID, AL::kVGA, AL::kRGBColorSpace, fps);
// Retrieve the current image.
AL::ALValue results;
results = cameraProxy.getImageRemote(subscriberID);
const unsigned char* imageData = static_cast<const unsigned char*>(results[6].GetBinary());
if (imageData == NULL) {
std::cerr << "Could not retrieve current image." << std::endl;
return 0;
}
else {
std::cout << "Image retrieved." << std::endl;
}
cameraProxy.releaseImage(subscriberID);
// Unsubscribe the V.M.
cameraProxy.unsubscribe(subscriberID);
return 1;
}
-
bool
ALVideoDeviceProxy::
releaseImage
(const std::string& Handle)¶ Release image buffer locked by getImageLocal(). If module had no locked image buffer, does nothing.
Parameters: - Handle – Handle to identify the subscriber.
Returns: true if success
Note
It is not mandatory to use releaseImage to release an image obtained by getImageRemote. However, it’s a good habit to place it in order to ease the switch from a remote behavior to a local one and this will not use CPU (this method returns directly when it follows a getImageRemote).
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_imageremote pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Subscribe a Vision Module to ALVideoDevice, starting the
// frame grabber if it was not started before.
std::string subscriberID = "subscriberID";
int fps = 5;
// The subscriberID can be altered if other instances are already running
subscriberID = cameraProxy.subscribe(subscriberID, AL::kVGA, AL::kRGBColorSpace, fps);
// Retrieve the current image.
const ALImage* image = cameraProxy.getImageLocal(subscriberID);
if (image == NULL) {
std::cerr << "Could not retrieve current image." << std::endl;
return 0;
}
else {
std::cout << "Image retrieved." << std::endl;
}
cameraProxy.releaseImage(subscriberID);
// Unsubscribe the V.M.
cameraProxy.unsubscribe(subscriberID);
return 1;
}
Multi Stream Management¶
-
AL::ALValue
ALVideoDeviceProxy::
getActiveCameras
(const std::string& Handle)¶ Gets current active cameras for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Array of camera indexes (see: Cameras specifications) or -1: can’t access video source.
-
AL::ALValue
ALVideoDeviceProxy::
setActiveCameras
(const std::string& Handle, const AL::ALValue& ActiveCameras)¶ Sets the current active cameras for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- ActiveCameras – Array of the requested camera indexes. For further details, see: Cameras specifications.
Returns: Array of booleans with true if success.
-
AL::ALValue
ALVideoDeviceProxy::
setResolutions
(const std::string& Handle, const AL::ALValue& Resolutions)¶ Sets the size of the output image for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- Resolution – Array of resolutions requested. For further details, see: Cameras specifications.
Returns: Array of booleans with true if success.
-
AL::ALValue
ALVideoDeviceProxy::
getColorSpaces
(const std::string& Handle)¶ Gets the current color spaces requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Array of color spaces. For further details, see: Cameras specifications.
-
AL::ALValue
ALVideoDeviceProxy::
setColorSpaces
(const std::string& Handle, const AL::ALValue& ColorSpaces)¶ Sets the current color spaces requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
- ColorSpaces – Array of color spaces requested. For further details, see: Cameras specifications.
Returns: Array of booleans with true if success
-
AL::ALValue
ALVideoDeviceProxy::
getCamerasParameter
(const std::string& Handle, const int& Id)¶ Gets a camera’s parameter from the module current active cameras. This method will probe for value of the current active camera of the module.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the cameras parameter. For further details, see: Cameras specifications.
Returns: Parameter’s values.
-
AL::ALValue
ALVideoDeviceProxy::
setCamerasParameter
(const std::string& Handle, const int& Id, const AL::ALValue& NewValue)¶ Sets the values of a specific parameter for the module current active cameras.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
- NewValue – New value to set.
Returns: Array of booleans with true if success.
-
AL::ALValue
ALVideoDeviceProxy::
setCamerasParameterToDefault
(const std::string& Handle, const int& Id)¶ Sets a camera’s parameter to its default value.
Parameters: - Handle – Handle to identify the subscriber.
- Id – Id of the camera parameter. For further details, see: Cameras specifications.
Returns: Array of booleans with true if success.
-
AL::ALValue
ALVideoDeviceProxy::
getImagesLocal
(const std::string& Handle)¶ Retrieves the latest images from the video source, applies eventual transformations to the images to provide the format requested by the vision module and returns pointers to locked
AL::ALImage
.Warning
- When the images are not necessary anymore, a call to releaseImages() is requested. If the module didn’t release the previous image, returns NULL.
- Image pointers are valid only if your module is running locally, not for remote modules.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Array of pointers to locked
AL::ALImage
buffers, NULL if error (e.g. if the previous images was not released).
-
AL::ALValue
ALVideoDeviceProxy::
getImagesRemote
(const std::string& Handle)¶ Retrieves the latest images from the video source, applies eventual transformations to the images to provide the format requested by the vision module and send it as an ALValue through the network.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Container of images.
-
AL::ALValue
ALVideoDeviceProxy::
releaseImages
(const std::string& Handle)¶ Release image buffers locked by getImagesLocal(). If module had no locked image buffers, does nothing.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Array of booleans with true if success.
Note
It is not mandatory to use releaseImages to release an image obtained by getImagesRemote. However, it’s a good habit to place it in order to ease the switch from a remote behavior to a local one and this will not use CPU (this method returns directly when it follows a getImagesRemote).
Simulation¶
-
bool
ALVideoDeviceProxy::
putImage
(const int& CameraIndex, const int& Width, const int& Height, const AL::ALValue& ImageBuffer)¶ Loads Image into kernel circular buffer. Simulates acquisition of a new image by the virtual camera.
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- Width – Width of the image buffer among 1280, 640, 320, 160.
- Height – Height of the image buffer among 960, 480, 240, 120.
- ImageBuffer – The image Buffer in Bitmap form (i.e. RGB 24bits).
Returns: true if success, false otherwise.
Warning
This method only works in simulation.
-
AL::ALValue
ALVideoDeviceProxy::
getExpectedImageParameters
(const int& CameraIndex)¶ Called by the simulator to know expected image parameters
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
Returns: ALValue of expected parameters: [int height, int width, int framerate]
Warning
This method only works in simulation.
Conversion¶
-
std::vector<float>
ALVideoDeviceProxy::
getAngularPositionFromImagePosition
(const int& CameraIndex, const std::vector<float>& ImagePosition)¶ Returns position as angles relative to camera axis given a normalized position in the image.
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- ImagePosition – Vector of size 2 containing the normalized position along the horizontal and vertical dimensions of the image. The two values must be in the range [0.0 - 1.0].
Returns: corresponding angles values in radians (vector of size 2).
-
std::vector<float>
ALVideoDeviceProxy::
getImagePositionFromAngularPosition
(const int& CameraIndex, const std::vector<float>& AngularPosition)¶ Returns a normalized position in the image from a position expressed with camera angles in radians.
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- AngularPosition – Vector of size 2 containing the camera angle values in radians along the horizontal and vertical dimensions of the image.
Returns: corresponding normalized position in the image [0.0 - 1.0] (vector of size 2).
-
std::vector<float>
ALVideoDeviceProxy::
getAngularSizeFromImageSize
(const int& CameraIndex, const std::vector<float>& ImageSize)¶ From a normalized size in the image, returns size expressed as angles in radian relative to camera axis.
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- ImageSize – Vector of size 2 containing the normalized position along the horizontal and vertical dimensions of the image. The two values must be in the range [0.0 - 1.0].
Returns: corresponding angles values in radians (vector of size 2).
-
std::vector<float>
ALVideoDeviceProxy::
getImageSizeFromAngularSize
(const int& CameraIndex, const std::vector<float>& AngularSize)¶ Returns a normalized size from a size expressed with camera angles in radians.
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- AngularSize – Vector of size 2 containing the camera angle values in radians along the horizontal and vertical dimensions of the image.
Returns: corresponding normalized position in the image [0.0 - 1.0] (vector of size 2).
-
std::vector<float>
ALVideoDeviceProxy::
getImageInfoFromAngularInfo
(const int& CameraIndex, const std::vector<float>& AngularInfo)¶ Returns [X, Y, width, height] normalized info in the image from these info expressed as angles in radians (as returned by vision extractors).
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- AngularInfo – Vector of size 2 containing the camera angle values in radians along the horizontal and vertical dimensions of the image.
Returns: corresponding normalized position and size info: [X, Y, width, height].
-
std::vector<float>
ALVideoDeviceProxy::
getImageInfoFromAngularInfoWithResolution
(const int& CameraIndex, const std::vector<float>& AngularInfo, const int& ResolutionIndex)¶ Returns [X, Y, width, height] info as pixels in the image from these info expressed as angles in radians (as returned by vision extractors).
Parameters: - CameraIndex – Index of the camera in the video system. For further details, see: Cameras specifications.
- AngularInfo – Vector of size 2 containing the camera angle values in radians along the horizontal and vertical dimensions of the image.
- ResolutionIndex – image resolution
Returns: corresponding pixels position and size info: [X, Y, width, height].
Deprecated Methods¶
-
int
ALVideoDeviceProxy::
getResolution
(const int& CameraIndex)¶ Deprecated since version 2.8: The resolution of the video source is managed internally and can be different from any resolution listed in the index.
Gets the resolution of the video source before eventual conversion.
Parameters: - CameraIndex – Index of the camera in the video system (see: Cameras specifications).
Returns: Resolution (see: Cameras specifications) or -1: can’t access video source.
-
int
ALVideoDeviceProxy::
getResolution
(const std::string& Handle)¶ Deprecated since version 2.8: When retrieving an image, use the getResolution function of the
AL::ALImage
class.Gets the current resolution requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Resolution. For further details, see: Cameras specifications.
-
AL::ALValue
ALVideoDeviceProxy::
getResolutions
(const std::string& Handle)¶ Deprecated since version 2.8: When retrieving an image, use the getResolution function of the
AL::ALImage
class.Gets the current resolutions requested for the specified module.
Parameters: - Handle – Handle to identify the subscriber.
Returns: Array of resolutions. For further details, see: Cameras specifications.
-
float
ALVideoDeviceProxy::
getHorizontalAperture
(const int& CameraIndex)¶ Deprecated since version 1.14: use
ALVideoDeviceProxy::getHorizontalFOV
instead.Gets the camera horizontal field of view for the specified camera.
Parameters: - CameraIndex – Index to the camera in the video system.
Returns: Horizontal field of view of the camera (in radian).
-
float
ALVideoDeviceProxy::
getVerticalAperture
(const int& CameraIndex)¶ Deprecated since version 1.14: use
ALVideoDeviceProxy::getVerticalFOV
instead.Gets the camera vertical field of view for the specified camera.
Parameters: - CameraIndex – Index to the camera in the video system.
Returns: Vertical field of view of the camera (in radian).
Cameras specifications¶
NAO | Pepper |
Video cameras | Video & depth sensors |
Internal Types¶
Image
Image container is an array as follow:
- [0]: width.
- [1]: height.
- [2]: number of layers.
- [3]: ColorSpace.
- [4]: time stamp from qi::Clock (seconds).
- [5]: time stamp from qi::Clock (microseconds).
- [6]: binary array of size height * width * nblayers containing image data.
- [7]: camera ID (kTop=0, kBottom=1).
- [8]: left angle (radian).
- [9]: topAngle (radian).
- [10]: rightAngle (radian).
- [11]: bottomAngle (radian).
Images
Images container is an array of image containers as follow:
- [0] First Image, an array containing:
- [0]: width.
- [1]: height.
- [2]: number of layers.
- [3]: ColorSpace.
- [4]: time stamp from qi::Clock (seconds).
- [5]: time stamp from qi::Clock (microseconds).
- [6]: binary array of size height * width * nblayers containing image data.
- [7]: camera ID (kTop=0, kBottom=1).
- [8]: left angle (radian).
- [9]: topAngle (radian).
- [10]: rightAngle (radian).
- [11]: bottomAngle (radian).
- [1] Second Image.
- [0]: width.
- [1]: height.
- [2]: number of layers.
- [3]: ColorSpace.
- [4]: time stamp from qi::Clock (seconds).
- [5]: time stamp from qi::Clock (microseconds).
- [6]: binary array of size height * width * nblayers containing image data.
- [7]: camera ID (kTop=0, kBottom=1).
- [8]: left angle (radian).
- [9]: topAngle (radian).
- [10]: rightAngle (radian).
- [11]: bottomAngle (radian).