|
|
0994ec |
From 2a770fff3a984e596c94373b766e050afd5335fe Mon Sep 17 00:00:00 2001
|
|
|
0994ec |
From: Paolo Cignoni <paolo.cignoni@isti.cnr.it>
|
|
|
0994ec |
Date: Sun, 20 Sep 2020 17:18:01 +0200
|
|
|
0994ec |
Subject: [PATCH] Substituted the notorious jhead with a smaller minimal lib
|
|
|
0994ec |
(easyexif)
|
|
|
0994ec |
|
|
|
0994ec |
---
|
|
|
0994ec |
src/meshlab/mainwindow_RunTime.cpp | 64 ++++++++++++++++--------------
|
|
|
0994ec |
src/meshlab/meshlab.pro | 15 ++++---
|
|
|
0994ec |
2 files changed, 41 insertions(+), 38 deletions(-)
|
|
|
0994ec |
|
|
|
0994ec |
diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp
|
|
|
0994ec |
index 784bcbf6c..9b2734370 100644
|
|
|
0994ec |
--- a/src/meshlab/mainwindow_RunTime.cpp
|
|
|
0994ec |
+++ b/src/meshlab/mainwindow_RunTime.cpp
|
|
|
0994ec |
@@ -49,12 +49,7 @@
|
|
|
0994ec |
#include "rich_parameter_gui/richparameterlistdialog.h"
|
|
|
0994ec |
|
|
|
0994ec |
#include <wrap/io_trimesh/alnParser.h>
|
|
|
0994ec |
-
|
|
|
0994ec |
-
|
|
|
0994ec |
-extern "C" {
|
|
|
0994ec |
-#include "jhead.h"
|
|
|
0994ec |
-}
|
|
|
0994ec |
-
|
|
|
0994ec |
+#include "../external/easyexif/exif.h"
|
|
|
0994ec |
|
|
|
0994ec |
using namespace std;
|
|
|
0994ec |
using namespace vcg;
|
|
|
0994ec |
@@ -2015,12 +2010,34 @@ bool MainWindow::importRaster(const QString& fileImg)
|
|
|
0994ec |
/// If no CCD Width value is provided, the intrinsics are extracted using the Equivalent 35mm focal
|
|
|
0994ec |
/// If no or invalid EXIF info is found, the Intrinsics are initialized as a "plausible" 35mm sensor, with 50mm focal
|
|
|
0994ec |
|
|
|
0994ec |
- ::ResetJpgfile();
|
|
|
0994ec |
- FILE * pFile = fopen(qUtf8Printable(fileName), "rb");
|
|
|
0994ec |
-
|
|
|
0994ec |
- int ret = ::ReadJpegSections (pFile, READ_METADATA);
|
|
|
0994ec |
- fclose(pFile);
|
|
|
0994ec |
- if (!ret || (ImageInfo.CCDWidth==0.0f && ImageInfo.FocalLength35mmEquiv==0.0f))
|
|
|
0994ec |
+ // Read the JPEG file into a buffer
|
|
|
0994ec |
+ FILE *fp = fopen(qUtf8Printable(fileName), "rb");
|
|
|
0994ec |
+ if (fp) {
|
|
|
0994ec |
+ QString errorMsgFormat = "Exif Parsing: Unable to open file:\n\"%1\"\n\nError details: file %1 is not readable.";
|
|
|
0994ec |
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
|
|
|
0994ec |
+ return false;
|
|
|
0994ec |
+ }
|
|
|
0994ec |
+ fseek(fp, 0, SEEK_END);
|
|
|
0994ec |
+ unsigned long fsize = ftell(fp);
|
|
|
0994ec |
+ rewind(fp);
|
|
|
0994ec |
+ unsigned char *buf = new unsigned char[fsize];
|
|
|
0994ec |
+ if (fread(buf, 1, fsize, fp) != fsize) {
|
|
|
0994ec |
+ QString errorMsgFormat = "Exif Parsing: Unable to read the content of the opened file:\n\"%1\"\n\nError details: file %1 is not readable.";
|
|
|
0994ec |
+ QMessageBox::critical(this, tr("Meshlab Opening Error"), errorMsgFormat.arg(fileName));
|
|
|
0994ec |
+ delete[] buf;
|
|
|
0994ec |
+ return false;
|
|
|
0994ec |
+ }
|
|
|
0994ec |
+ fclose(fp);
|
|
|
0994ec |
+
|
|
|
0994ec |
+ // Parse EXIF
|
|
|
0994ec |
+ easyexif::EXIFInfo ImageInfo;
|
|
|
0994ec |
+ int code = ImageInfo.parseFrom(buf, fsize);
|
|
|
0994ec |
+ delete[] buf;
|
|
|
0994ec |
+ if (code) {
|
|
|
0994ec |
+ GLA()->Logf(0,"Warning unable to parse exif for file %s",qPrintable(fileName) );
|
|
|
0994ec |
+ }
|
|
|
0994ec |
+
|
|
|
0994ec |
+ if (code || ImageInfo.FocalLengthIn35mm==0.0f)
|
|
|
0994ec |
{
|
|
|
0994ec |
rm->shot.Intrinsics.ViewportPx = vcg::Point2i(rm->currentPlane->image.width(), rm->currentPlane->image.height());
|
|
|
0994ec |
rm->shot.Intrinsics.CenterPx = Point2m(float(rm->currentPlane->image.width()/2.0), float(rm->currentPlane->image.width()/2.0));
|
|
|
0994ec |
@@ -2028,26 +2045,13 @@ bool MainWindow::importRaster(const QString& fileImg)
|
|
|
0994ec |
rm->shot.Intrinsics.PixelSizeMm[1]=rm->shot.Intrinsics.PixelSizeMm[0];
|
|
|
0994ec |
rm->shot.Intrinsics.FocalMm = 50.0f;
|
|
|
0994ec |
}
|
|
|
0994ec |
- else if (ImageInfo.CCDWidth!=0)
|
|
|
0994ec |
- {
|
|
|
0994ec |
- rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height);
|
|
|
0994ec |
- rm->shot.Intrinsics.CenterPx = Point2m(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0));
|
|
|
0994ec |
- float ratio;
|
|
|
0994ec |
- if (ImageInfo.Width>ImageInfo.Height)
|
|
|
0994ec |
- ratio=(float)ImageInfo.Width/(float)ImageInfo.Height;
|
|
|
0994ec |
- else
|
|
|
0994ec |
- ratio=(float)ImageInfo.Height/(float)ImageInfo.Width;
|
|
|
0994ec |
- rm->shot.Intrinsics.PixelSizeMm[0]=ImageInfo.CCDWidth/(float)ImageInfo.Width;
|
|
|
0994ec |
- rm->shot.Intrinsics.PixelSizeMm[1]=ImageInfo.CCDWidth/((float)ImageInfo.Height*ratio);
|
|
|
0994ec |
- rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength;
|
|
|
0994ec |
- }
|
|
|
0994ec |
else
|
|
|
0994ec |
{
|
|
|
0994ec |
- rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.Width, ImageInfo.Height);
|
|
|
0994ec |
- rm->shot.Intrinsics.CenterPx = Point2m(float(ImageInfo.Width/2.0), float(ImageInfo.Height/2.0));
|
|
|
0994ec |
- float ratioFocal=ImageInfo.FocalLength/ImageInfo.FocalLength35mmEquiv;
|
|
|
0994ec |
- rm->shot.Intrinsics.PixelSizeMm[0]=(36.0f*ratioFocal)/(float)ImageInfo.Width;
|
|
|
0994ec |
- rm->shot.Intrinsics.PixelSizeMm[1]=(24.0f*ratioFocal)/(float)ImageInfo.Height;
|
|
|
0994ec |
+ rm->shot.Intrinsics.ViewportPx = vcg::Point2i(ImageInfo.ImageWidth, ImageInfo.ImageHeight);
|
|
|
0994ec |
+ rm->shot.Intrinsics.CenterPx = Point2m(float(ImageInfo.ImageWidth/2.0), float(ImageInfo.ImageHeight/2.0));
|
|
|
0994ec |
+ float ratioFocal=ImageInfo.FocalLength/ImageInfo.FocalLengthIn35mm;
|
|
|
0994ec |
+ rm->shot.Intrinsics.PixelSizeMm[0]=(36.0f*ratioFocal)/(float)ImageInfo.ImageWidth;
|
|
|
0994ec |
+ rm->shot.Intrinsics.PixelSizeMm[1]=(24.0f*ratioFocal)/(float)ImageInfo.ImageHeight;
|
|
|
0994ec |
rm->shot.Intrinsics.FocalMm = ImageInfo.FocalLength;
|
|
|
0994ec |
}
|
|
|
0994ec |
|
|
|
0994ec |
diff --git a/src/meshlab/meshlab.pro b/src/meshlab/meshlab.pro
|
|
|
0994ec |
index 4e492a184..c5e668b9d 100644
|
|
|
0994ec |
--- a/src/meshlab/meshlab.pro
|
|
|
0994ec |
+++ b/src/meshlab/meshlab.pro
|
|
|
0994ec |
@@ -8,7 +8,6 @@ QT += network
|
|
|
0994ec |
|
|
|
0994ec |
#CONFIG += debug_and_release
|
|
|
0994ec |
DESTDIR = $$MESHLAB_DISTRIB_DIRECTORY
|
|
|
0994ec |
-EXIF_DIR = ../external/jhead-3.04
|
|
|
0994ec |
|
|
|
0994ec |
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x000000
|
|
|
0994ec |
|
|
|
0994ec |
@@ -17,8 +16,7 @@ INCLUDEPATH *= \
|
|
|
0994ec |
.. \
|
|
|
0994ec |
../.. \
|
|
|
0994ec |
$$VCGDIR \
|
|
|
0994ec |
- $$EIGENDIR \
|
|
|
0994ec |
- $$EXIF_DIR
|
|
|
0994ec |
+ $$EIGENDIR
|
|
|
0994ec |
|
|
|
0994ec |
!CONFIG(system_glew): INCLUDEPATH *= $$GLEWDIR/include
|
|
|
0994ec |
|
|
|
0994ec |
@@ -79,7 +77,8 @@ SOURCES += \
|
|
|
0994ec |
glarea_setting.cpp \
|
|
|
0994ec |
rich_parameter_gui/richparameterlistdialog.cpp \
|
|
|
0994ec |
rich_parameter_gui/richparameterlistframe.cpp \
|
|
|
0994ec |
- rich_parameter_gui/richparameterwidgets.cpp
|
|
|
0994ec |
+ rich_parameter_gui/richparameterwidgets.cpp \
|
|
|
0994ec |
+ ../external/easyexif/exif.cpp
|
|
|
0994ec |
|
|
|
0994ec |
FORMS += \
|
|
|
0994ec |
ui/layerDialog.ui \
|
|
|
0994ec |
@@ -114,15 +113,15 @@ ICON = images/meshlab.icns
|
|
|
0994ec |
CONFIG += stl
|
|
|
0994ec |
|
|
|
0994ec |
win32-msvc:LIBS += \
|
|
|
0994ec |
- -L$$MESHLAB_DISTRIB_DIRECTORY/lib/win32-msvc -ljhead \
|
|
|
0994ec |
+ -L$$MESHLAB_DISTRIB_DIRECTORY/lib/win32-msvc \
|
|
|
0994ec |
-L$$MESHLAB_DISTRIB_DIRECTORY/lib -lmeshlab-common -lopengl32 -lGLU32
|
|
|
0994ec |
|
|
|
0994ec |
win32-g++:LIBS += \
|
|
|
0994ec |
- -L$$MESHLAB_DISTRIB_DIRECTORY/lib/win32-gcc -ljhead \
|
|
|
0994ec |
+ -L$$MESHLAB_DISTRIB_DIRECTORY/lib/win32-gcc \
|
|
|
0994ec |
-L$$MESHLAB_DISTRIB_DIRECTORY/lib -lmeshlab-common -lopengl32 -lGLU32
|
|
|
0994ec |
|
|
|
0994ec |
macx:LIBS += \
|
|
|
0994ec |
- -L$$MESHLAB_DISTRIB_DIRECTORY/lib/macx64 -ljhead \
|
|
|
0994ec |
+ -L$$MESHLAB_DISTRIB_DIRECTORY/lib/macx64 \
|
|
|
0994ec |
$$MESHLAB_DISTRIB_DIRECTORY/lib/libmeshlab-common.dylib
|
|
|
0994ec |
|
|
|
0994ec |
macx:QMAKE_POST_LINK += "\
|
|
|
0994ec |
@@ -133,7 +132,7 @@ macx:QMAKE_POST_LINK += "\
|
|
|
0994ec |
|
|
|
0994ec |
linux:LIBS += \
|
|
|
0994ec |
-lmeshlab-common -lGLU \
|
|
|
0994ec |
- -L$$MESHLAB_DISTRIB_DIRECTORY/lib/linux -ljhead
|
|
|
0994ec |
+ -L$$MESHLAB_DISTRIB_DIRECTORY/lib/linux
|
|
|
0994ec |
|
|
|
0994ec |
!CONFIG(system_glew) {
|
|
|
0994ec |
INCLUDEPATH *= $$GLEWDIR/include
|