Click here to Skip to main content
14,932,707 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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);
        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();

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

    qInfo() << image.size();

    QFile file("./output.tif");;
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 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.
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 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 :
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11

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.

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?
Jochen Arndt 23-Aug-18 5:37am
You have to use the full path to the file instead of argv[1]:
QString filepath("/home/maxime/ExportFLIR/image.jpg");

Alternatively select the file by using a QFileDialog.

Note also that the code must be moved later from main() when you have created a GUI. It must be then placed for example within the handler for the button that should start the conversion.
Member 13957640 23-Aug-18 6:24am
Thank you very much Jochen Arndt!
That's works!
Now I need to take time to learn how to make a GUI...
I will look for tutorials.

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