Ask Your Question

sweeneychris's profile - activity

2016-08-03 14:02:19 -0600 answered a question Problem with OpenCV camera calibration from video file

I had the same issue. This is because OpenCV tries to open the video file as an xml file and crashes. I modified my readStringList function with a try-catch and it works for me:

static bool readStringList(const string& filename, vector<string>& l) {
    l.clear();
    FileStorage fs;
    try {
      fs.open(filename, FileStorage::READ);
    } catch (...) {
      return false;
    }
    if (!fs.isOpened()) return false;
    FileNode n = fs.getFirstTopLevelNode();
    if (n.type() != FileNode::SEQ) return false;
    FileNodeIterator it = n.begin(), it_end = n.end();
    for (; it != it_end; ++it) l.push_back((string)*it);
    return true;
  }
2016-04-01 12:23:23 -0600 received badge  Supporter (source)
2016-04-01 12:17:51 -0600 commented answer How to convert pixel segmentation to polylines?

You can treat each superpixel segment as a polygon and then decimate the polygon with Douglas Peucker, but this does not enforce that the boundaries between each polygon are consistent. So using findCountours will not work in my case.

I am thinking that tracing boundaries explicitly may be the only way. I'm hoping for a faster solution though.

2016-04-01 01:42:39 -0600 received badge  Student (source)
2016-04-01 00:49:23 -0600 asked a question How to convert pixel segmentation to polylines?

I have a pixel segmentation created from a superpixel algorithm such as this. So for each pixel I have a label for which "superpixel" (i.e. group) it belongs to. I would like to convert the boundaries between superpixels into polylines instead of pixels so that they may be simplified with the Douglas-Peucker algorithm.

My problem is that I cannot figure out how to go from the superpixel labels to polylines. It is trivial to draw the superpixel boundaries (see attached image) but I am having trouble understanding how to convert those boundaries to polylines. Any suggestions would be really appreciated!

image description