Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm new in using qt and i would like to use this code : Extracting RAW Images from Flir JPEG on Linux[^]
to make a GUI with Qtcreator but i don't succed.

What I have tried:

I'm at the begining and I don't know how to do, I have just put it in Qt creator : 
#include <iostream>
#include <QProcess>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QFile>

int main(int argc, char** argv)
{
    QString filepath(argv[1]);

    QProcess exiftoolProcess;
    exiftoolProcess.start("exiftool", QStringList() << "-j" << "-b" << filepath);
    if(!exiftoolProcess.waitForFinished(100000))
    {
        qInfo() << "exiftool timed out";
    }

    QByteArray data = exiftoolProcess.readAllStandardOutput();
    QJsonDocument exiftoolDoc = QJsonDocument::fromJson(data);

    QJsonArray dataArray = exiftoolDoc.array();

    QJsonValue value = dataArray[0];

    QJsonObject obj = value.toObject();

    qInfo() << obj.keys();

    int width = obj["RawThermalImageWidth"].toDouble();
    int height = obj["RawThermalImageHeight"].toDouble();

    qInfo() << "Resolution: " << width << "x" << height;

    QString imgBase64Str = obj["RawThermalImage"].toString();
    imgBase64Str.remove(0,7);

    QByteArray image = QByteArray::fromBase64(imgBase64Str.toLocal8Bit());

    qInfo() << image.size();

    QFile file("./output.tif");
    file.open(QIODevice::WriteOnly);
    file.write(image);
    file.close();
}
Posted
Updated 22-Aug-18 5:42am

1 solution

Create a new project (File - New Project) and select the project type. For console applications like in the code snippet select Other Project and then choose Qt Console or Plain C++ which is the type of the shown code. Then paste the code from the article into the body of the created main function.

This step is necessary to create the Qt project file qmake.pro which contains the build definitions.

If you want to create a Qt GUI application you have first to learn about those. Start at Tutorials | Qt Creator Manual[^]. Create the GUI according to your requirements (here for example by providing controls to select input and output files) and insert the code from the article to perform the conversion.

Note that the code requires the exiftool to be installed.
 
Share this answer
 
Comments
Member 13957640 23-Aug-18 3:31am    
Thank you very much.
I have just done the first step, the code is past in main.cpp file.
But I don't know if it's ok because when I try to run I have this (sorry some parts are in french...) :

09:29:20: Exécution des étapes pour le projet ExportFLIR...
09:29:20: Configuration inchangée, étape qmake sautée.
09:29:20: Débute : "/usr/bin/make"
gcc -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../ExportFLIR -I. -I../Qt/5.11.1/gcc_64/include -I../Qt/5.11.1/gcc_64/include/QtWidgets -I../Qt/5.11.1/gcc_64/include/QtGui -I../Qt/5.11.1/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../Qt/5.11.1/gcc_64/mkspecs/linux-g++ -o .o /
gcc: warning: /: linker input file unused because linking not done
g++ -Wl,-rpath,/home/maxime/Qt/5.11.1/gcc_64/lib -o ExportFLIR .o main.o -L/home/maxime/Qt/5.11.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
g++: error: .o: No such file or directory
make: *** [ExportFLIR] Error 1
Makefile:257: recipe for target 'ExportFLIR' failed
09:29:20: Le processus "/usr/bin/make" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet ExportFLIR (kit : Desktop Qt 5.11.1 GCC 64bit)
When executing step "Make"
09:29:20: Temps écoulé : 00:00.
Jochen Arndt 23-Aug-18 3:44am    
Your qmake.pro file seems to be invalid.
It executes the C compiler (gcc) passing "/" as source file name.
It should instead execute the C++ compiler (g++) passing main.cpp.
Member 13957640 23-Aug-18 3:52am    
Thank you.
I have just this in my .pro file :
TEMPLATE = app
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11

SOURCES += \\
main.cpp
Jochen Arndt 23-Aug-18 4:21am    
It must be
SOURCES += main.cpp
The backslash can be used for line continuation like in C/C++ source files.
But then it must be a single backslash.

See http://doc.qt.io/qt-5/qmake-project-files.html.
Member 13957640 23-Aug-18 5:28am    
ok thank you for your reply.
Now to test I have found a file for exemple "image.jpg" and I have put in the directory of my Qt project in my computer it's /home/maxime/ExportFLIR/
But I don't know what i need to write in the code for using the file "image.jpg" to see if this code works?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900