コード例 #1
0
void RegionGrowingHSV::applySmoothRegionGrowingAlgorithm()
{
    point_labels_.resize (num_pts, -1);
    std::vector<std::vector<int> > Area_cluster;
    std::vector<int> isaac;
    int seed = 0;

    int number_of_segments = 0;

    std::vector<int> init_seed;
    std::cout<<"calculate seed queue"<<std::endl;
    computeInitalSeed(init_seed);
    if( init_seed.size()!=num_pts )
    {
        std::cout<<"error"<<std::endl;
    }

    while (!init_seed.empty())
    {
        // select the seed point index
        seed = init_seed[0];
        init_seed.erase(init_seed.begin());
        if( point_labels_[seed]!=-1 )
            continue;

        Area_cluster.push_back(isaac);
        growRegion (seed, number_of_segments,Area_cluster);
        number_of_segments++;
    }
    number_of_segments_ = number_of_segments;
}
コード例 #2
0
void ImageOverlayRegionFinder::findRegions(bool optimizeForPowersOf2)
{
    m_regions.clear();

    if (!m_overlay.isValid())
    {
        return;
    }

    int rows = m_overlay.getRows();
    int columns = m_overlay.getColumns();
    unsigned char *data = m_overlay.getData();

    // Màscara que indica els píxels visitats
    QBitArray mask(rows * columns);

    for (int row = 0, i = 0; row < rows; row++)
    {
        for (int column = 0; column < columns; column++, i++)
        {
            // Si trobem un objecte no tractat
            if (data[i] > 0 && !mask.testBit(i))
            {
                QRect region = growRegion(row, column, mask);
                addPadding(region);
                addRegion(region, optimizeForPowersOf2);
                removePadding(region);
                fillMaskForRegion(mask, region);
            }
        }
    }
}
コード例 #3
0
	/* ------------------------------------------------------------------------------------------ */
	void run () {

		// Create the interface to the Kinect
		char buf [256];
		sprintf(buf, "#%d", id);
		pcl::Grabber* interface = new pcl::OpenNIGrabber(buf);
		boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
			boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

		// Start the interface
		interface->registerCallback (f);
		interface->start ();

		// Set the callback function to get the points
		cv::Vec3s coords (0, 0, -1);
		cv::namedWindow("image", CV_WINDOW_AUTOSIZE);
    cv::setMouseCallback("image", interact, (void*) (&coords));
		bool update = true;

		// Wait
		int counter = 0;
		int lastMouseInput = -1;
		Eigen::Vector3d sumCenter (0,0,0);
		while (true) { //(!viewer.wasStopped()) {

			// Create the image from cloud data
			pthread_mutex_lock(&lock);
			if(update) makeImage();
			pthread_mutex_unlock(&lock);

			// Get the user input if it exists and grow a region around it
			pthread_mutex_lock(&lock2);
			if((coords[2] > 0)) {
				growRegion(coords[0], coords[1]);
				if(coords[2] > lastMouseInput) {
					counter = 0;
					sumCenter = Eigen::Vector3d(0,0,0);
					cout << "----------- reset" << endl;
					lastMouseInput = coords[2];
				}
				// coords[2] = -1;
				if((!(center(0) != center(0))) && center.norm() > 1e-2) {
					counter++;
					sumCenter += center;
				}
				if(counter >= 100) {
					counter = 0;
					cout << "mean center: " << (sumCenter/100).transpose() << endl;
					sumCenter = Eigen::Vector3d(0,0,0);
				}
				// update = false;
			}
			pthread_mutex_unlock(&lock2);
			usleep(1e4);
		}

		// Stop the interface
		interface->stop ();
	}
コード例 #4
0
ファイル: region_growing.hpp プロジェクト: VictorLamoine/pcl
template <typename PointT, typename NormalT> void
pcl::RegionGrowing<PointT, NormalT>::applySmoothRegionGrowingAlgorithm ()
{
  int num_of_pts = static_cast<int> (indices_->size ());
  point_labels_.resize (input_->points.size (), -1);

  std::vector< std::pair<float, int> > point_residual;
  std::pair<float, int> pair;
  point_residual.resize (num_of_pts, pair);

  if (normal_flag_ == true)
  {
    for (int i_point = 0; i_point < num_of_pts; i_point++)
    {
      int point_index = (*indices_)[i_point];
      point_residual[i_point].first = normals_->points[point_index].curvature;
      point_residual[i_point].second = point_index;
    }
    std::sort (point_residual.begin (), point_residual.end (), comparePair);
  }
  else
  {
    for (int i_point = 0; i_point < num_of_pts; i_point++)
    {
      int point_index = (*indices_)[i_point];
      point_residual[i_point].first = 0;
      point_residual[i_point].second = point_index;
    }
  }
  int seed_counter = 0;
  int seed = point_residual[seed_counter].second;

  int segmented_pts_num = 0;
  int number_of_segments = 0;
  while (segmented_pts_num < num_of_pts)
  {
    int pts_in_segment;
    pts_in_segment = growRegion (seed, number_of_segments);
    segmented_pts_num += pts_in_segment;
    num_pts_in_segment_.push_back (pts_in_segment);
    number_of_segments++;

    //find next point that is not segmented yet
    for (int i_seed = seed_counter + 1; i_seed < num_of_pts; i_seed++)
    {
      int index = point_residual[i_seed].second;
      if (point_labels_[index] == -1)
      {
        seed = index;
        seed_counter = i_seed;
        break;
      }
    }
  }
}
コード例 #5
0
ファイル: region_growing.hpp プロジェクト: 9gel/hellopcl
template <typename PointT> unsigned int
pcl::RegionGrowing<PointT>::applySmoothRegionGrowingAlgorithm ()
{
  int num_of_pts = static_cast<int> (cloud_for_segmentation_->points.size ());
  point_labels_.resize (num_of_pts, -1);

  std::vector< std::pair<float, int> > point_residual;
  std::pair<float, int> pair;
  point_residual.resize (num_of_pts, pair);

  if (normal_flag_ == true)
  {
    for (int i_point = 0; i_point < num_of_pts; i_point++)
    {
      point_residual[i_point].first = normals_->points[i_point].curvature;
      point_residual[i_point].second = i_point;
    }
    std::sort (point_residual.begin (), point_residual.end (), comparePair);
  }
  else
  {
    for (int i_point = 0; i_point < num_of_pts; i_point++)
    {
      point_residual[i_point].first = 0;
      point_residual[i_point].second = i_point;
    }
  }
  int seed_counter = 0;
  int seed = point_residual[seed_counter].second;

  int segmented_pts_num = 0;
  int number_of_segments = 0;
  while (segmented_pts_num < num_of_pts)
  {
    int pts_in_segment;
    pts_in_segment = growRegion (seed, number_of_segments);
    segmented_pts_num += pts_in_segment;
    num_pts_in_segment_.push_back (pts_in_segment);
    number_of_segments++;

    for (int i_seed = seed_counter + 1; i_seed < num_of_pts; i_seed++)
    {
      int index = point_residual[i_seed].second;
      if (point_labels_[index] == -1)
      {
        seed = index;
        break;
      }
    }
  }

  return (number_of_segments);
}
コード例 #6
0
ファイル: colorlut.cpp プロジェクト: AndriiDSD/pixy
int ColorLUT::generateSignature(const Frame8 &frame, const Point16 &point, Points *points, uint8_t signum)
{
	if (signum<1 || signum>CL_NUM_SIGNATURES)
		return -1;
    // this routine requires some memory to store the region which consists of some consistently-sized blocks
    growRegion(frame, point, points);
    IterPixel ip(frame, points);
    iterate(&ip, m_signatures+signum-1);
	m_signatures[signum-1].m_type = 0;

	updateSignature(signum);
    return 0;
}
コード例 #7
0
ファイル: rescalewidget.cpp プロジェクト: davidhesselbom/freq
void RescaleWidget::
        resizeEvent ( QResizeEvent * )
{
    QPolygon poly = recreatePolygon ();
    setMask(growRegion(poly));
}