Skip to content

Commit

Permalink
fix compile on ubuntu 16.04 with opencv 2.4 and Qt5.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
abreheret committed Jan 29, 2018
1 parent 67fc0d8 commit f6eb013
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
28 changes: 15 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.2)
project(PixelAnnotationTool)

set(QT5_DIR "~/Qt/5.9.1/msvc2015_64/lib/cmake" CACHE STRING "Additional search paths for QT5")


set(QT5_DIR "~/Qt5.9.1/5.9.1/msvc2015_64/lib/cmake" CACHE STRING "Additional search paths for QT5")
set(CMAKE_AUTOMOC ON)

if(WIN32)
Expand Down Expand Up @@ -107,18 +109,18 @@ if( MSVC )
COMMAND ${QT5_DIR}/../../bin/windeployqt ${DIR_NAME_RELEASE}/bin
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${NAME_RELEASE}.zip" --format=zip ${DIR_NAME_RELEASE} )
else(UNIX)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
set(opecncv_dep libopencv_imgproc libopencv_imgcodecs libopencv_core)
foreach(libcv ${opecncv_dep})
file(COPY ${OpenCV_DIR}/../../lib/${libcv}.so.${OpenCV_VERSION} DESTINATION ${DIR_NAME_RELEASE}/bin)
file(RENAME ${DIR_NAME_RELEASE}/bin/${libcv}.so.${OpenCV_VERSION} ${DIR_NAME_RELEASE}/bin/${libcv}.so.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR})
endforeach()
# IF("${isSystemDir}" STREQUAL "-1")
# SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# ENDIF("${isSystemDir}" STREQUAL "-1")
# set(opecncv_dep libopencv_imgproc libopencv_imgcodecs libopencv_core)
# foreach(libcv ${opecncv_dep})
# file(COPY ${OpenCV_DIR}/../../lib/${libcv}.so.${OpenCV_VERSION} DESTINATION ${DIR_NAME_RELEASE}/bin)
# file(RENAME ${DIR_NAME_RELEASE}/bin/${libcv}.so.${OpenCV_VERSION} ${DIR_NAME_RELEASE}/bin/${libcv}.so.${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR})
# endforeach()
add_custom_command(TARGET PixelAnnotationTool POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:PixelAnnotationTool> ${DIR_NAME_RELEASE}/bin/PixelAnnotationTool
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts_to_build/linuxdeployqt ${DIR_NAME_RELEASE}/bin/PixelAnnotationTool -qmake=${QT5_DIR}/../../bin/qmake
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${NAME_RELEASE}.zip" --format=zip ${DIR_NAME_RELEASE} )

COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:PixelAnnotationTool> ${DIR_NAME_RELEASE}/bin/PixelAnnotationTool
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts_to_build/linuxdeployqt ${DIR_NAME_RELEASE}/bin/PixelAnnotationTool -qmake=${QT5_DIR}/../../bin/qmake
COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${NAME_RELEASE}.zip" --format=zip ${DIR_NAME_RELEASE} )
#
endif()

15 changes: 14 additions & 1 deletion scripts_to_build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@

## build and run on linux :

On ubuntu, PixelAnnotationTool need this pacakage (OpenCV and Qt5.9.1):

```sh
sudo apt-get install mesa-common-dev
sudo apt-get install libopencv-dev python-opencv
wget http://download.qt.io/official_releases/qt/5.9/5.9.1/qt-opensource-linux-x64-5.9.1.run
chmod +x qt-opensource-linux-x64-5.9.1.run
./qt-opensource-linux-x64-5.9.1.run

```

To compile the application :

```sh
cd ..
mkdir x64
cd x64
cmake -DQT5_DIR=/path/to/Qt/5.7/gcc_64/lib/cmake -G "Unix Makefiles" ..
cmake -DQT5_DIR=/path/to/Qt5.9.1/5.9.1/gcc_64/lib/cmake -G "Unix Makefiles" ..
make

```
2 changes: 1 addition & 1 deletion scripts_to_build/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -d "build" ]; then
fi
mkdir build
cd build
cmake -DQT5_DIR=/home/amaury/Qt/5.9.1/gcc_64/lib/cmake -G"Unix Makefiles" ../..
cmake -DQT5_DIR=/home/amaury/Qt5.9.1/5.9.1/gcc_64/lib/cmake -G"Unix Makefiles" ../..
make
cd ..

6 changes: 3 additions & 3 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include "labels.h"

#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <QImage>

cv::Mat qImage2Mat(QImage const& src);
Expand All @@ -21,4 +21,4 @@ bool isFullZero(const QImage& image);
int rgbToInt(uchar r, uchar g, uchar b);
void intToRgb(int value, uchar &r, uchar &g, uchar &b);

#endif
#endif

0 comments on commit f6eb013

Please sign in to comment.