Skip to content

Commit

Permalink
add: new release
Browse files Browse the repository at this point in the history
  • Loading branch information
frank1789 committed Feb 10, 2020
2 parents 88fe409 + c2d808c commit 51ab0aa
Show file tree
Hide file tree
Showing 28 changed files with 440 additions and 574 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#-----------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 3.7)
set(LEPTONCAMERA "FlirLepton")
project(${LEPTONCAMERA} LANGUAGES C CXX VERSION "4.0.0")
project(${LEPTONCAMERA} LANGUAGES C CXX VERSION "0.5.0")

#-----------------------------------------------------------------------------
# check build type
Expand Down
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Flir-Lepton

This Qt-based project allows the interface between the Flir Lepton 2.5 camera and Raspicam to be part of my thesis project for the Master's Degree in Mechatronics, by title _Enanching UAV capabilities with machine learning on board_.

## Prerequisites

* Qt
* gcc 6.3 (c++14 or above)
* cmake (3.7 or above)
* Flir Lepton Guide [product page](https://learn.sparkfun.com/tutorials/flir-lepton-hookup-guide)
+ Lepton Flir 2.0 [reference](https://groupgets.com/manufacturers/flir/products/lepton-2-0)
* [RaspiCam](https://www.uco.es/investiga/grupos/ava/node/40): C++ API for using Raspberry
+ Raspicam [source](https://sourceforge.net/projects/raspicam/files/?)

### Configuration

Connections:
1. match your female to female jumpers wires to the images below (_note: your jumper wires may differ in color_), You can also use the list below.

<center>

| Raspberry GPIO | Breakout Board |
|:----------------|-----------------:|
|(Pin 1) +3.3V| VIN|
|(Pin 3) SDA | SDA|
|(Pin5) SCL | SCL|
|(Pin6) GND |GND|
|(Pin 19)MOSI |MOSI|
|(Pin 21) MISO| MISO|
|(Pin 23) SCLK | CLK|
|(Pin 24) CE0 |CS|

</center>
<br>
<div class="row" align="center">
<div class="column">
<img src="./images/breakoutboard.jpg" style="width:35%">
</div>
<div class="column">
<img src="./images/gpioconnection.jpg" style="width:35%">
</div>
</div>

2. Now install the Raspberry Pi Camera, the camera should face towards the IO ports.
<br>
<div class="row" align="center">
<div class="column">
<img src="./images/camera.jpg" style="width:35%">
</div>
</div>

This configuration works well and avoids the red rectangle on the screen most of the time.
* I preferred a method that would automatically decide whether to use: _"/dev/spidev0.1" or "/dev/spidev0.1"_

## Run

To run the project in release mode:

```sh
git clone https://github.com/frank1789/Flir-Lepton.git
cd Flir-Lepton
./build
```

otherwise in debug mode:

```sh
git clone https://github.com/frank1789/Flir-Lepton.git
cd Flir-Lepton
./build Debug
```

The software has a single main window in which the images acquired by the thermal camera and Raspicam are displayed.
you can edit the color map for the thermal image from the main widget and save photos.
it is possible to modify the fusion filter between the images, these however require that the cameras are perfectly aligned with a support structure.

Inside there is a TCP server to send images to clients connected using the default port 52693, while the address is shown in the main widget.

<div class="row" align="center">
<div class="column">
<img src="./images/lava.png" style="width:35%">
</div>
<div class="column">
<img src="./images/grayscale.png" style="width:35%">
</div>
<div class="column">
<img src="./images/rainbow.png" style="width:35%">
</div>
</div>
67 changes: 61 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,63 @@
#!/usr/bin/env sh

rm -rf build
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Debug ..
make -j3
EXECUTABLE=$(find $PWD -name "FlirLepton")
${EXECUTABLE}


# ////////////////////////////////////////////////////////////////////////////
# declare function
# ////////////////////////////////////////////////////////////////////////////

compile_debug() {
DIRECTORY=build_debug
clear_old_build
echo "create new directory $DIRECTORY"
mkdir $DIRECTORY && cd $DIRECTORY
cmake -D CMAKE_BUILD_TYPE=Debug ..
make -j3
EXECUTABLE=$(find $PWD -name "FlirLepton")
${EXECUTABLE}
}

compile_release() {
DIRECTORY=build_release
clear_old_build
echo "create new directory $DIRECTORY"
mkdir $DIRECTORY && cd $DIRECTORY
cmake -D CMAKE_BUILD_TYPE=Release ..
make -j3
EXECUTABLE=$(find $PWD -name "FlirLepton")
${EXECUTABLE}
}

clear_old_build() {
DIR_BUILD_DEBUG=build_debug
DIR_BUILD_RELES=build_release
# check for previuous debug build
if [ -d "$DIR_BUILD_DEBUG" ]; then
echo "remove previus build debug"
rm -rf $DIR_BUILD_DEBUG

# check for previus release build
elif [ -d "$DIR_BUILD_RELES" ]; then
echo "remove previus build release"
rm -rf $DIR_BUILD_RELES
fi

if [ -d "build" ]; then
echo "remove previus build"
rm -rf build
fi
}

# ////////////////////////////////////////////////////////////////////////////
# main script
# ////////////////////////////////////////////////////////////////////////////

if [ "$#" -eq "0" ]; then
echo "build release version"
compile_release
else
if [ "$1" = "Debug" ] || [ "$1" = "debug" ]; then
echo "build release version"
compile_debug
fi
fi
Binary file added images/breakoutboard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/camera.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gpioconnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/grayscale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lava.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rainbow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/Lepton_I2C.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Lepton_I2C.h"

#include "log/logger.h"

bool _connected{false};
Expand Down
2 changes: 2 additions & 0 deletions src/SPI.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SPI.h"

#include <fcntl.h>
#include <getopt.h>
#include <linux/spi/spidev.h>
Expand All @@ -8,6 +9,7 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>

#include <iostream>
#include <string>

Expand Down
3 changes: 3 additions & 0 deletions src/camerathread.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "camerathread.hpp"

#include <unistd.h>

#include <fstream>
#include <iostream>

#include "log/logger.h"

CameraColour::CameraColour() {
Expand Down
4 changes: 2 additions & 2 deletions src/camerathread.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef CAMERAWORKER_H
#define CAMERAWORKER_H

#include <raspicam/raspicam.h>

#include <QImage>
#include <memory>

#include <raspicam/raspicam.h>

// constant raspberry Camera V2
constexpr unsigned int RaspicamLoadTime{30000}; // 0.03 s = 30 ms = 30000 us
constexpr unsigned int RaspicamResetTime{200}; // 0.0002 s = 0.2 ms = 200 us
Expand Down
3 changes: 3 additions & 0 deletions src/leptonthread.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "leptonthread.hpp"

#include <string.h>
#include <unistd.h>

#include <QLabel>
#include <type_traits>

#include "Lepton_I2C.h"
#include "SPI.h"
#include "log/logger.h"
Expand Down
1 change: 1 addition & 0 deletions src/leptonthread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QtCore>
#include <cstdint>
#include <ctime>

#include "camerathread.hpp"

// constant Lepton packet and frame
Expand Down
15 changes: 12 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#include "mainwindow.hpp"

#include <unistd.h>

#include <QColor>
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QImage>
#include <QMutexLocker>
#include <QPushButton>
#include <QRadioButton>
#include <QString>
#include <QVBoxLayout>

#include "log/logger.h"
#include "palettes.h"
#include "socket/tcpserverui.hpp"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
Expand Down Expand Up @@ -43,9 +47,13 @@ MainWindow::MainWindow(QWidget *parent)
}

server = new TCPServer();
auto ui_server = new TCPServerUi();
connect(server, &TCPServer::Connect, ui_server, &TCPServerUi::onClientConnect);
connect(server, &TCPServer::Disconnect, ui_server,
&TCPServerUi::onClientDisconnect);
m_group_all->addLayout(create_label_preview(), 0, 0);
m_group_all->addLayout(create_bar_control(), 0, 1);
// m_group_all->addWidget(client, 0, 2);
m_group_all->addWidget(ui_server, 0, 2);
widget->setLayout(m_group_all);

// connect signal from this to respective classes label
Expand Down Expand Up @@ -74,8 +82,9 @@ MainWindow::MainWindow(QWidget *parent)

// connect Camera to TcpClient
connect(this, &MainWindow::update_rgb_image, [=](QImage image) {
QImage image_resized = image.scaled(512, 512, Qt::KeepAspectRatio);
QPixmap img = QPixmap::fromImage(image_resized);
QMutexLocker locker(&mutex);
QPixmap img =
QPixmap::fromImage(image.scaled(512, 512, Qt::KeepAspectRatio));
QByteArray bImage;
QBuffer bBuffer(&bImage);
// Putting every image in the buffer
Expand Down
6 changes: 5 additions & 1 deletion src/mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
#include <QPainter>

#include "mylabel.hpp"
#include "socket/tcpserver.h"
#include "socket/tcpserver.hpp"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}

class QComboBox;
class QGroupBox;
class QGridLayout;
Expand Down Expand Up @@ -155,5 +156,8 @@ class MainWindow : public QMainWindow {

// socket client layout
TCPServer *server{nullptr};

// mutex lock
QMutex mutex;
};
#endif // MAINWINDOW_HPP
3 changes: 2 additions & 1 deletion src/mylabel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "mylabel.hpp"

#include <QColor>
#include <QPainter>

#include "log/logger.h"

MyLabel::MyLabel(QWidget *parent) : QLabel(parent) {}
Expand All @@ -12,4 +14,3 @@ void MyLabel::setImage(QImage image) {
QPixmap pixmap = QPixmap::fromImage(image);
setPixmap(pixmap.scaled(this->width(), this->height(), Qt::KeepAspectRatio));
}

2 changes: 1 addition & 1 deletion src/socket/commonconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void send_message_image(QTcpSocket *socket, const QImage &image) {
#endif
return;
}

// prepare datastream and serialize information
QByteArray ba_message;
QDataStream out(&ba_message, QIODevice::WriteOnly);
Expand Down
Loading

0 comments on commit 51ab0aa

Please sign in to comment.