# ALSegmentation3D API¶

NAOqi Vision - Overview | API

This module requires a robot with a 3D sensor.

Namespace : AL


#include <alproxies/alsegmentation3Dproxy.h>



## Method list ¶

class ALSegmentation3DProxy

## Methods ¶

Returns: The current value of DepthThreshold (in meters) for the segmentation. The default value is 0.05m. See definition of DepthThreshold in section Segmentation.
float ALSegmentation3DProxy::getBlobTrackingDistance()
Returns: The current value of BlobTrackingDistance (in meters). See definition of BlobTrackingDistance in section Blob tracking.
AL::ALValue ALSegmentation3DProxy::getTopOfBlob(const float& dist, const int& frame, const bool& applyVerticalOffset)

This function is like a “one-shot” version of the Blob tracking

Returns the position of the TopOfBlob of the blob the most in the center, present at a distance near the given distance dist.

Parameters: dist – Distance criterion in order to filter the segmentated blobs. By setting dist to -1, it it possible to bypass this criterion and just select the nearest blob to the robot. frame – Used to select the frame in which the position will be returned (-1 for the frame of the image, 0 for FRAME_TORSO, 1 for FRAME_WORLD and 2 for FRAME_ROBOT). applyVerticalOffset – Used to choose if the VerticalOffset must be applied. This offset will not be applied if the TopOfBlob belongs to the top border of the depth image. If frame equals -1, result = [xAngle, yAngle, distBlob] where [xAngle,yAngle] are the angular coordinates in the image and distBlob is the real distance of the blob with respect ot the camera. If frame equals 0,1 or 2, result = [x, y, z] where [x,y,z] are the coordinates in the corresponding frame.
float ALSegmentation3DProxy::getVerticalOffset()
Returns: The current value of the VerticalOffset (in meters). The default value is -0.2m. A negative value means that the offset will be substracted to the position of TopOfBlob. See definition of VerticalOffset in section Blob tracking.
bool ALSegmentation3DProxy::isBlobTrackingEnabled()
Returns: true if blob tracking is running, false otherwise.
void ALSegmentation3DProxy::setBlobTrackingDistance(const float& distance)

Sets the value of BlobTrackingDistance. See definition of BlobTrackingDistance in section Blob tracking.

Parameters: distance – New BlobTrackingDistance (in meters), -1 to track the nearest blob.
void ALSegmentation3DProxy::setBlobTrackingEnabled(const bool& status)

Turns on or off the blob tracking.

Parameters: status – true to turn on the blob tracking, false to turn it off.
void ALSegmentation3DProxy::setDeltaDepthThreshold(const float& threshold)

Sets the value of DepthThreshold (in meters) used for the segmentation. See definition of DepthThreshold in section Segmentation.

Parameters: threshold – New DepthThreshold value (must be positive).
void ALSegmentation3DProxy::setVerticalOffset(const float& offset)

Sets the value of VerticalOffset. See definition of VerticalOffset in section Blob tracking.

Parameters: threshold – New VerticalOffset value (in meters). A negative value means that the offset will be substracted to the position of TopOfBlob.

## Events ¶

Event: "ALTracker/BlobDetected"
callback(std::string eventName, AL::ALValue result, std::string subscriberIdentifier)

Raised each time the tracked blob is detected, with a structure that can be used with function ALTrackerProxy::trackEvent() of the module ALTracker. For more details, see: Blob tracking.

Event: "Segmentation3D/BlobTrackerUpdated"
callback(std::string eventName, std::string subscriberIdentifier)

Raised each time the tracked blob is detected. The information about the updated position of the tracked blob can be accessed using the memory key Segmentation3D/TopOfTrackedBlob. For more details, see: Blob tracking.

Event: "Segmentation3D/SegmentationUpdated"
callback(std::string eventName, std::string subscriberIdentifier)

Raised each time segmentation is computed. The description of the blobs of the updated segmentation can be accessed using the memory key Segmentation3D/BlobsList. For more details, see: Segmentation.

Event: "Segmentation3D/TrackedBlobNotFound"
callback(std::string eventName, std::string subscriberIdentifier)

Raised each time the tracked blob is not detected. For more details, see: Blob tracking.

## Memory Keys ¶

AL::ALValue Segmentation3D/BlobsList

Contains the list of blobs after segmentation.

### Key structure ¶


BlobsList =
[
TimeStamp,
[BlobInfo_1, BlobInfo_2, ... BlobInfo_n],
CameraPose_InTorsoFrame,
CameraPose_InRobotFrame,
Camera_Id
]


TimeStamp: this field is the time stamp of the image that was used to perform the detection.


TimeStamp [
TimeStamp_Seconds,
Timestamp_Microseconds
]


BlobInfo_i: each of these fields contains the description of a blob of similar depth:


BlobInfo_i =
[
PositionOfCog,
AngularRoi,
MeanDistance,
RealSizeRoi,
TopOfBlob
]

• PositionOfCog = [xAngle,yAngle] contains the angular coordinates (in radians) of the center of gravity of the blob.
• AngularRoi = [xAngle,yAngle,width, height] contains information about the smallest rectangle (ROI) in which the blob is included. [xAngle,yAngle] corresponds to the angular coordinates (in radians) of the top left corner of the ROI in the current depth image. [width, height] corresponds to the angular size (in radians) of the ROI.
• MeanDistance is the mean distance of the points of the blob, with respect to the depth camera.
• RealSizeRoi = [realwidth, realheight] gives the real size (in meters) of the ROI of the cluster.
• TopOfBlob = [xAngle,yAngle] contains the angular coordinates (in radians) of the TopOfBlob.

CameraPose_InTorsoFrame: describes the Position6D of the depth camera at the time the image was taken, in FRAME_TORSO.

CameraPose_InRobotFrame: describes the Position6D of the depth camera at the time the image was taken, in FRAME_ROBOT.

Camera_Id: gives the Id of the depth camera used for the detection.

AL::ALValue Segmentation3D/TopOfTrackedBlob

Contains the infomation about the tracked blob.

### Key structure ¶


TopOfTrackedBlob =
[
TimeStamp,
Position,
CameraPose_InTorsoFrame,
CameraPose_InRobotFrame,
Camera_Id
]


TimeStamp: this field is the time stamp of the image that was used to perform the detection.


TimeStamp [
TimeStamp_Seconds,
Timestamp_Microseconds
]


Position = [xAngle,yAngle,distance], where [xAngle,yAngle] are the angular coordinates (in radians) in the image of the top of the blob after applying the offset, and distance is the distance between the blob and the camera.

CameraPose_InTorsoFrame: describes the Position6D of the depth camera at the time the image was taken, in FRAME_TORSO.

CameraPose_InRobotFrame: describes the Position6D of the depth camera at the time the image was taken, in FRAME_ROBOT.

Camera_Id: gives the Id of the depth camera used for the detection.