当前位置: 首页>>代码示例>>C++>>正文


C++ image::AutoPtr类代码示例

本文整理汇总了C++中exiv2::image::AutoPtr的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr类的具体用法?C++ AutoPtr怎么用?C++ AutoPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AutoPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyMetadata

void ExifTransfer::copyMetadata() {
    try {
        dst = Exiv2::ImageFactory::open(BasicIo::AutoPtr(new MemIo(data, dataSize)));
        dst->readMetadata();
    } catch (Exiv2::Error & e) {
        std::cerr << "Exiv2 error: " << e.what() << std::endl;
        return;
    }
    try {
        src = Exiv2::ImageFactory::open(srcFile.toLocal8Bit().constData());
        src->readMetadata();
        copyXMP();
        copyIPTC();
        copyEXIF();
    } catch (Exiv2::Error & e) {
        std::cerr << "Exiv2 error: " << e.what() << std::endl;
        // At least we have to set the SubImage1 file type to Primary Image
        dst->exifData()["Exif.SubImage1.NewSubfileType"] = 0;
    }
    try {
        dst->writeMetadata();
        FileIo fileIo(dstFile.toLocal8Bit().constData());
        fileIo.open("wb");
        fileIo.write(dst->io());
        fileIo.close();
    } catch (Exiv2::Error & e) {
        std::cerr << "Exiv2 error: " << e.what() << std::endl;
    }
}
开发者ID:Beep6581,项目名称:hdrmerge,代码行数:29,代码来源:ExifTransfer.cpp

示例2: write

void write(const std::string& file, Exiv2::ExifData& ed)
{
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
    assert (image.get() != 0);
    image->setExifData(ed);
    image->writeMetadata();
}
开发者ID:007durgesh219,项目名称:nomacs,代码行数:7,代码来源:exifdata-test.cpp

示例3: HashExif

bool ExifHasher::HashExif(const std::string& path,
                          unsigned char* sha1_hash) const {
  FD fd;
  sys_call_rv(fd, open, path.c_str(), O_RDONLY);
  struct stat stat_buf;
  sys_call(fstat, fd, &stat_buf);
  void* memblock;
  sys_call2_rv(NULL, memblock, mmap, NULL, stat_buf.st_size, PROT_READ,
               MAP_PRIVATE, fd, 0);
  auto bytes = static_cast<const unsigned char*>(memblock);

  Exiv2::Image::AutoPtr image;
  try {
    image = Exiv2::ImageFactory::open(bytes, stat_buf.st_size);
  } catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
    return false;
  }

  if (image.get() != 0)
    image->readMetadata();
  else
    std::cerr << "Warning: EXIF not found in: " << path << std::endl;

  sys_call(munmap, memblock, stat_buf.st_size);
  fd.Close();

  if (image.get() == 0)
    return false;

  const auto& exifData = image->exifData();
  if (!exifData.empty()) {
    std::ostringstream oss;
    auto end = exifData.end();
    for (auto i = exifData.begin(); i != end; ++i) {
      // std::cerr << i->key() << " (" << i->count() << ")" << ": " <<
      //     i->value() << std::endl;
      oss << i->key() << i->value();
    }
    const std::string& exif_str = oss.str();
    SHA1(reinterpret_cast<const unsigned char*>(exif_str.c_str()),
         exif_str.size(), sha1_hash);
    return true;
  } else {
    std::cerr << "Warning: EXIF not found in: " << path << std::endl;
  }

  return false;
}
开发者ID:losvald,项目名称:jpgsync,代码行数:49,代码来源:exif_hasher.cpp

示例4: main

int main(int argc, char* const argv[])
try {

    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " file\n";
        return 1;
    }

    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
    assert(image.get() != 0);
    image->readMetadata();

    const std::string& xmpPacket = image->xmpPacket();
    if (xmpPacket.empty()) {
        std::string error(argv[1]);
        error += ": No XMP packet found in the file";
        throw Exiv2::Error(1, error);
    }
    std::cout << xmpPacket << "\n";

    return 0;
}
catch (Exiv2::AnyError& e) {
    std::cout << "Caught Exiv2 exception '" << e << "'\n";
    return -1;
}
开发者ID:007durgesh219,项目名称:nomacs,代码行数:26,代码来源:xmpdump.cpp

示例5: populateMetaExif

int populateMetaExif(std::string file, std::string plate)
{
	try 
	{
		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
		std::string comment = plate + ' '+ "LOT50"; //Add code to get information about lot
	
		if(!image.get())
		{
			throw Exiv2::Error(1, "Failed to open image");
		}
		
		image->readMetadata();
		Exiv2::ExifData &exifData = image->exifData();
	
		
		exifData["Exif.Photo.UserComment"]= comment;
		//std::cout<< "Writing Exiv User Comment "<< exifData["Exif.Image.ImageDescription"] <<"\n";
		image->writeMetadata();
		
	} catch (Exiv2::AnyError& e) {
		std::cout << "Problem Writing Metadata '" << e << "'\n";
		return -1;
	}
	
	return 0;
}
开发者ID:renegadeboss,项目名称:CyPRUSclient,代码行数:27,代码来源:cyprus_client.cpp

示例6: print

void print(const std::string& file)
{
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
    assert(image.get() != 0);
    image->readMetadata();

    Exiv2::ExifData &ed = image->exifData();
    Exiv2::ExifData::const_iterator end = ed.end();
    for (Exiv2::ExifData::const_iterator i = ed.begin(); i != end; ++i) {
        std::cout << std::setw(45) << std::setfill(' ') << std::left
                  << i->key() << " "
                  << "0x" << std::setw(4) << std::setfill('0') << std::right
                  << std::hex << i->tag() << " "
                  << std::setw(12) << std::setfill(' ') << std::left
                  << i->ifdName() << " "
                  << std::setw(9) << std::setfill(' ') << std::left
                  << i->typeName() << " "
                  << std::dec << std::setw(3)
                  << std::setfill(' ') << std::right
                  << i->count() << " "
                  << std::dec << i->value()
                  << "\n";

    }
}
开发者ID:FihlaTV,项目名称:Satires,代码行数:25,代码来源:write2-test.cpp

示例7: getExifFromPath

Exiv2::ExifData getExifFromPath(char* filename) {
    qDebug() << "Trying to read EXIF for" << filename;
    try {
        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
        assert(image.get() != 0);
        image->readMetadata();

        Exiv2::ExifData &exifData = image->exifData();
        if (exifData.empty()) {
            std::string error(filename);
            error += ": No Exif data found in the file";

            //TODO Translate
            //throw Exiv2::Error(1, error);
        }
        return exifData;
    } catch (Exiv2::Error& e) {
        Exiv2::ExifData exifData;
        qCritical() << "Caught Exiv2 exception '" << e.what();
        //TODO Translate
        return exifData;
    }


}
开发者ID:shilpi230,项目名称:CaesiumPH,代码行数:25,代码来源:exif.cpp

示例8: imwrite_tiff

bool imwrite_tiff(matrix<unsigned short> output, string outputfilename,
                  Exiv2::ExifData exifData)
{
    int xsize, ysize;
    xsize = output.nc()/3;
    ysize = output.nr();



    outputfilename = outputfilename + ".tif";
    TIFF *out = TIFFOpen(outputfilename.c_str(),"w");
    if (!out)
    {
        cerr << "Can't open file for writing" << endl;
        return 1;
    }	
    TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize);  
    TIFFSetField(out, TIFFTAG_IMAGELENGTH, ysize);
    TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); //RGB
    TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 16);
    TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);    // set the origin of the image.
    //Magic below
    TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
    //End Magic

    tsize_t linebytes = 3 * xsize * 2;//Size in bytes of a line
    unsigned short *buf = NULL;
    buf =(unsigned short *)_TIFFmalloc(linebytes);
    for (int j = 0; j < ysize; j++)
    {
        for(int i = 0; i < xsize; i ++)
        {
            buf[i*3  ] = output(j,i*3  );
            buf[i*3+1] = output(j,i*3+1);
            buf[i*3+2] = output(j,i*3+2);
        }
        if (TIFFWriteScanline(out, buf, j, 0) < 0)
            break;
    }
    (void) TIFFClose(out);

    if (buf)
        _TIFFfree(buf);

    exifData["Exif.Image.Orientation"] = 1;//set all images to unrotated
    exifData["Exif.Image.ImageWidth"] = output.nr();
    exifData["Exif.Image.ImageLength"] = output.nc()/3;

    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(outputfilename.c_str());
    assert(image.get() != 0);

    image->setExifData(exifData);
    //image->writeMetadata();

    return 0;
}
开发者ID:CarVac,项目名称:filmulator-gui,代码行数:57,代码来源:imwriteTiff.cpp

示例9: loadFromData

bool JpegContent::loadFromData(const QByteArray& data)
{
    Exiv2::Image::AutoPtr image;
    Exiv2ImageLoader loader;
    if (!loader.load(data)) {
        qCritical() << "Could not load image with Exiv2, reported error:" << loader.errorMessage();
    }
    image = loader.popImage();

    return loadFromData(data, image.get());
}
开发者ID:KDE,项目名称:gwenview,代码行数:11,代码来源:jpegcontent.cpp

示例10: loadCamXyzFromDng

void RawParameters::loadCamXyzFromDng() {
    // Try to load it from the DNG metadata
    try {
        const float d65_white[3] = { 0.950456f, 1.0f, 1.088754f };
        double cc[4][4], xyz[] = { 1,1,1 };
        for (int i = 0; i < 4; ++i) {
            for (int j = 0; j < 4; ++j) {
                cc[j][i] = i == j ? 1.0 : 0.0;
            }
        }
        Exiv2::Image::AutoPtr src = Exiv2::ImageFactory::open(fileName.toLocal8Bit().constData());
        src->readMetadata();
        const Exiv2::ExifData & srcExif = src->exifData();

        auto ccData = srcExif.findKey(Exiv2::ExifKey("Exif.Image.CameraCalibration1"));
        if (ccData == srcExif.end()) {
            ccData = srcExif.findKey(Exiv2::ExifKey("Exif.Image.CameraCalibration2"));
        }
        if (ccData != srcExif.end()) {
            for (int i = 0; i < colors; ++i) {
                for (int j = 0; j < colors; ++j) {
                    cc[i][j] = ccData->toFloat(i*colors + j);
                }
            }
        }

        auto xyzData = srcExif.findKey(Exiv2::ExifKey("Exif.Image.AsShotWhiteXY"));
        if (xyzData != srcExif.end()) {
            xyz[0] = xyzData->toFloat(0);
            xyz[1] = xyzData->toFloat(1);
            xyz[2] = 1.0 - xyz[0] - xyz[1];
            for (int i = 0; i < 3; ++i) {
                xyz[i] /= d65_white[i];
            }
        }

        auto cmData = srcExif.findKey(Exiv2::ExifKey("Exif.Image.ColorMatrix1"));
        if (cmData == srcExif.end()) {
            cmData = srcExif.findKey(Exiv2::ExifKey("Exif.Image.ColorMatrix2"));
        }
        if (cmData != srcExif.end() && cmData->count() == 3*colors) {
            for (int c = 0; c < colors; ++c) {
                for (int i = 0; i < 3; ++i) {
                    camXyz[c][i] = 0.0;
                    for (int j = 0; j < colors; ++j) {
                        camXyz[c][i] += cc[c][j] * cmData->toFloat(j*3 + i) * xyz[i];
                    }
                }
            }
        }
    } catch (Exiv2::Error & e) {
        Log::debug("Could not load camXyz values from metadata: ", e.what());
    }
}
开发者ID:Beep6581,项目名称:hdrmerge,代码行数:54,代码来源:RawParameters.cpp

示例11: RemoveGPSExif

int RemoveGPSExif(const char* File, int NoChangeMtime)
{
	struct stat statbuf;
	struct stat statbuf2;
	struct utimbuf utb;
	if (NoChangeMtime)
		stat(File, &statbuf);

	// Open the file and start reading.
	Exiv2::Image::AutoPtr Image;
	
	try {
		Image = Exiv2::ImageFactory::open(File);
	} catch (Exiv2::Error e) {
		DEBUGLOG("Failed to open file %s.\n", File);
		return 0;
	}
	Image->readMetadata();
	if (Image.get() == NULL)
	{
		// It failed if we got here.
		DEBUGLOG("Failed to read file %s %s.\n",
			 File, Exiv2::strError().c_str());
		return 0;
	}

	Exiv2::ExifData &ExifInfo = Image->exifData();

	if (ExifInfo.count() == 0)
	{
		DEBUGLOG("No EXIF tags in file %s.\n", File);
		return 0;
	}

	EraseGpsTags(ExifInfo);
	
	try {
		Image->writeMetadata();
	} catch (Exiv2::Error e) {
		DEBUGLOG("Failed to write to file %s.\n", File);
		return 0;
	}

	if (NoChangeMtime)
	{
		stat(File, &statbuf2);
		utb.actime = statbuf2.st_atime;
		utb.modtime = statbuf.st_mtime;
		utime(File, &utb);
	}

	return 1;

}
开发者ID:bruniii,项目名称:gpscorrelate,代码行数:54,代码来源:exif-gps.cpp

示例12: save

void Frame::save(std::string dir) {
    std::string path = dir + "/" + id;
    imwrite(path, *img);
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
    image->readMetadata();
    Exiv2::ExifData &exifData = image->exifData();
    std::stringstream ss;
    ss << std::setprecision(12) << data.lat << " " << data.lon << " " << data.altitude << " " << data.heading << " " << data.time;
    exifData["Exif.Photo.UserComment"] = ss.str();
    image->writeMetadata();
}
开发者ID:chrishajduk84,项目名称:computer-vision,代码行数:11,代码来源:frame.cpp

示例13: ReadExifDate

char* ReadExifDate(const char* File, int* IncludesGPS)
{
	// Open and read the file.
	Exiv2::Image::AutoPtr Image;

	try {
		Image = Exiv2::ImageFactory::open(File);
	} catch (Exiv2::Error e) {
		DEBUGLOG("Failed to open file %s.\n", File);
		return NULL;
	}
	Image->readMetadata();
	if (Image.get() == NULL)
	{
		DEBUGLOG("Failed to read file %s %s.\n",
			 File, Exiv2::strError().c_str());
		return NULL;
	}

	Exiv2::ExifData &ExifRead = Image->exifData();

	// Read the tag out.
	Exiv2::Exifdatum& Tag = ExifRead["Exif.Photo.DateTimeOriginal"];

	// Check that the tag is not blank.
	std::string Value = Tag.toString();

	if (Value.length() == 0)
	{
		// No date/time stamp.
		// Not good.
		// Just return - above us will handle it.
		return NULL;
	}

	// Copy the tag and return that.
	char* Copy = strdup(Value.c_str());
	
	// Check if we have GPS tags.
	Exiv2::Exifdatum& GPSData = ExifRead["Exif.GPSInfo.GPSLatitude"];

	if (GPSData.count() < 3)
	{
		// No valid GPS data.
		*IncludesGPS = 0;
	} else {
		// Seems to include GPS data...
		*IncludesGPS = 1;
	}

	// Now return, passing a pointer to the date string.
	return Copy; // It's up to the caller to free this.
}
开发者ID:bruniii,项目名称:gpscorrelate,代码行数:53,代码来源:exif-gps.cpp

示例14: catch

// Reads metadata from given file
Exiv2::ExifData *FlickrDownload::readExifData(QString file){
    try{
        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(
                    file.toStdString().c_str());
        image->readMetadata();
        Exiv2::ExifData *data = new Exiv2::ExifData();
        *data = image->exifData();
        return data;
    } catch (Exiv2::Error& e) {
        qCritical("[Filechooser] %s", e.what());
        return 0;
    }
}
开发者ID:FalseCAM,项目名称:reihenaufnahme,代码行数:14,代码来源:flickr-download.cpp

示例15: createProcessor

NegativeProcessor* NegativeProcessor::createProcessor(AutoPtr<dng_host> &host, const char *filename) {
    // -----------------------------------------------------------------------------------------
    // Open and parse rawfile with libraw...

    AutoPtr<LibRaw> rawProcessor(new LibRaw());

    int ret = rawProcessor->open_file(filename);
    if (ret != LIBRAW_SUCCESS) {
        rawProcessor->recycle();
        std::stringstream error; error << "LibRaw-error while opening rawFile: " << libraw_strerror(ret);
        throw std::runtime_error(error.str());
    }

    ret = rawProcessor->unpack();
    if (ret != LIBRAW_SUCCESS) {
        rawProcessor->recycle();
        std::stringstream error; error << "LibRaw-error while unpacking rawFile: " << libraw_strerror(ret);
        throw std::runtime_error(error.str());
    }

    // -----------------------------------------------------------------------------------------
    // ...and libexiv2

    Exiv2::Image::AutoPtr rawImage;
    try {
        rawImage = Exiv2::ImageFactory::open(filename);
        rawImage->readMetadata();
    } 
    catch (Exiv2::Error& e) {
        std::stringstream error; error << "Exiv2-error while opening/parsing rawFile (code " << e.code() << "): " << e.what();
        throw std::runtime_error(error.str());
    }

    // -----------------------------------------------------------------------------------------
    // Identify and create correct processor class

    if (rawProcessor->imgdata.idata.dng_version != 0) {
        try {return new DNGprocessor(host, rawProcessor.Release(), rawImage);}
        catch (dng_exception &e) {
            std::stringstream error; error << "Cannot parse source DNG-file (code " << e.ErrorCode() << ")";
            throw std::runtime_error(error.str());
        }
    }
    else if (!strcmp(rawProcessor->imgdata.idata.model, "ILCE-7"))
        return new ILCE7processor(host, rawProcessor.Release(), rawImage);
    else if (!strcmp(rawProcessor->imgdata.idata.make, "FUJIFILM"))
        return new FujiProcessor(host, rawProcessor.Release(), rawImage);

    return new VariousVendorProcessor(host, rawProcessor.Release(), rawImage);
}
开发者ID:elix22,项目名称:raw2dng,代码行数:50,代码来源:negativeProcessor.cpp


注:本文中的exiv2::image::AutoPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。