robotology/iol

Get blob's pixel list

Closed this issue · 5 comments

Hi,

In order to be able to use lbpExtractor to substitute the classic graphBasedSegmentation in some applications, it would be very useful if the interface could be replicated. Particularly, the option of querying for the list of pixels that belong to any of the segmented blobs would be really useful (mostly for point cloud reconstruction).

The rpc command for that query is get_component_around followed by the x and y coordinates of a seed point, and the reply should contain a list of pixel coordinates, formatted as a bottle of bottles.

In details, here is a code snippet to show the use of this interface:

// Get segmented region from external segmentation module
Bottle cmdSeg;
cmdSeg.addString("get_component_around");
cmdSeg.addInt(seed.x);
cmdSeg.addInt(seed.y);

Bottle replySeg;
if (portSeg.write(cmdSeg,replySeg))
{
    Bottle* pixelList=replySeg.get(0).asList();
    cv::Mat binImg = cv::Mat(imgDispInMat.rows, imgDispInMat.cols, CV_8U, 0.0);
    for (int i=0; i<pixelList->size(); i++)
    {
        Bottle* point=pixelList->get(i).asList();
        int x = point->get(0).asDouble();
        int y = point->get(1).asDouble();
        binImg.at<uchar>(y,x) = 255;
    }
}

Thanks in advance!
Tanis

@tanismar, I think you meant to refer to lbpExtractor module in your post, is that right?

If so, @vtikha could consider endorsing such a request.

@pattacini yes it is for the lbpExtractor module. I asked @tanismar to put his request here in order not to forget about it.

👍

yup.. sorry I forgot to mention the particular module I was referring to.

@tanismar request has been committed.