vcg/wrap/import_out.h uses easyexif lib, small typo corrected in alnParser
This commit is contained in:
parent
f38172157a
commit
dd8c26474d
|
@ -36,7 +36,7 @@ struct RangeMap
|
|||
}
|
||||
|
||||
std::string filename;
|
||||
Matrix44m trasformation;
|
||||
Matrix44m transformation;
|
||||
float quality;
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
{
|
||||
(*rm).filename = (*it);
|
||||
(*rm).quality = 1.0f;
|
||||
(*rm).trasformation.SetIdentity();
|
||||
(*rm).transformation.SetIdentity();
|
||||
}
|
||||
files.clear();
|
||||
return NoError;
|
||||
|
@ -106,10 +106,10 @@ public:
|
|||
rm.quality = (float) atof(occurrence+2);
|
||||
assert(rm.quality>0);
|
||||
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.trasformation[0][0]),&(rm.trasformation[0][1]),&(rm.trasformation[0][2]),&(rm.trasformation[0][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.trasformation[1][0]),&(rm.trasformation[1][1]),&(rm.trasformation[1][2]),&(rm.trasformation[1][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.trasformation[2][0]),&(rm.trasformation[2][1]),&(rm.trasformation[2][2]),&(rm.trasformation[2][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.trasformation[3][0]),&(rm.trasformation[3][1]),&(rm.trasformation[3][2]),&(rm.trasformation[3][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.transformation[0][0]),&(rm.transformation[0][1]),&(rm.transformation[0][2]),&(rm.transformation[0][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.transformation[1][0]),&(rm.transformation[1][1]),&(rm.transformation[1][2]),&(rm.transformation[1][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.transformation[2][0]),&(rm.transformation[2][1]),&(rm.transformation[2][2]),&(rm.transformation[2][3]));
|
||||
fscanf(stream,"%f %f %f %f \n",&(rm.transformation[3][0]),&(rm.transformation[3][1]),&(rm.transformation[3][2]),&(rm.transformation[3][3]));
|
||||
|
||||
rangemaps.push_back(rm);
|
||||
}
|
||||
|
|
|
@ -31,13 +31,8 @@
|
|||
#include <wrap/callback.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <QImageReader>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <jhead.h>
|
||||
int ReadJpegSections (FILE * infile, ReadMode_t ReadMode);
|
||||
void ResetJpgfile(void);
|
||||
}
|
||||
#include <QFileInfo>
|
||||
#include <exif.h> //external easyexif lib
|
||||
|
||||
namespace vcg {
|
||||
namespace tri {
|
||||
|
@ -85,9 +80,13 @@ static bool ReadHeader(FILE *fp,unsigned int &num_cams, unsigned int &num_points
|
|||
return true;
|
||||
}
|
||||
|
||||
static int Open( OpenMeshType &m, std::vector<Shot<ScalarType> > & shots,
|
||||
static int Open(
|
||||
OpenMeshType &m,
|
||||
std::vector<Shot<ScalarType> > & shots,
|
||||
std::vector<std::string > & image_filenames,
|
||||
const char * filename,const char * filename_images, CallBackPos *cb=0)
|
||||
const char * filename,
|
||||
const char * filename_images,
|
||||
CallBackPos *cb=0)
|
||||
{
|
||||
unsigned int num_cams,num_points;
|
||||
typedef typename vcg::Matrix44<ScalarType> Matrix44x;
|
||||
|
@ -191,13 +190,35 @@ static bool ReadImagesFilenames(const char * filename,std::vector<std::string>
|
|||
|
||||
static bool AddIntrinsics(vcg::Shotf &shot, const char * image_file)
|
||||
{
|
||||
::ResetJpgfile();
|
||||
FILE * pFile = fopen(image_file, "rb");
|
||||
int ret = ::ReadJpegSections (pFile, READ_METADATA);
|
||||
fclose(pFile);
|
||||
if(ret==0) return false;
|
||||
shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height);
|
||||
shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0));
|
||||
// Read the JPEG file into a buffer
|
||||
FILE *fp = fopen(qUtf8Printable(image_file), "rb");
|
||||
if (!fp) {
|
||||
std::cerr << "Exif Parsing: Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
|
||||
return false;
|
||||
}
|
||||
fseek(fp, 0, SEEK_END);
|
||||
unsigned long fsize = ftell(fp);
|
||||
rewind(fp);
|
||||
unsigned char *buf = new unsigned char[fsize];
|
||||
if (fread(buf, 1, fsize, fp) != fsize) {
|
||||
std::cerr << "Exif Parsing: Unable to read the content of the opened file:\n\"%1\"\n\nError details: file %1 is not readable.";
|
||||
delete[] buf;
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
// Parse EXIF
|
||||
easyexif::EXIFInfo ImageInfo;
|
||||
int ret = ImageInfo.parseFrom(buf, fsize);
|
||||
delete[] buf;
|
||||
if (ret == 0) {
|
||||
std::cerr << "Warning unable to parse exif for file %s" << qPrintable(image_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.ImageWidth, ImageInfo.ImageHeight);
|
||||
shot.Intrinsics.CenterPx = vcg::Point2f(float(ImageInfo.ImageWidth/2.0), float(ImageInfo.ImageHeight/2.0));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue