NAOqi Vision - Overview | API | Tutorial | ALVideoDevice - Advanced
See also
Namespace : AL
#include <alproxies/alvideodeviceproxy.h>
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
Unregisters a module from ALVideoDevice.
Parameters: |
|
---|
#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;
}
Callback when client is disconnected
Parameters: |
|
---|
Gets the camera model of the default active camera.
Parameters: |
|
---|---|
Returns: |
Opens and initialize the video source device if it was not already opened.
Note
The first module subscribing to ALVideoDevice will launch it automatically, so the main purpose of this method is to reduce time when the first vision module is subscribing.
Parameters: |
|
---|---|
Returns: | true if success. |
Closes the video source device.
Note
When the last vision module subscribed to ALVideoDevice unsubscribes, this doesn’t close the video source device as we assume that if some video was requested before, video will be again requested latter. But if this is not the case, closing the video source will save processing resources.
Parameters: |
|
---|---|
Returns: | true if success. |
Asks if the framegrabber is running or not.
Parameters: |
|
---|---|
Returns: | true if success. |
Gets the internal frame rate of the video source.
Parameters: |
|
---|---|
Returns: | video source framerate. -1: can’t access video source. |
Gets the resolution of the video source before eventual conversion.
Parameters: |
|
---|---|
Returns: | resolution or -1: can’t access video source. |
Get the color space of the video source before enventual conversion.
Parameters: |
|
---|---|
Returns: | colorspace or -1: can’t access video source. |
Subscribes to ALVideoDevice. When a Video Module registers to ALVideoDevice, a buffer of the requested image format is added to the buffers list. Returns the name under which the module will be known from ALVideoDevice (useful when several modules try to subscribe using the same name, the 3rd one getting _3 added to its name for instance).
Parameters: |
|
---|---|
Returns: | Name under which the module is known from ALVideoDevice, NULL if failed. |
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).
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: |
|
---|---|
Returns: | module framerate or -1: can’t access video source. |
Changes the framerate requested to the video source by the subscribed module.
Parameters: |
|
---|
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. |
---|
Gets the current active camera for the specified module.
Parameters: |
|
---|
Sets the current active camera for the specified module.
Parameters: |
|
---|---|
Returns: | true if success. |
Gets the current resolution requested for the specified module.
Parameters: |
|
---|---|
Returns: |
Sets the size of the output image for the specified module.
Parameters: |
|
---|---|
Returns: | true if success. |
Gets the current color space requested for the specified module.
Parameters: |
|
---|---|
Returns: | colorspace or -1: can’t access video source. |
Sets the current color space requested for the specified module.
Parameters: |
|
---|---|
Returns: | true if success. |
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: |
|
---|---|
Returns: | Parameter’s value. |
Sets the value of a specific parameter for the module current active camera.
Parameters: |
|
---|---|
Returns: | true if success. |
Sets a camera’s parameter to its default value.
Parameters: |
|
---|---|
Returns: | true if success. |
Retrieves the latest image from the video source and returns a pointer to the locked AL::ALImage, with data array pointing directly to raw data. There is no format conversion and no copy of the raw buffer.
Warning
Parameters: |
|
---|---|
Returns: | Pointer to the locked AL::ALImage buffer, NULL if error. |
Retrieves the latest image from the video source and send the data coming directly from the raw buffer as an ALValue through the network (no format conversion).
Warning
Parameters: |
|
---|---|
Returns: | Container of image. |
Release image buffer locked by getDirectRawImageLocal(). If the module has no locked image buffer, does nothing.
Parameters: |
|
---|---|
Returns: | true if success |
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
Parameters: |
|
---|---|
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;
}
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: |
|
---|---|
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;
}
Release image buffer locked by getImageLocal(). If module had no locked image buffer, does nothing.
Parameters: |
|
---|---|
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;
}
Subscribes to Video Inpute System. When a Video Module subscribes to the video input system, a buffer of the requested image resolution is added to the buffers list.
Parameters: |
|
---|---|
Returns: | Name under which the module is known from the video system. |
Note
Gets current active cameras for the specified module.
Parameters: |
|
---|
Sets the current active cameras for the specified module.
Parameters: |
|
---|---|
Returns: | Array of booleans with true if success. |
Gets the current resolutions requested for the specified module.
Parameters: |
|
---|---|
Returns: | Array of resolutions (see resolution). |
Sets the size of the output image for the specified module.
Parameters: |
|
---|---|
Returns: | Array of booleans with true if success. |
Gets the current color spaces requested for the specified module.
Parameters: |
|
---|---|
Returns: | Array of color spaces (see colorspace). |
Sets the current color spaces requested for the specified module.
Parameters: |
|
---|---|
Returns: | Array of booleans with true if success |
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: |
|
---|---|
Returns: | Parameter’s values. |
Sets the values of a specific parameter for the module current active cameras.
Parameters: |
|
---|---|
Returns: | Array of booleans with true if success. |
Sets a camera’s parameter to its default value.
Parameters: |
|
---|---|
Returns: | Array of booleans with true if success. |
Retrieves the latest images from the video source and returns pointers to the locked AL::ALImage, with data array pointing directly to raw data. There is no format conversion and no copy of the raw buffer.
Warning
Parameters: |
|
---|---|
Returns: | Array of pointers to the locked AL::ALImage buffer, NULL if error. |
Retrieves the latest images from the video source and send the data coming directly from the raw buffer as an ALValue through the network (no format conversion).
Parameters: |
|
---|---|
Returns: | Container of images. |
Release image buffer locked by getDirectRawImagesLocal(). If the module has no locked image buffer, does nothing.
Parameters: |
|
---|---|
Returns: | true if success |
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
Parameters: |
|
---|---|
Returns: | Array of pointers to locked AL::ALImage buffers, NULL if error (e.g. if the previous images was not released). |
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: |
|
---|---|
Returns: | Container of images. |
Release image buffers locked by getImagesLocal(). If module had no locked image buffers, does nothing.
Parameters: |
|
---|---|
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).
Records in background an .arv raw format video from the images processed by the module.
Parameters: |
|
---|---|
Returns: | true if success. |
import time
#import Image
from naoqi import ALProxy
import vision_definitions
# Put here IP and Port of a broker containg basicMotionDetector
IP = "127.0.0.1" # Put here the IP address of your robot
PORT=9559
#________________________________
# Get Proxy on ALVideoDevice
#________________________________
try:
camProxy = ALProxy("ALVideoDevice",IP,PORT)
except Exception,e:
print "Error when creating vision proxy:"
print str(e)
exit(1)
#________________________________
# Vision module creation
#________________________________
resolution = vision_definitions.kQVGA
colorSpace = vision_definitions.kYUV422ColorSpace
fps = 30
nameId = "pythonVM"
nameId = camProxy.subscribe(nameId, resolution, colorSpace, fps)
#________________________________
# Ask to grab a maximum of 3500
# images obtained by the vision module
#________________________________
print "set recording file"
camProxy.recordVideo(nameId, "/home/nao/myVideo", 3500, 1)
print "launch recording"
#________________________________
# The vision module requests 300 images
#________________________________
for i in range(0, 300):
image = camProxy.getImageLocal(nameId)
camProxy.releaseImage(nameId)
time.sleep(0.030)
#________________________________
# Stop manually the recording
# after 300 images
#________________________________
print "finishing"
camProxy.stopVideo(nameId)
camProxy.unsubscribeAllInstances(nameId)
print 'end of script'
Stops writing the video sequence.
Parameters: |
|
---|---|
Returns: | true if success. |
Loads Image into kernel circular buffer. Simulates acquisition of a new image by the virtual camera.
Parameters: |
|
---|---|
Returns: | true if success. |
Called by the simulator to know expected image parameters
Returns: | ALValue of expected parameters: [int height, int width, int framerate] |
---|
Returns position as angles relative to camera axis given a normalized position in the image.
Parameters: |
|
---|---|
Returns: | corresponding angles values in radians. |
Returns a normalized position in the image from a position expressed with camera angles in radians.
Parameters: |
|
---|---|
Returns: | corresponding normalized position in the image [0.0 - 1.0] |
From a normalized size in the image, returns size expressed as angles in radian relative to camera axis.
Parameters: |
|
---|---|
Returns: | corresponding angles values in radians. |
Returns a normalized size from a size expressed with camera angles in radians.
Parameters: |
|
---|---|
Returns: | corresponding normalized position in the image [0.0 - 1.0] |
Returns [X, Y, width, height] normalized info in the image from these info expressed as angles in radians (as returned by vision extractors).
Parameters: |
|
---|---|
Returns: | corresponding normalized position and size info: [X, Y, width, height]. |
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: |
|
---|---|
Returns: | corresponding pixels position and size info: [X, Y, width, height]. |
Subscribe to ALVideoDevice. When a Video Module registers to ALVideoDevice, a buffer of the requested image format is added to the buffers list. Returns the name under which the V.M. will be known from ALVideoDevice (useful when several V.M. try to subscribe using the same name, the 3rd one getting _3 added to its name for instance).
Parameters: |
|
---|---|
Returns: | Name under which the V.M. is known from ALVideoDevice, NULL if failed. |
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).
Deprecated since version 1.14: use ALVideoDeviceProxy::subscribeCamera() instead.
Used to unsubscribe all instances for a given module (e.g. VisionModule and VisionModule_5) from ALVideoDevice.
Parameters: |
|
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::unsubscribe() instead.
Opens and initialize the video source device if it was not already opened.
Note
The first module subscribing to ALVideoDevice will launch it automatically, so the main purpose of this method is to reduce time when the first vision module is subscribing.
Returns: | true if success |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::startFrameGrabber() instead.
Close the video source device.
Note
When the last vision module subscribed to ALVideoDevice unsubscribes, this doesn’t close the video source device as we assume that if some video was requested before, video will be again requested latter. But if this is not the case, closing the video source will save processing resources.
Returns: | true if success |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::stopFrameGrabber() instead.
Asks if the framegrabber is running or not.
Returns: | true if off |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::isFrameGrabberOff() instead.
Gets the index of the current default active camera.
Returns: | cameraindex. |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getActiveCamera() instead.
#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;
}
Get the resolution of the video source before eventual conversion.
Returns: | { 0 = kQQVGA, 1 = kQVGA, 2 = kVGA, 3 = k4VGA } -1: can’t access video source |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getResolution() instead.
Get the color space of the video source before enventual conversion.
Returns: | { 0 = kYuv, 9 = kYUV422, 10 = kYUV, 11 = kRGB, 12 = kHSY, 13 = kBGR } -1 can’t access video source |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getColorSpace() instead.
Get the internal frame rate of the video source.
Returns: | video source framerate. -1: can’t access video source |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getFrameRate() instead.
Get the resolution of a particular Vision Module
Parameters: |
|
---|---|
Returns: | resolution or -1: can’t access video source |
Deprecated since version 1.14: use ALVideoDeviceProxy::getResolution() instead.
Get the color space of a particular Vision Module.
Parameters: |
|
---|---|
Returns: | colorspace -1: can’t access video source |
Deprecated since version 1.14: use ALVideoDeviceProxy::getColorSpace() instead.
Get 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::getVIMFrameRate() 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: |
|
---|---|
Returns: | The Vision Module framerate, or -1 if we can’t access video source |
Deprecated since version 1.14: use ALVideoDeviceProxy::getFrameRate() instead.
Gets the camera model index of the current default active camera.
Returns: | cameramodel. |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getCameraModel() instead.
Get the value of a video source specific parameter.
Warning
Depending on the type of the video source, available parameters may change.
Parameters: |
|
---|---|
Returns: | Parameter’s value. See below the parameters list according to the type of video source (values are available in Modifying camera parameters ). |
Deprecated since version 1.14: use ALVideoDeviceProxy::getCameraParameter() instead.
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_getparam pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Example: retrieve the ID of the selected camera.
int pVal = cameraProxy.getParam(AL::kCameraSelectID);
std::cout << "AL::kCameraSelectID is " << pVal << std::endl;
return 0;
}
Sets the value of a specific parameter for the video source.
Parameters: |
|
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::setCameraParameter() instead.
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_setparam pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// For example, set the current selected camera to top camera.
cameraProxy.setParam(AL::kCameraSelectID, 0);
std::cout << "AL::kCameraSelectID has been set to " << 0 << std::endl;
return 0;
}
Sets a specific parameter for the video source at its default value.
Parameters: |
|
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::setCameraParameterToDefault() instead.
alvideodevice_setparamdefault.cpp
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
#include <iostream>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_setparamdefault pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// For example, set the current selected camera to default.
cameraProxy.setParamDefault(AL::kCameraSelectID);
std::cout << "AL::kCameraSelectID has been set to default value "
<< cameraProxy.getParam(AL::kCameraSelectID) << std::endl;
return 0;
}
Returns position as angles relative to camera axis given a normalized position in the image.
Parameters: |
|
---|---|
Returns: | corresponding angles values in radians. |
Deprecated since version 1.14: use ALVideoDeviceProxy::getAngularPositionFromImagePosition() instead.
#include <iostream>
#include <vector>
#include <alproxies/alvideodeviceproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_imagetoangle pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Example of a normalized position in the image.
float x = 0.2f, y = 0.7f;
std::vector<float> posUV;
posUV.push_back(x);
posUV.push_back(y);
// Retrieve the corresponding angles.
std::vector<float> camAngles = cameraProxy.getAngPosFromImgPos(posUV);
std::cout << "Position " << posUV << " corresponds to angles "
<< camAngles << std::endl;
// Example of a normalized object size.
float sizeX = 0.1f, sizeY = 0.3f;
posUV.clear();
posUV.push_back(sizeX);
posUV.push_back(sizeY);
// Retrieve corresponding angle size.
std::vector<float> angSize = cameraProxy.getAngSizeFromImgSize(posUV);
std::cout << "Object size " << posUV << "corresponds to angle size "
<< angSize << std::endl;
return 0;
}
From a normalized size in the image, returns size expressed as angles in radian relative to camera axis.
Parameters: |
|
---|---|
Returns: | corresponding angles values in radians. |
Deprecated since version 1.14: use ALVideoDeviceProxy::getAngularSizeFromImageSize() instead.
#include <iostream>
#include <vector>
#include <alproxies/alvideodeviceproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_imagetoangle pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Example of a normalized position in the image.
float x = 0.2f, y = 0.7f;
std::vector<float> posUV;
posUV.push_back(x);
posUV.push_back(y);
// Retrieve the corresponding angles.
std::vector<float> camAngles = cameraProxy.getAngPosFromImgPos(posUV);
std::cout << "Position " << posUV << " corresponds to angles "
<< camAngles << std::endl;
// Example of a normalized object size.
float sizeX = 0.1f, sizeY = 0.3f;
posUV.clear();
posUV.push_back(sizeX);
posUV.push_back(sizeY);
// Retrieve corresponding angle size.
std::vector<float> angSize = cameraProxy.getAngSizeFromImgSize(posUV);
std::cout << "Object size " << posUV << "corresponds to angle size "
<< angSize << std::endl;
return 0;
}
Returns [X, Y, width, height] normalized info in the image from these info expressed as angles in radians (as returned by vision extractors).
Parameters: |
|
---|---|
Returns: | corresponding normalized position and size info: [X, Y, width, height]. |
Deprecated since version 1.14: use ALVideoDeviceProxy::getImageInfoFromAngularInfo() instead.
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: |
|
---|---|
Returns: | corresponding pixels position and size info: [X, Y, width, height]. |
Deprecated since version 1.14: use ALVideoDeviceProxy::getImageInfoFromAngularInfoWithResolution() instead.
Returns a normalized position in the image from a position expressed with camera angles in radians.
Parameters: |
|
---|---|
Returns: | corresponding normalized position in the image [0.0 - 1.0] |
Deprecated since version 1.14: use ALVideoDeviceProxy::getImagePositionFromAngularPosition() instead.
alvideodevice_angletoimage.cpp
#include <iostream>
#include <vector>
#include <alproxies/alvideodeviceproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage videodevice_angletoimage pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Example camera angles.
std::vector<float> camAngles;
camAngles.push_back(0.1f);
camAngles.push_back(0.1f);
// Retrieve image position in pixels.
std::vector<float> imgPos = cameraProxy.getImgPosFromAngPos(camAngles);
std::cout << "Camera angles " << camAngles << " correspond to "
<< imgPos << " in pixels" << std::endl;
camAngles.clear();
// Example camera angle size.
camAngles.push_back(0.1f);
camAngles.push_back(0.3f);
// Retrieve object size in pixels.
std::vector<float> imSize = cameraProxy.getImgSizeFromAngSize(camAngles);
std::cout << "Angle size " << imSize << " corresponds to "
<< imSize << " size in pixels" << std::endl;
return 0;
}
Returns a normalized size from a size expressed with camera angles in radians.
Parameters: |
|
---|---|
Returns: | corresponding normalized position in the image [0.0 - 1.0] |
Deprecated since version 1.14: use ALVideoDeviceProxy::getImageSizeFromAngularSize() instead.
#include <iostream>
#include <vector>
#include <alproxies/alvideodeviceproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage videodevice_angletoimage pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Example camera angles.
std::vector<float> camAngles;
camAngles.push_back(0.1f);
camAngles.push_back(0.1f);
// Retrieve image position in pixels.
std::vector<float> imgPos = cameraProxy.getImgPosFromAngPos(camAngles);
std::cout << "Camera angles " << camAngles << " correspond to "
<< imgPos << " in pixels" << std::endl;
camAngles.clear();
// Example camera angle size.
camAngles.push_back(0.1f);
camAngles.push_back(0.3f);
// Retrieve object size in pixels.
std::vector<float> imSize = cameraProxy.getImgSizeFromAngSize(camAngles);
std::cout << "Angle size " << imSize << " corresponds to "
<< imSize << " size in pixels" << std::endl;
return 0;
}
Called by the simulator to know expected image parameters
Returns: | ALValue of expected parameters: [int height, int width, int framerate] |
---|
Deprecated since version 1.14: use ALVideoDeviceProxy::getExpectedImageParameters() instead.
Set parameters for the images that the simulator will provide.
Parameters: |
|
---|---|
Returns: | true if success |
Deprecated since version 1.14: use ALVideoDeviceProxy::putImage() instead.
Allow image buffer pushing
Parameters: |
|
---|---|
Returns: | true if success |
Deprecated since version 1.14: use ALVideoDeviceProxy::putImage() instead.
return the width and the height of a resolution
Parameters: |
|
---|---|
Returns: | array of sizes: (return [-1;-1] if the format is invalid) [0] : width; [1] : height; |
Deprecated since version 1.14: use AL::setSizeFromResolution instead.
alvideodevice_resolutiontosizes.cpp
#include <iostream>
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage videodevice_resolutiontosizes pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Retrieve current image size.
AL::ALValue size = cameraProxy.resolutionToSizes(AL::kVGA);
std::cout << "Image width is " << size[0] << " and image height is "
<< size[1] << std::endl;
return 0;
}
return the resolution from sizes
Parameters: |
|
---|---|
Returns: | resolution or -1 if the inputs are invalid |
Deprecated since version 1.14: use AL::getResolutionFromSize instead.
alvideodevice_siizestoresolution.cpp
#include <iostream>
#include <alproxies/alvideodeviceproxy.h>
#include <alvision/alvisiondefinitions.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: videodevice_sizestoresolution pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Proxy to ALVideoDevice.
AL::ALVideoDeviceProxy cameraProxy(pIp);
// Get resolution of the currently selected camera.
int resolution = cameraProxy.sizesToResolution(640, 480);
switch(resolution) {
case 0:
std::cout << "Current resolution is QQVGA" << std::endl;
break;
case 1:
std::cout << "Current resolution is QVGA" << std::endl;
break;
case 2:
std::cout << "Current resolution is VGA" << std::endl;
break;
default:
std::cerr << "Unknown resolution" << std::endl;
break;
}
return 1;
}
Camera Index
Camera Index can have the following values:
Parameter ID Name | ID Value | Description |
---|---|---|
AL::kTopCamera | 0 | camera on the top. |
AL::kBottomCamera | 1 | camera on the bottom. |
Camera Model
Camera Model can have the following values:
Parameter ID Name | ID Value | Description |
---|---|---|
AL::kOV7670 | 1 | VGA Camera |
AL::kMT9M114 | 2 | HD Camera |
Resolution
Resolution parameter can have the following values:
Parameter ID Name | ID Value | Description |
---|---|---|
AL::kQQVGA | 0 | Image of 160*120px |
AL::kQVGA | 1 | Image of 320*240px |
AL::kVGA | 2 | Image of 640*480px |
AL::k4VGA | 3 | Image of 1280*960px |
Note
AL::k4VGA is only available on NAO V4 (camera HD MT9M114).
Color Space
A color space is a model describing the way to represent color as an ordered list of numbers. For example you can represent the color of each pixel of your screen as a list of three elements R, G and B. Which are respectively the value of Red, Green, and Blue usually store in an byte (range from 0 to 255).
Setting the color space allows you to set the image buffer encoding in AL::ALImage.
Color space parameter can have the following values:
Parameter ID Name | ID Value | Number of channels | Description |
---|---|---|---|
AL::kYuvColorSpace | 0 | 1 | Buffer only contains the Y (luma component) equivalent to one unsigned char |
AL::kyUvColorSpace | 1 | 1 | Buffer only contains the U (Chrominance component) equivalent to one unsigned char |
AL::kyuVColorSpace | 2 | 1 | Buffer only contains the V (Chrominance component) equivalent to one unsigned char |
AL::kRgbColorSpace | 3 | 1 | Buffer only contains the R (Red component) equivalent to one unsigned char |
AL::krGbColorSpace | 4 | 1 | Buffer only contains the G (Green component) equivalent to one unsigned char |
AL::krgBColorSpace | 5 | 1 | Buffer only contains the B (Blue component) equivalent to one unsigned char |
AL::kHsyColorSpace | 6 | 1 | Buffer only contains the H (Hue component) equivalent to one unsigned char |
AL::khSyColorSpace | 7 | 1 | Buffer only contains the S (Saturation component) equivalent to one unsigned char |
AL::khsYColorSpace | 8 | 1 | Buffer only contains the Y (Brithness component) equivalent to one unsigned char |
AL::kYUV422ColorSpace | 9 | 3 | Native format, 0xY’Y’VVYYUU equivalent to four unsigned char for two pixels. With Y luma for pixel n, Y’ luma for pixel n+1, and U and V are the average chrominance value of both pixels. |
AL::kYUVColorSpace | 10 | 3 | Buffer contains triplet on the format 0xVVUUYY, equivalent to three unsigned char |
AL::kRGBColorSpace | 11 | 3 | Buffer contains triplet on the format 0xBBGGRR, equivalent to three unsigned char |
AL::kHSYColorSpace | 12 | 3 | Buffer contains triplet on the format 0xYYSSHH, equivalent to three unsigned char |
AL::kBGRColorSpace | 13 | 3 | Buffer contains triplet on the format 0xRRGGBB, equivalent to three unsigned char |
AL::kYYCbCrColorSpace | 14 | 3 | TIFF format, four unsigned chararacters for two pixels. |
AL::kH2RGBColorSpace | 15 | 3 | H from “HSY to RGB” in fake colors. |
AL::kHSMixedColorSpace | 16 | 3 | HS and (H+S)/2. |
Frame Rate
The OV7670 VGA camera can only run at 30, 15, 10 and 5fps (frame per second). On the contrary MT9M114 HD camera will be able to run from 1 to 30fps.
Note
On camera OV7670, the framerate is automaticaly set to the upper closest available frmae rate. (e.g. if you set framerate to 12, it will be setup to 15 internaly)
Image
Image container is an array as follow:
Images
Images container is an array of arrays as follow: