void PaintBrush::loadImage(const Node& root)
{
    update();
    interactionCount_ = 0;
    actions_.clear();
    vertexList_.clear();
    edgeList_.clear();
    std::list< Node > children = root.children();
    std::list< Node >::iterator it;
    for (it = children.begin(); it != children.end(); ++it)
    {
        if (it->name() == "vertex") vertexList_.push_back(extractVertex(it->children()));
        if (it->name() == "edge") edgeList_.push_back(extractEdge(it->children()));
    }

    // now iterate the edges and update the image.
    std::list< Edge >::iterator eit;
    for (eit = edgeList_.begin(); eit != edgeList_.end(); ++eit)
    {
        Vertex v1 = lookup(eit->v1);
        path_ = WPainterPath(WPointF(v1.x, v1.y));
        path_.addRect(v1.x, v1.y, 1, 1);
        Vertex v2 = lookup(eit->v2);
        path_.lineTo(v2.x, v2.y);
        path_.addRect(v2.x, v2.y, 1, 1);
        actions_.push_back(path_);
    }
    update(PaintUpdate);
}
Position MotionDetector::detect() {
  std::vector<cv::Mat> buffer(buffer_.begin(), buffer_.end());
  int N = buffer.size();
  cv::Size frameSize = buffer[N-1].size();

  std::vector<Position> votes;
  Position p;

  // Method: identify region using three frame difference of detected edges.
  cv::Mat foreground(frameSize.height, frameSize.width, CV_8UC1);
  foreground.setTo(cv::Scalar(0));
  extractForeground(buffer.end() - 4, buffer.end(), foreground);

  cv::Mat edge;
  extractEdge(buffer[N-1], edge);

  cv::Mat motionDiff1;
  cv::bitwise_and(foreground, edge, motionDiff1);
  p = identifyObjectPositionByCenterOfMovingEdge(motionDiff1, 20);
  votes.push_back(p);

  // Method: identify region using sum of multiple frame difference and
  // edge detection.
  cv::Mat foreground2(frameSize.height, frameSize.width, CV_8UC1);
  foreground2.setTo(cv::Scalar(0));
  extractForeground(buffer.begin(), buffer.end(), foreground2);

  cv::Mat motionDiff2;
  cv::bitwise_and(foreground2, edge, motionDiff2);
  p = identifyObjectPositionByCenterOfMovingEdge(motionDiff2, 20);
  votes.push_back(p);

  // Method: identify region using only frame difference.
  p = identifyObjectPositionByWithMotionStrength(foreground, 1.2);
  votes.push_back(p);
  Position voteReuslt = majorityVote(votes);

  // std::cout << "reuslt: ";
  // for (int i = 0; i < votes.size(); ++i) {
  //   std::cout << " " << votes[i];
  // }
  // std::cout << " vote result: " << voteReuslt << std::endl;
  return voteReuslt;
}
Beispiel #3
0
  int
  BrepHandler::extractLoop(const DirectoryEntry* de, bool isOuter, int face) {
    debug("########################## E X T R A C T   L O O P");
    ParameterData params;
    _iges->getParameter(de->paramData(), params);

    int loop = handleLoop(isOuter, face);
    int numberOfEdges = params.getInteger(1);

    int i = 2; // extract the edge uses!
    for (int _i = 0; _i < numberOfEdges; _i++) {
      bool isVertex = (1 == params.getInteger(i)) ? true : false;
      Pointer edgePtr = params.getPointer(i+1);
      int index = params.getInteger(i+2);
      // need to get the edge list, and extract the edge info
      int edge = extractEdge(_iges->getDirectoryEntry(edgePtr), index);
      bool orientWithCurve = params.getLogical(i+3);

      // handle this edge
      handleEdgeUse(edge, orientWithCurve);

      // deal with param-space curves (not generally included in Pro/E output)
      int numCurves = params.getInteger(i+4);
      int j = i+5;
      list<PSpaceCurve> pCurveIndices;
      for (int _j = 0; _j < numCurves; _j++) {
	// handle the param-space curves, which are generally not included in MSBO
	Logical iso = params.getLogical(j);
	Pointer ptr = params.getPointer(j+1);
	pCurveIndices.push_back(PSpaceCurve(_iges,
					    this,
					    iso,
					    ptr));
	j += 2;
      }
      i = j;
    }
    return loop;
  }