Пример #1
0
bool FileListSequence::read_listing(const string listing)
{

  std::string line;

  std::ifstream listing_stream (listing.c_str());

  if (listing_stream.is_open())
    {

      while (listing_stream.good())
        {

          getline(listing_stream, line);
//DEBUGMSG("%s %d \n", line.c_str(),file_type(line.c_str()));
          if (file_type(line.c_str()) != FILETYPE_FILE)
            continue;

          files.push_back(string(line));

        }

      listing_stream.close();
    }
  else throw LegitException("Unable to read file");

}
Пример #2
0
int Patches::add(Image& image, PatchType type, Point2f position, float weight)
{

  Ptr<Patch> pch;

  switch (type)
    {
    case HISTOGRAM:
      pch = new HistogramPatch(count++, 10, bufferlimit, psize, psize);
      break;
    case RGBPIXEL:
      pch = new RGBPatch(count++, 10, bufferlimit);
      break;
    case HSPIXEL:
      pch = new HSPatch(count++, 10, bufferlimit);
      break;
    case SSD:
      pch = new SSDPatch(count++, 10, bufferlimit, psize, psize);
      break;
    default:
      throw LegitException("Unknown type");
    }

  pch->push();
  pch->set_position(position);
  pch->set_weight(weight);

  pch->initialize(image, position);

  //calculate_histogram(image, position, psize, pch->histogram);

  patches.push_back(pch);

  return patches.size();
}
Пример #3
0
        /**
        Basic HSV FB-BG color histogram modality that uses OpenCV histograms.


        */
        ModalityColor3DHistogram::ModalityColor3DHistogram(string configbase) : Modality(configbase), has_data(false) {

            channels[0] = 0;
            channels[1] = 1;
            channels[2] = 2;
            histSize[0] = 16;
            histSize[1] = 16;
            histSize[2] = 4;

            string cspace = "hsv";

            if (cspace == "hsv") {
                colorspace = IMAGE_FORMAT_HSV;
                ranges1[0] = 0;
                ranges1[1] = 180; // 180.0f / 256.0f;
                ranges2[0] = 0;
                ranges2[1] = 256; //1.0f;
                ranges3[0] = 0;
                ranges3[1] = 256; // 1.0f;
            } else if (cspace == "rgb") {
                colorspace = IMAGE_FORMAT_RGB;
                ranges1[0] = 0;
                ranges1[1] = 256; //1.0f;
                ranges2[0] = 0;
                ranges2[1] = 256; // 1.0f;
                ranges3[0] = 0;
                ranges3[1] = 256; //1.0f;
            } else if (cspace == "ycrcb") {
                colorspace = IMAGE_FORMAT_YCRCB;
                ranges1[0] = 0;
                ranges1[1] = 256; //1.0f;
                ranges2[0] = 0;
                ranges2[1] = 256; // 1.0f;
                ranges3[0] = 0;
                ranges3[1] = 256; //1.0f;
            } else { throw LegitException("Unrecognized color space"); }

            ranges[0] = ranges1;
            ranges[1] = ranges2;
            ranges[2] = ranges3;

            foreground.create(3, histSize, CV_32F);
            background.create(3, histSize, CV_32F);
            model.create(3, histSize, CV_32F);

            foreground_presistence = 0.95;
            background_presistence = 0.5;

            foreground_size = 0.7;
            background_margin = 10;
            background_size = 35;



            flush();
        }