Exemplo n.º 1
0
void MovieTickets::on_edit_image_clicked(){
	QString image_name(this->window.edit_image_lineEdit->text());
	
	QPixmap* image;
	if(image_name.length() > 0){
		QString image_full_path(this->image_path);
		image_full_path.append(image_name);

		image = new QPixmap(image_full_path);

		if(image->isNull()){
			image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
		}
	}
	else{
		image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
	}
	
	QPixmap aux = image->scaledToWidth(this->window.edit_image_label->width());

	if(aux.height() > this->window.edit_image_label->height()){
		aux = image->scaledToHeight(this->window.edit_image_label->height());
	}

	this->window.edit_image_label->setPixmap(aux);
}
Exemplo n.º 2
0
void pp_export(PGconn * conn, const char * query)
{

	const int ascFmt = 0;
	int len = 0, i;
	int rows, ncol, icol;
	char * val;
	char * file;
	PGresult * res;
	const char * const * ival = (const char * const *) &val;
	FILE * fimg;

	/* execute the user provided query */
	res = PQexecParams(conn, query,
			0, //n. of params
			NULL, //oids guessed by backend
			NULL,
			NULL,
			NULL,
			ascFmt);
	if (PQresultStatus(res) != PGRES_TUPLES_OK) {
		pp_print_error(PQerrorMessage(conn));
		PQclear(res);
		return;
	}

	/* some check */
	icol = PQfnumber(res, opts.imagecol);
	if(icol==-1) {
		fprintf(stderr, "ERROR: Image column '%s' does not exist in result set.\n", opts.imagecol);
		PQclear(res);
		return;
	}
	if (!opts.nameprefix) {
		ncol = PQfnumber(res, opts.namecol);
		if(ncol==-1) {
			fprintf(stderr, "ERROR: Name column '%s' does not exist in result set.\n", opts.namecol);
			PQclear(res);
			return;
		}
	}
	rows = PQntuples(res);
	
	/* fetch the data and save */
	for (i = 0; i < rows; ++i) {
		val = PQunescapeBytea( PQgetvalue(res, i, icol), &len);
		if(opts.namecol) file = PQgetvalue(res, i, ncol);
		else file = image_name(opts.nameprefix, i);
		fimg = fopen(file, "w");
		fwrite(val, len, 1, fimg);
		fclose(fimg);
		PQfreemem(val);
		fprintf(stderr, "INFO: exported file %s\n", file);
	}
	PQclear(res);
}
Exemplo n.º 3
0
image_manager::image_manager(running_machine &machine)
	: m_machine(machine)
{
	// make sure that any required devices have been allocated
	for (device_image_interface &image : image_interface_iterator(machine.root_device()))
	{
		// ignore things not user loadable
		if (!image.user_loadable())
			continue;

		// is an image specified for this image
		const char *image_name_ptr = machine.options().value(image.instance_name());
		if ((image_name_ptr != nullptr) && (image_name_ptr[0] != '\0'))
		{
			image_init_result result = image_init_result::FAIL;
			std::string image_name(image_name_ptr);

			// mark init state
			image.set_init_phase();

			// try as a softlist
			if (software_name_parse(image_name))
				result = image.load_software(image_name);

			// failing that, try as an image
			if (result != image_init_result::PASS)
				result = image.load(image_name);

			// failing that, try creating it (if appropriate)
			if (result != image_init_result::PASS && image.support_command_line_image_creation())
				result = image.create(image_name);

			// did the image load fail?
			if (result != image_init_result::PASS)
			{
				// retrieve image error message
				std::string image_err = std::string(image.error());

				// unload all images
				unload_all();

				fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s",
					image.device().name(),
					image_name.c_str(),
					image_err.c_str());
			}
		}
	}

	machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this));
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{
  if(argc != 2)
  {
    std::cerr << "Usage: image" << std::endl;
    return(0);
  }
  
  // read image
  std::string image_name(argv[1]);
  cv::Mat image = cv::imread(image_name,-1);
    
  // start creating parameters
  v4r::LocationSaliencyMap locationSaliencyMap;
  locationSaliencyMap.setWidth(image.cols);
  locationSaliencyMap.setHeight(image.rows);

  cv::Mat map;
  
  locationSaliencyMap.setLocation(v4r::AM_TOP);
  printf("[INFO]: Computing location map AM_TOP.\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }

  locationSaliencyMap.setLocation(v4r::AM_CENTER);
  printf("[INFO]: Computing location map AM_CENTER.\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }

  locationSaliencyMap.setLocation(v4r::AM_RIGHT_CENTER);
  printf("[INFO]: Computing location map AM_RIGHT_CENTER.\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }

  locationSaliencyMap.setLocation(v4r::AM_BOTTOM_CENTER);
  printf("[INFO]: Computing location map AM_BOTTOM_CENTER.\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }

  locationSaliencyMap.setLocation(v4r::AM_RIGHT);
  printf("[INFO]: Computing location map AM_RIGHT.\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }

  locationSaliencyMap.setLocation(v4r::AM_LOCATION_CUSTOM);
  locationSaliencyMap.setCenter(cv::Point(50,50));
  printf("[INFO]: Computing location map AM_LOCATION_CUSTOM, cv::Point(50,50).\n");
  locationSaliencyMap.calculate();
  
  if(locationSaliencyMap.getMap(map))
  {
    printf("[INFO]: Computation completed.\n");
    cv::imshow("Location Map",map);
    printf("[INFO]: Press any key to continue.\n");
    cv::waitKey();
  }
  else
  {
    printf("[INFO]: Computation failed.\n");
  }
  
  return(0);
}
Exemplo n.º 5
0
int do_pb_read_one(int fd, void **pobj, int type, bool eof)
{
	u8 local[PB_PKOBJ_LOCAL_SIZE];
	void *buf = (void *)&local;
	u32 size;
	int ret;

	if (!cr_pb_descs[type].pb_desc) {
		pr_err("Wrong object requested %d on %s\n",
			type, image_name(fd));
		return -1;
	}

	*pobj = NULL;

	ret = read(fd, &size, sizeof(size));
	if (ret == 0) {
		if (eof) {
			return 0;
		} else {
			pr_err("Unexpected EOF on %s\n",
			       image_name(fd));
			return -1;
		}
	} else if (ret < sizeof(size)) {
		pr_perror("Read %d bytes while %d expected on %s",
			  ret, (int)sizeof(size),
			  image_name(fd));
		return -1;
	}

	if (size > sizeof(local)) {
		ret = -1;
		buf = xmalloc(size);
		if (!buf)
			goto err;
	}

	ret = read(fd, buf, size);
	if (ret < 0) {
		pr_perror("Can't read %d bytes from file %s",
			  size, image_name(fd));
		goto err;
	} else if (ret != size) {
		pr_perror("Read %d bytes while %d expected from %s",
			  ret, size, image_name(fd));
		ret = -1;
		goto err;
	}

	*pobj = cr_pb_descs[type].unpack(NULL, size, buf);
	if (!*pobj) {
		ret = -1;
		pr_err("Failed unpacking object %p from %s\n",
		       pobj, image_name(fd));
		goto err;
	}

	ret = 1;
err:
	if (buf != (void *)&local)
		xfree(buf);

	return ret;
}
Exemplo n.º 6
0
imgdata loadJpeg( const char* filename){
    unsigned char a,r,g,b;
    int img_width, img_height;

    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;

    FILE *file;
    JSAMPARRAY pJpegBuffer;
    int row_stride;

    std::string image_name(filename);
    file = fopen(image_name.c_str(), "rb");
    if( file == NULL){
        std::string msg("Error opening ");
        throw std::runtime_error(msg + image_name);
    }
    printf("Loading in files %s\n", image_name.c_str());

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo);
    jpeg_stdio_src(&cinfo, file);
    jpeg_read_header(&cinfo, TRUE);
    jpeg_start_decompress(&cinfo);
    img_width  = cinfo.image_width;
    img_height = cinfo.image_height;
    printf("img_width %d img_height %d\n", img_width, img_height);

    unsigned char *img_data = new unsigned char [4 * img_height * img_width];
    unsigned char *pTest = img_data;
    if(!img_data){
        std::string msg("NO MEM FOR JPEG CONVERT!\n");
        throw std::runtime_error(msg);
    }

    row_stride = img_width * cinfo.output_components;
    pJpegBuffer = (*cinfo.mem->alloc_sarray)
      ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);

    while( cinfo.output_scanline < cinfo.output_height){
        jpeg_read_scanlines(&cinfo, pJpegBuffer, 1);
        for( int x=0; x<img_width; x++){
            a = 0;
            r = pJpegBuffer[0][cinfo.output_components*x];
            if( cinfo.output_components > 2){
                g = pJpegBuffer[0][cinfo.output_components*x+1];
                b = pJpegBuffer[0][cinfo.output_components*x+2];
            }else{
                g = r;
                b = r;
            }
            //printf( "r %c g %c b %c\n", r,g,b);
            *(img_data++) = r;
            *(img_data++) = g;
            *(img_data++) = b;
            *(img_data++) = a;
        }
    }
    fclose(file);
    jpeg_finish_decompress(&cinfo);
    jpeg_destroy_decompress(&cinfo);
    imgdata retval;
    retval.height = img_height;
    retval.width = img_width;
    retval.data = pTest;

    return retval;
}
Exemplo n.º 7
0
static int get_surflist( Node *node, LWSurfaceID *surfid )
{
   Node *surf, *tnode;
   LWTextureID tex;
   LWTLayerID tlayer;
   char *p, name[ 200 ];
   int ntex, nlayer, i, j, si, tj, k, proj;


   surf = node->child;

   /* look at all of the surfaces */

   for ( i = 0, si = 0; surfid[ i ]; i++ ) {

      /* if there are no image mapped textures, keep moving */

      ntex = count_imagetxtrs( surfid[ i ] );
      if ( !ntex ) continue;

      /* init surface node, which has texture children */

      if ( !init_node( &surf[ si ], surff->name( surfid[ i ] ), surfid[ i ], ntex ))
         return 0;

      /* look at each of the surface's channels */

      for ( j = 0, tj = 0; surfchan[ j ]; j++ ) {

         /* if the channel isn't textured, keep moving */

         tex = surff->getTex( surfid[ i ], surfchan[ j ] );
         if ( !tex ) continue;

         /* if the texture has no image maps, keep moving */

         nlayer = count_imagemaps( tex );
         if ( !nlayer ) continue;

         /* init texture node, which has texture layer children */

         tnode = &surf[ si ].child[ tj ];
         if ( !init_node( tnode, surfchan_label[ j ], tex, nlayer ))
            return 0;

         /* look at all of the texture layers */

         k = 0;
         tlayer = txtrf->firstLayer( tex );
         while ( tlayer ) {

            /* if the layer is an image map */

            if ( TLT_IMAGE == txtrf->layerType( tlayer )) {

               /* init texture layer node */

               txtrf->getParam( tlayer, TXTAG_PROJ, &proj );
               switch ( proj ) {
                  case TXPRJ_PLANAR:       p = "Planar";       break;
                  case TXPRJ_CYLINDRICAL:  p = "Cylindrical";  break;
                  case TXPRJ_SPHERICAL:    p = "Spherical";    break;
                  case TXPRJ_CUBIC:        p = "Cubic";        break;
                  case TXPRJ_FRONT:        p = "Front";        break;
                  case TXPRJ_UVMAP:        p = "UVMap";        break;
                  default:                 p = "Unknown";
               }
               sprintf( name, "%s: %s", p, image_name( tlayer ));
               if ( !init_node( &tnode->child[ k ], name, tlayer, 0 ))
                  return 0;
               ++k;
            }
            tlayer = txtrf->nextLayer( tex, tlayer );
         }
         ++tj;
      }
      ++si;
   }

   return 1;
}
Exemplo n.º 8
0
void MovieTickets::updateMovieEdit(){
	if(this->movie_index_edit < this->movies.size() && this->movie_index >= 0){
		//Update Title
		this->window.edit_title_lineEdit->clear();
		this->window.edit_title_lineEdit->setText(this->movies[this->movie_index_edit].getTitle());

		//Update Director
		this->window.edit_director_lineEdit->clear();
		this->window.edit_director_lineEdit->setText(this->movies[this->movie_index_edit].getDirector());

		//Update Year
		int index = -1;
		for(int i = 0 ; index < 0 && i < this->window.edit_year_comboBox->count() ; i++){
			if(this->window.edit_year_comboBox->itemText(i).toInt() ==  this->movies[this->movie_index_edit].getYear().toInt()){
				index = i; 
			}
		}

		this->window.edit_year_comboBox->setCurrentIndex(index);

		//Update Duration
		this->window.edit_duration_lineEdit->clear();
		this->window.edit_duration_lineEdit->setText(this->movies[this->movie_index_edit].getDuration());

		//Update Rating
		this->window.edit_rating_doubleSpinBox->setValue(this->movies[this->movie_index_edit].getRating().toDouble());
		

		//Update Visualization Date
		int day,month,year;
		sscanf_s(this->movies[this->movie_index_edit].getVisualization_date().toStdString().data(),"%d/%d/%d",&day,&month,&year);
		
		this->window.edit_visualization_dateEdit->setDate(QDate(year,month,day));

		//Update Plot
		this->window.edit_plot_textEdit->clear();
		this->window.edit_plot_textEdit->setPlainText(this->movies[this->movie_index_edit].getPlot());

		//Update Cast
		QString cast_;
		for(int i = 0 ; i < this->movies[this->movie_index_edit].getCast().size() ; i+=2){
			cast_.append(this->movies[this->movie_index_edit].getCast()[i]);
			cast_.append(" ... ");
			cast_.append(this->movies[this->movie_index_edit].getCast()[i+1]);
			cast_.append("\n");
		}
		
		this->window.edit_cast_textEdit->clear();
		this->window.edit_cast_textEdit->setPlainText(cast_);

		//Update Picture
		QString image_name(this->movies[movie_index_edit].getImage_path());
		this->window.edit_image_lineEdit->setText(this->movies[movie_index_edit].getImage_path());
	
		QPixmap* image;
		if(image_name.length() > 0){
			QString image_full_path(this->image_path);
			image_full_path.append(image_name);

			image = new QPixmap(image_full_path);

			if(image->isNull()){
				image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
			}
		}
		else{
			image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
		}
	
		QPixmap aux = image->scaledToWidth(this->window.edit_image_label->width());

		if(aux.height() > this->window.edit_image_label->height()){
			aux = image->scaledToHeight(this->window.edit_image_label->height());
		}

		this->window.edit_image_label->setPixmap(aux);
	}
}
Exemplo n.º 9
0
void MovieTickets::updateMovieView(){
	if(this->movie_index < this->movies.size() && this->movie_index >= 0){
		//Update Title
		this->window.view_title_label->clear();
		this->window.view_title_label->setText("Title: " + this->movies[this->movie_index].getTitle());

		//Update Director
		this->window.view_director_label->clear();
		this->window.view_director_label->setText("Director: " + this->movies[this->movie_index].getDirector());

		//Update Year
		this->window.view_year_label->clear();
		this->window.view_year_label->setText("Year: " + this->movies[this->movie_index].getYear());

		//Update Duration
		this->window.view_duration_label->clear();
		this->window.view_duration_label->setText("Duration: " + this->movies[this->movie_index].getDuration());

		//Update Rating
		this->window.view_rating_label->clear();
		this->window.view_rating_label->setText("IMDB Rating: " + this->movies[this->movie_index].getRating());

		//Update Visualization Date
		this->window.view_visualization_label->clear();
		this->window.view_visualization_label->setText("Visualization Date: " + this->movies[this->movie_index].getVisualization_date());

		//Update Plot
		this->window.view_plot_textBrowser->clear();
		this->window.view_plot_textBrowser->setText(this->movies[this->movie_index].getPlot());

		//Update Cast
		QString cast_;
		for(int i = 0 ; i < this->movies[this->movie_index].getCast().size() ; i+=2){
			cast_.append(this->movies[this->movie_index].getCast()[i]);
			cast_.append(" ... ");
			cast_.append(this->movies[this->movie_index].getCast()[i+1]);
			cast_.append("\n");
		}
		
		this->window.view_cast_textBrowser->clear();
		this->window.view_cast_textBrowser->setText(cast_);

		//Update Picture
		QString image_name(this->movies[movie_index].getImage_path());
	
		QPixmap* image;
		if(image_name.length() > 0){
			QString image_full_path(this->image_path);
			image_full_path.append(image_name);

			image = new QPixmap(image_full_path);

			if(image->isNull()){
				image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
			}
		}
		else{
			image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
		}
	
		QPixmap aux = image->scaledToWidth(this->window.view_image_label->width());

		if(aux.height() > this->window.view_image_label->height()){
			aux = image->scaledToHeight(this->window.view_image_label->height());
		}

		this->window.view_image_label->setPixmap(aux);
	}
}
Exemplo n.º 10
0
/*************************************************************************
SAX2 Handler methods
*************************************************************************/
void Font_xmlHandler::elementStart(const String& element, const XMLAttributes& attributes)
{
    // handle a Mapping element
    if (element == MappingElement)
    {
        if (!d_font->d_freetype)
        {
            String	image_name(attributes.getValueAsString(MappingImageAttribute));
            utf32 codepoint = (utf32)attributes.getValueAsInteger(MappingCodepointAttribute);
            int horzAdvance = attributes.getValueAsInteger(MappingHorzAdvanceAttribute, -1);

            Font::glyphDat	mapDat;
            mapDat.d_image = &d_font->d_glyph_images->getImage(image_name);

            // calculate advance width if it was not specified
            if (horzAdvance == AutoGenerateHorzAdvance)
            {
                horzAdvance = (int)(mapDat.d_image->getWidth() + mapDat.d_image->getOffsetX());
            }

            mapDat.d_horz_advance_unscaled = horzAdvance;
            mapDat.d_horz_advance = (uint)(((float)horzAdvance) * (d_font->d_autoScale ? d_font->d_horzScaling : 1.0f));
            d_font->d_cp_map[codepoint] = mapDat;
        }
        else
        {
            Logger::getSingleton().logEvent((utf8*)"Mapping element encountered.  This element is invalid for dynamic fonts.", Informative);
        }
    }
    // handle root Font element
    else if (element == FontElement)
    {
        // get name of font we are creating
        String font_name(attributes.getValueAsString(FontNameAttribute));

        // get filename for the font
        String filename(attributes.getValueAsString(FontFilenameAttribute));
        // get resource group for font file.
        String resourceGroup(attributes.getValueAsString(FontResourceGroupAttribute));

        Logger::getSingleton().logEvent("Started creation of Font '" + font_name + "' via XML file.", Informative);

        //
        // load auto-scaling configuration
        //
        float hres, vres;
        bool auto_scale;

        // get native horizontal resolution
        hres = (float)attributes.getValueAsInteger(FontNativeHorzResAttribute, 640);

        // get native vertical resolution
        vres = (float)attributes.getValueAsInteger(FontNativeVertResAttribute, 480);

        // get auto-scaling setting
        auto_scale = attributes.getValueAsBool(FontAutoScaledAttribute, false);

        //
        // get type of font
        //
        String	font_type(attributes.getValueAsString(FontTypeAttribute));

        // dynamic (ttf) font
        if (font_type == FontTypeDynamic)
        {
            // get size of font
            uint size = (uint)attributes.getValueAsInteger(FontSizeAttribute, 12);

            // extract codepoint range
            utf32 first_codepoint = (utf32)attributes.getValueAsInteger(FontFirstCodepointAttribute, 32);
            utf32 last_codepoint = (utf32)attributes.getValueAsInteger(FontLastCodepointAttribute, 127);

            // build string containing the required code-points.
            for (; first_codepoint <= last_codepoint; ++first_codepoint)
            {
                d_glyphSet += first_codepoint;
            }

            uint flags = attributes.getValueAsBool(FontAntiAliasedAttribute, true) ? 0 : NoAntiAlias;

            // perform pre-initialisation
            d_font->setNativeResolution(Size(hres, vres));
            d_font->setAutoScalingEnabled(auto_scale);

            // Finalise construction of font without glyphs.
            // Glyphs will defined after we know which ones we need.
            d_font->constructor_impl(font_name, filename, resourceGroup, size, flags, String(""));
        }
        // static (Imageset based) font
        else if (font_type == FontTypeStatic)
        {
            d_font->d_name = font_name;
            d_font->d_freetype = false;

            // load the Imageset
            d_font->d_glyph_images = ImagesetManager::getSingleton().createImageset(filename, resourceGroup);

            d_font->setNativeResolution(Size(hres, vres));
            d_font->setAutoScalingEnabled(auto_scale);
        }
        // error (should never happen)
        else
        {
            throw FileIOException("Font::xmlHandler::startElement - The unknown Font:Type attribute value '" + font_type + "' was encountered while processing the Font file.");
        }

        d_font->d_sourceFilename = filename;
    }
    // Glyph element
    else if (element == GlyphElement)
    {
        if (d_font->d_freetype)
        {
            utf32 codepoint = (utf32)attributes.getValueAsInteger(GlyphCodepointAttribute);

            if (d_glyphSet.find(codepoint) == String::npos)
            {
                d_glyphSet.append(1, codepoint);
            }
        }
        else
        {
            Logger::getSingleton().logEvent((utf8*)"Glyph element encountered.  This element is invalid for static fonts.", Informative);
        }
    }
    // GlyphRange element
    else if (element == GlyphRangeElement)
    {
        if (d_font->d_freetype)
        {
            utf32 start = (utf32)attributes.getValueAsInteger(GlyphRangeStartCodepointAttribute);
            utf32 end	= (utf32)attributes.getValueAsInteger(GlyphRangeEndCodepointAttribute);

            for (utf32 codepoint = start; codepoint <= end; ++codepoint)
            {
                if (d_glyphSet.find(codepoint) == String::npos)
                {
                    d_glyphSet.append(1, codepoint);
                }
            }

        }
        else
        {
            Logger::getSingleton().logEvent((utf8*)"GlyphRange element encountered.  This element is invalid for static fonts.", Informative);
        }
    }
    // GlyphSet element
    else if (element == GlyphSetElement)
    {
        if (d_font->d_freetype)
        {
            String glyphs(attributes.getValueAsString(GlyphSetGlyphsAttribute));

            for (String::size_type i = 0; i < glyphs.length(); ++i)
            {
                utf32 codepoint = glyphs[i];

                if (d_glyphSet.find(codepoint) == String::npos)
                {
                    d_glyphSet.append(1, codepoint);
                }

            }

        }
        else
        {
            Logger::getSingleton().logEvent((utf8*)"GlyphSet element encountered.  This element is invalid for static fonts.", Informative);
        }
    }
    // anything else is an error which *should* have already been caught by XML validation
    else
    {
        throw FileIOException("Font::xmlHandler::startElement - Unexpected data was found while parsing the Font file: '" + element + "' is unknown.");
    }

}
Exemplo n.º 11
0
int main(int argc, char** argv)
{
  if(argc != 5)
  {
    printUsage(argv[0]);
    return(0);
  }
  
  srand ( time(NULL) );
  
  std::string image_name(argv[1]);
  std::string saliency_map_name(argv[2]);
  std::string output_file_name(argv[3]);
  std::string output_png_name(argv[4]);
    
  cv::Mat image = cv::imread(image_name,-1);
  cv::Mat map = cv::imread(saliency_map_name,-1);
  map.convertTo(map,CV_32F,1.0f/255);
    
  std::vector<v4r::ConnectedComponent> connectedComponents;
    
  float th = 0.1;
  v4r::extractConnectedComponents(map,connectedComponents,th);
  v4r::drawConnectedComponents(connectedComponents,image,cv::Scalar(255,0,0));
  //std::cerr << "Number of connected components: " << connectedComponents.size() << std::endl;
    
  std::vector<v4r::SaliencyLine> saliencyLine;
  cv::Mat points_image = cv::Mat_<uchar>::zeros(image.rows,image.cols);
  std::vector<v4r::PointSaliency> saliencyPoints;
    
  for(unsigned int i = 0; i < connectedComponents.size(); ++ i)
  {
    //std::cerr << i << " " << connectedComponents.size() << std::endl;
    cv::Mat mask = cv::Mat_<uchar>::zeros(image.rows,image.cols);
    v4r::drawConnectedComponent(connectedComponents.at(i),mask,cv::Scalar(1));
    //cv::imshow("mask",255*mask);
    //cv::waitKey();
      
    v4r::SaliencyLine saliencyLineCurent;
    v4r::PointSaliency pointSaliencyCurrent;
    //std::cerr << "here 0" << std::endl;
    if(v4r::extractSaliencyLine(mask,map,saliencyLineCurent))
    {
      //std::vector<cv::Point> saliencyLineCurent_points;
      //v4r::createSimpleLine(saliencyLineCurent,saliencyLineCurent_points);
      //std::cerr << saliencyLineCurent_points.size() << std::endl;
      //v4r::drawAttentionPoints(image,saliencyLineCurent_points);
      //cv::imshow("skeleton",image);
      //cv::waitKey();
      
      saliencyLine.push_back(saliencyLineCurent);
      //std::cerr << "here 1" << std::endl;
      v4r::selectSaliencyCenterPoint(saliencyLineCurent,pointSaliencyCurrent);
      //std::cerr << "here 2" << std::endl;
      saliencyPoints.push_back(pointSaliencyCurrent);
      
    }
    //std::cerr << "here 3" << std::endl;
  }
    
  std::sort(saliencyPoints.begin(),saliencyPoints.end(),v4r::saliencyPointsSort);
    
  std::vector<cv::Point> attentionPoints;
  v4r::createAttentionPoints(saliencyPoints,attentionPoints);
  
  v4r::writeAttentionPoints(attentionPoints,output_file_name);
  
  v4r::drawAttentionPoints(image,attentionPoints,10);
  
  cv::imwrite(output_png_name,image);
  
  //cv::imshow("attention points", image);
  //cv::imshow("saliency map", map);
  //cv::waitKey();
}