示例#1
0
void Gui_DisplayBaseClass::redraw(){
    DEV_INFOS("redrawing");
    cv::Mat tmp_img;
    cv::Point2f offset;
    drawBackground();
    if(!m_processor_hand.getSourceImgAsRGB(tmp_img)){
        if(!m_banner_pixbuf)
            m_banner_pixbuf = Gui_PixbufOpener::pixbufOpen(BANNER_IMG);
            offset = m_ROI.scaleToFitAllocation(m_banner_pixbuf, m_pixbuf);
    }
    else{
        m_banner_pixbuf.clear();
        cv::Point2f raw_img_dim(tmp_img.cols,tmp_img.rows);
        m_ROI.update(raw_img_dim);
        tmp_img(m_ROI).copyTo(tmp_img);
        offset = m_ROI.scaleToFitAllocation(tmp_img, m_img_to_display);
        m_pixbuf = Gdk::Pixbuf::create_from_data((guint8*)m_img_to_display.data,Gdk::COLORSPACE_RGB,false,
                                                8,m_img_to_display.cols,m_img_to_display.rows,m_img_to_display.step);




        //show mask

        if(getMask(tmp_img) && m_show_mask){

            DEV_INFOS("drawing mask "<<cv::Point2f(tmp_img.rows,tmp_img.cols)<<" vs "<<raw_img_dim);
            tmp_img(m_ROI).copyTo(tmp_img);
            cv::LUT(tmp_img,m_LUT,tmp_img);

            m_ROI.scaleToFitAllocation(tmp_img, tmp_img,true);

            m_mask_pixbuf = Gdk::Pixbuf::create_from_data((guint8*)tmp_img.data,Gdk::COLORSPACE_RGB,false,
                                                    8,tmp_img.cols,tmp_img.rows,tmp_img.step);
            m_mask_pixbuf = m_mask_pixbuf->add_alpha(true,0,0,0);
            m_mask_pixbuf->composite 	( 	m_pixbuf,0,0,
                m_mask_pixbuf->get_width(),m_mask_pixbuf->get_height(),
                0,0,1,1,Gdk::INTERP_NEAREST,
                m_alph_mask//int  	overall_alpha
                );


        }


    }
    m_pixbuf->render_to_drawable(get_window(), get_style()->get_black_gc(),0, 0,
                  offset.x, offset.y, m_pixbuf->get_width(), m_pixbuf->get_height(),Gdk::RGB_DITHER_NONE, 0, 0);

    if(m_draw_result)
        m_deco.decorate();

}
示例#2
0
/**
 * @brief Tests QR detection with a zero-sized image. Should return 0 qrs
 */
TEST_F(QrDetectionTest, zero_sized_image_test)
{
  cv::Mat tmp_img(0, 0, CV_8UC1);
  std::vector<QrCode> qrs;
  qrs = qr_detector_->detectQrs(tmp_img);
  EXPECT_EQ(0, qrs.size());
}
TEST_F(QrDetectionTest, zero_sized_image_test)
{
  cv::Mat tmp_img(0, 0, CV_8UC1);
  std::vector<cv::Point> points;
  std::vector<std::string> messages;
  qr_detector_->detectQrs(tmp_img, points, messages);
  EXPECT_EQ(0, messages.size());
}
TEST_F(FaceDetectionTest, zero_sized_image_test)
{
  cv::Mat tmp_img(0, 0, CV_8UC1);
  std::vector<cv::Rect> faces = face_detector_->detectFaces(tmp_img);
  EXPECT_EQ(0,faces.size());
}
示例#5
0
ImageT<int> *relabelOutput (Image &Img, char *labelname, char *descr)
{
  Image hist = Img.calcHistogram(0, 256, 256);
  int max = 255;

  while (hist.getInt (max, 0, 0) == 0 && max > 0)
    max--;

  if (!max) {
    cout << "no texture classes in output segmentation!" << endl;
    exit (-1);
  }
  else
    cout << "identified " << max << " texture classes in segmentation result" << endl;

  ImageT<int> *result_img = new ImageT<int>(Img.sizeX (), Img.sizeY ());
  result_img->typeImage(_PFM_SINT);

  ImageT<int> tmp_img(Img.sizeX(), Img.sizeY());
  tmp_img.typeImage(_PFM_SINT);

  cout << "neue Bilder angelegt" << endl;

  int *dest, *source;
  unsigned char *orig;

  int sumlabel[max + 1];
  memset(sumlabel, 0, sizeof (int) * (max + 1));

  cout << "memset Befehl" << endl;

  // sumlabel stores the number of labels found for each class,
  // labelling should start with 1
  sumlabel[0] = 1;

  for (int i = 1; i <= max; i++) {
    dest = tmp_img.data();
    orig = (unsigned char *) Img.data();

  cout << "Schleife über i" << endl;

    // extract one class and prepare it for labelling
    for (int j = 0; j < Img.sizeImage (); ++j, ++dest, ++orig)
      if (*orig == i)
        *dest = 0;
      else
        *dest = 1;

    // label the current class and store the number of labels
    // label 0 and 1 are background and label border --> throw them away (-2)!
    sumlabel[i] = labelImage(tmp_img) - 2;

    // sum up the labelnumbers for fusion of the different classes
    sumlabel[i] += sumlabel[i - 1];

    // shift the labels, so that they are unique (fusion)
    source = tmp_img.data();
    dest = result_img->data();
    for (int j = 0; j < tmp_img.sizeImage(); ++j, ++dest, ++source) {
      // if the label is not background or border (-2), add it to the result
      if (*source > 1)
        *dest = *source - 2 + sumlabel[i - 1];
    }
    tmp_img.clear();
  }

  cout << "image relabeled" << endl;

  // generate the label description

  ImageT<int> list;
  calcBoundingBoxes(list, *result_img, sumlabel[max]);

  FILE *fp = fopen (descr, "w");
  if (!fp)
  {
    cout << "error opening file " << descr << " for writing." << endl;
    exit (-1);
  }

  // list only the labels with value greater than zero (0 is background)
  for (int i = 1, j = 0; i < sumlabel[max]; ++i)
  {
    if (i >= sumlabel[j + 1])
      j ++;

    fprintf(fp, "<region class=\"class%i\" id=\"%d\" p=\"0.7\" file=\"%s\" llx=\"%d\" lly=\"%d\" urx=\"%d\" ury=\"%d\" />\n",
  				  j+1, i, labelname, list[0][i], list[1][i], list[2][i], list[3][i]);
  }
  cout << "Regionenbeschreibung erzeugt" << endl;
  fclose(fp);

  return (result_img);
}