...
 
Commits (4)
    https://gitcode.net/kl222/FaceRecognizer/-/commit/19dded4ec66b922d33a82e529b73f1316171fa96 CI: Use qt6 in ubuntu.yml 2023-08-15T09:09:30+08:00 Kang Lin kl222@126.com https://gitcode.net/kl222/FaceRecognizer/-/commit/a31fa0e4c499004444183197ca6abf0edd482a16 CMake: fix BUILD_PERFORMANCE 2023-08-15T09:09:42+08:00 Kang Lin kl222@126.com https://gitcode.net/kl222/FaceRecognizer/-/commit/a423e71540342e677b39b5f9e5f2ac5be0a741dc CMake: Use std c++ 11 or 17 2023-08-15T16:08:49+08:00 Kang Lin kl222@126.com https://gitcode.net/kl222/FaceRecognizer/-/commit/e10b52de67f6d6266ee442125ff004f66940ff60 CMake: fix FaceRecognizer.sh exec module 2023-08-16T08:56:33+08:00 Kang Lin kl222@126.com
......@@ -16,7 +16,7 @@ jobs:
matrix:
BUILD_TYPE: [Release, Debug]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
BUILD_TYPE: ${{matrix.BUILD_TYPE}}
......@@ -55,14 +55,18 @@ jobs:
cmake build-essential \
debhelper fakeroot graphviz \
libglu1-mesa-dev libpulse-mainloop-glib0 \
qttools5-dev qttools5-dev-tools qtbase5-dev qtbase5-dev-tools \
qtmultimedia5-dev qtlocation5-dev libqt5svg5-dev \
qtwebengine5-dev libqtermwidget5-0-dev libqt5serialport5-dev\
qt6-tools-dev qt6-tools-dev-tools \
qt6-base-dev qt6-base-dev-tools qt6-qpa-plugins \
libqt6svg6-dev qt6-l10n-tools qt6-translations-l10n \
qt6-scxml-dev qt6-multimedia-dev libqt6serialport6-dev \
qt6-webengine-dev qt6-webengine-dev-tools \
libqt6core5compat6-dev \
libutf8proc-dev libpam0g-dev \
libxkbcommon-dev libxkbcommon-x11-dev xorg-dev libx11-xcb-dev \
libx11-dev libxfixes-dev \
libdlib-dev libopencv-dev libopencv-contrib-dev \
libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libavresample-dev libavutil-dev \
libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev \
libswresample-dev libavutil-dev \
libsqlite3-dev
- name: Cache installed
......@@ -117,7 +121,8 @@ jobs:
SeetaQualityAssessor_DIR: ${{env.INSTALL_DIR}}/lib/cmake
facedetection_DIR: ${{env.INSTALL_DIR}}/lib/cmake/facedetection
run: |
./build_debpackage.sh /usr/lib/`uname -m`-linux-gnu/qt5
export Qt6_DIR=/usr/lib/`uname -a`-linux-gnu/cmake/Qt6
./build_debpackage.sh
cp ../facerecognizer_${{env.FaceRecognizer_VERSION}}_amd64.deb facerecognizer_${{env.FaceRecognizer_VERSION}}_amd64.deb
- name: Update xml file
......
......@@ -88,7 +88,7 @@ if(UNIX AND NOT ANDROID)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/share/FaceRecognizer.desktop
DESTINATION "share/applications"
COMPONENT Runtime)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/share/FaceRecognizer.sh
INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/share/FaceRecognizer.sh
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT Runtime)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resource/image/FaceRecognizer.png
......
......@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 2.8)
project(FaceRecognizer)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
if(POLICY CMP0083)
......@@ -21,6 +24,11 @@ endif()
OPTION(ENABLE_DOWNLOAD_MODULE "Enable automation download module files" OFF)
#打开 qt 编译工具
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
#需要的QT组件
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
......@@ -34,6 +42,9 @@ if(ANDROID AND (Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS 6.0.0))
endif()
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
LIST(APPEND QT_COMPONENTS MultimediaWidgets Core5Compat)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QT_COMPONENTS})
message("QT_VERSION:${Qt${QT_VERSION_MAJOR}_VERSION}")
......@@ -47,15 +58,6 @@ if(Qt${QT_VERSION_MAJOR}_FOUND)
endif()
get_filename_component(QT_INSTALL_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE)
#打开 qt 编译工具
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
IF(MSVC)
# This option is to enable the /MP switch for Visual Studio 2005 and above compilers
OPTION(WIN32_USE_MP "Set to ON to build with the /MP option (Visual Studio 2005 and above)." ON)
......@@ -67,13 +69,10 @@ IF(MSVC)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
ENDIF(MSVC)
IF(MINGW)
add_compile_options("-std=c++0x")
ENDIF()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-std=c++0x -Wno-sign-compare -Wno-unused-parameter)
add_compile_options(-Wno-sign-compare -Wno-unused-parameter)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_compile_options(-g -ggdb)
......@@ -139,21 +138,21 @@ if(NOT RabbitCommon_DIR)
endif()
endif()
if(RabbitCommon_DIR AND EXISTS ${RabbitCommon_DIR}/Src)
message("Use RabbitCommon source code")
message(STATUS "Use RabbitCommon source code")
add_subdirectory(${RabbitCommon_DIR}/Src ${CMAKE_BINARY_DIR}/RabbitCommon)
else()
find_package(RabbitCommon)
if(NOT RabbitCommon_FOUND)
message("RabbitCommon_DIR is not found. Please use one of the following ways to set it:")
message("1. Set RabbitCommon_DIR to the install prefix of RabbitCommon.")
message("2. Set RabbitCommon_DIR to source code root of RabbitCommon.")
message("2.1 Please download the source code of RabbitCommon from https://github.com/KangLin/RabbitCommon")
message(" ag:")
message(" git clone https://github.com/KangLin/RabbitCommon.git")
message("2.2 Then set cmake variable or environment variable RabbitCommon_DIR to download root directory.")
message(" ag:")
message(" cmake -DRabbitCommon_DIR= ")
message(FATAL_ERROR "RabbitCommon_DIR isn't set.")
message(FATAL_ERROR
"RabbitCommon_DIR is not found. Please use one of the following ways to set it:\n"
"1. Set RabbitCommon_DIR to the install prefix of RabbitCommon.\n"
"2. Set RabbitCommon_DIR to source code root of RabbitCommon.\n"
"2.1 Please download the source code of RabbitCommon from https://github.com/KangLin/RabbitCommon\n"
" ag:\n"
" git clone https://github.com/KangLin/RabbitCommon.git\n"
"2.2 Then set cmake variable or environment variable RabbitCommon_DIR to download root directory.\n"
" ag:\n"
" cmake -DRabbitCommon_DIR=")
endif()
endif()
......
......@@ -10,31 +10,7 @@ endif()
project(FaceRecognizer)
OPTION(BUILD_PERFORMANCE "Set to ON to build performance)." OFF)
if(BUILD_PERFORMANCE)
set(LIBS_DEFINES ${LIBS_DEFINES} BUILD_PERFORMANCE)
set(SOURCE_FILES ${SOURCE_FILES} Performance.cpp)
endif()
option(USE_YUV "Use libyuv" ON)
if(USE_YUV)
#Use: https://github.com/KangLin/libyuv
find_package(YUV)
if(YUV_FOUND)
set(LIBS_DEFINES ${LIBS_DEFINES} HAVE_LIBYUV)
set(LIBS ${LIBS} YUV)
# if(ANDROID)
# INSTALL(FILES $<TARGET_FILE:YUV>
# DESTINATION "libs/${ANDROID_ABI}")
# else()
# INSTALL(FILES $<TARGET_FILE:YUV>
# DESTINATION "${CMAKE_INSTALL_BINDIR}")
# endif()
endif()
endif(USE_YUV)
set(SOURCE_FILES
${SOURCE_FILES}
CameraQtCaptureVideoFrame.cpp
ImageTool.cpp
ConverFormat.cpp
......@@ -74,6 +50,29 @@ set(HEADER_FILES
database/TableRegister.h
)
OPTION(BUILD_PERFORMANCE "Set to ON to build performance)." OFF)
if(BUILD_PERFORMANCE)
set(LIBS_DEFINES ${LIBS_DEFINES} BUILD_PERFORMANCE)
list(APPEND SOURCE_FILES Performance.cpp)
endif()
option(USE_YUV "Use libyuv" ON)
if(USE_YUV)
#Use: https://github.com/KangLin/libyuv
find_package(YUV)
if(YUV_FOUND)
set(LIBS_DEFINES ${LIBS_DEFINES} HAVE_LIBYUV)
set(LIBS ${LIBS} YUV)
# if(ANDROID)
# INSTALL(FILES $<TARGET_FILE:YUV>
# DESTINATION "libs/${ANDROID_ABI}")
# else()
# INSTALL(FILES $<TARGET_FILE:YUV>
# DESTINATION "${CMAKE_INSTALL_BINDIR}")
# endif()
endif()
endif(USE_YUV)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
if(BUILD_TYPE STREQUAL "debug")
set(LIBS_DEFINES ${LIBS_DEFINES} DEBUG)
......
/*
* 作者:康林 (Email: kl222@126.com)
*
* 从摄像头(QCarmera)或者(Player)中捕获视频帧。
* 注意:android后景摄像头捕获的视频翻转-90度,前景摄像头翻转90度。
* 用法:
* QCamera m_Camera;
* m_Camera.setCaptureMode(QCamera::CaptureVideo);
* CCaptureVideoFrame videoFrame;
* videoFrame.setSource(&m_Camera);
* 注册SLOT:
* connect(&videoFrame, SIGNAL(sigCaptureFrame(const QVideoFrame&)),
* SLOT(CaptureVideoFrame(const QVideoFrame&)));
* 在SLOT 中 CaptureVideoFrame(const QVideoFrame&) 处理捕获到的视频帧。
*
* 示例代码:
* QList<QByteArray> device = QCamera::availableDevices();
* QList<QByteArray>::iterator it;
* for(it = device.begin(); it != device.end(); it++)
* {
* qDebug("Camera:%s", qPrintable(QCamera::deviceDescription(*it)));
* }
*
* QCamera camera(QCamera::availableDevices().at(1));
* camera.setCaptureMode(QCamera::CaptureVideo);
* CFrmPlayer player;
* CCaptureVideoFrame captureVideoFrame;
* if(captureVideoFrame.setSource(&camera))
* {
* qDebug("probe.setSource is ok");
* player.connect(&captureVideoFrame, SIGNAL(CaptureFrame(QVideoFrame)),
* SLOT(present(QVideoFrame)));
* }
*
* player.show();
* player.activateWindow();
* camera.start();
*/
#ifndef CAPTUREVIDEOFRAME_H
#define CAPTUREVIDEOFRAME_H
#include <QtGlobal>
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
#include <QVideoSink>
#else
#include <QAbstractVideoSurface>
#endif
#ifdef ANDROID
#include <QVideoProbe>
#endif
#include <QCamera>
#include <QImage>
#include <QMetaClassInfo>
#include "facerecognizer_export.h"
/**
* @brief The CCameraQtCaptureVideoFrame class
* @ingroup RABBITIM_IMPLEMENT_CAMERA_QT
*/
class FACERECOGNIZER_EXPORT CCameraQtCaptureVideoFrame
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
: public QVideoSink
#else
: public QAbstractVideoSurface
#endif
{
Q_OBJECT
Q_CLASSINFO("Author", "Kang Lin <kl222@126.com>")
public:
explicit CCameraQtCaptureVideoFrame(QObject *parent = nullptr);
virtual ~CCameraQtCaptureVideoFrame();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
//设置支持的捕获格式
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
virtual bool present(const QVideoFrame &frame);
#else
public Q_SLOTS:
void present(const QVideoFrame &frame);
#endif
int SetCameraAngle(int angle);
signals:
//从摄像头捕获的原始帧
void sigCaptureFrame(const QVideoFrame &frame);
void sigCaptureFrame(const QImage &frame);
private:
#ifdef ANDROID
QVideoProbe m_Probe;//android下,目前只能用probe捕获视频
#endif
int m_Angle;
};
#endif // CAPTUREVIDEOFRAME_H
/*
* 作者:康林 (Email: kl222@126.com)
*
* 从摄像头(QCarmera)或者(Player)中捕获视频帧。
* 注意:android后景摄像头捕获的视频翻转-90度,前景摄像头翻转90度。
* 用法:
* QCamera m_Camera;
* m_Camera.setCaptureMode(QCamera::CaptureVideo);
* CCaptureVideoFrame videoFrame;
* videoFrame.setSource(&m_Camera);
* 注册SLOT:
* connect(&videoFrame, SIGNAL(sigCaptureFrame(const QVideoFrame&)),
* SLOT(CaptureVideoFrame(const QVideoFrame&)));
* 在SLOT 中 CaptureVideoFrame(const QVideoFrame&) 处理捕获到的视频帧。
*
* 示例代码:
* QList<QByteArray> device = QCamera::availableDevices();
* QList<QByteArray>::iterator it;
* for(it = device.begin(); it != device.end(); it++)
* {
* qDebug("Camera:%s", qPrintable(QCamera::deviceDescription(*it)));
* }
*
* QCamera camera(QCamera::availableDevices().at(1));
* camera.setCaptureMode(QCamera::CaptureVideo);
* CFrmPlayer player;
* CCaptureVideoFrame captureVideoFrame;
* if(captureVideoFrame.setSource(&camera))
* {
* qDebug("probe.setSource is ok");
* player.connect(&captureVideoFrame, SIGNAL(CaptureFrame(QVideoFrame)),
* SLOT(present(QVideoFrame)));
* }
*
* player.show();
* player.activateWindow();
* camera.start();
*/
#ifndef CAPTUREVIDEOFRAME_H
#define CAPTUREVIDEOFRAME_H
#include <QtGlobal>
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
#include <QVideoSink>
#else
#include <QAbstractVideoSurface>
#endif
#ifdef ANDROID
#include <QVideoProbe>
#endif
#include <QCamera>
#include <QImage>
#include <QMetaClassInfo>
#include "facerecognizer_export.h"
/**
* @brief The CCameraQtCaptureVideoFrame class
* @ingroup RABBITIM_IMPLEMENT_CAMERA_QT
*/
class FACERECOGNIZER_EXPORT CCameraQtCaptureVideoFrame
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
: public QVideoSink
#else
: public QAbstractVideoSurface
#endif
{
Q_OBJECT
Q_CLASSINFO("Author", "Kang Lin <kl222@126.com>")
public:
explicit CCameraQtCaptureVideoFrame(QObject *parent = nullptr);
virtual ~CCameraQtCaptureVideoFrame();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
//设置支持的捕获格式
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
virtual bool present(const QVideoFrame &frame);
#else
public Q_SLOTS:
void present(const QVideoFrame &frame);
#endif
int SetCameraAngle(int angle);
signals:
//从摄像头捕获的原始帧
void sigCaptureFrame(const QVideoFrame &frame);
void sigCaptureFrame(const QImage &frame);
private:
#ifdef ANDROID
QVideoProbe m_Probe;//android下,目前只能用probe捕获视频
#endif
int m_Angle;
};
#endif // CAPTUREVIDEOFRAME_H
......@@ -10,7 +10,7 @@
#define RETURN(value)
#else
#define PERFORMANCE(name) \
CPerformance object##name (#name);
CPerformance object##name(#name);
#define PERFORMANCE_START(name) object##name.StartTime();
#define PERFORMANCE_ADD_TIME(name, message) \
object##name.AddTime(__FILE__, __LINE__, __FUNCTION__, message);
......
......@@ -27,6 +27,7 @@ int CConverFormatFFmpeg::SetFFmpegLog()
return 0;
}
// See: https://blog.csdn.net/u014260892/article/details/51883723
AVPixelFormat CConverFormatFFmpeg::QVideoFrameFormatToFFMpegPixFormat(
const QVideoFrame::PixelFormat format)
{
......@@ -77,7 +78,8 @@ QImage CConverFormatFFmpeg::onConverFormatToRGB888(const QVideoFrame &frame)
QImage::Format_RGB888);
#if LIBAVUTIL_VERSION_MAJOR >= 55
nRet = av_image_fill_arrays(outPic->data, outPic->linesize,
img.bits(), AV_PIX_FMT_RGB24, img.width(), img.height(), 1);
img.bits(), AV_PIX_FMT_RGB24,
img.width(), img.height(), 1);
#else
nRet = avpicture_fill((AVPicture *)outPic, videoFrame.bits(),
QVideoFrameFormatToFFMpegPixFormat(videoFrame.pixelFormat()),
......
......@@ -11,10 +11,6 @@ if [ -n "$1" -a -z "$QT_ROOT" ]; then
QT_ROOT=$1
fi
if [ -z "$QT_ROOT" ]; then
help "QT_ROOT don't exist: $QT_ROOT"
fi
if [ -n "$2" ]; then
export ThirdLibs_DIR=$2
fi
......@@ -44,9 +40,7 @@ if [ -z "$ENABLE_DOWNLOAD_MODULE" ]; then
fi
export RabbitCommon_DIR=$RabbitCommon_DIR
export QT_ROOT=$QT_ROOT
export PATH=$QT_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$QT_ROOT/lib/i386-linux-gnu:$QT_ROOT/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$QT_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH
fakeroot debian/rules binary
#dpkg-buildpackage -us -uc -b
#fakeroot debian/rules binary
#dpkg-buildpackage -us -uc -b #The -us -uc tell it there is no need to GPG sign the package. the -b is build binary
dpkg-buildpackage -us -uc #The -us -uc tell it there is no need to GPG sign the package
......@@ -31,11 +31,11 @@ case "$1" in
fi
#echo "/opt/FaceRecognizer/lib" > /etc/ld.so.conf.d/FaceRecognizer.conf
#echo "/opt/FaceRecognizer/bin" >> /etc/ld.so.conf.d/FaceRecognizer.conf
export QT_VERSION_DIR=
if [ -n "${QT_VERSION_DIR}" ]; then
echo "/opt/qt${QT_VERSION_DIR}/lib" >> /etc/ld.so.conf.d/FaceRecognizer.conf
fi
ldconfig
#export QT_VERSION_DIR=
#if [ -n "${QT_VERSION_DIR}" ]; then
# echo "/opt/qt${QT_VERSION_DIR}/lib" >> /etc/ld.so.conf.d/FaceRecognizer.conf
#fi
#ldconfig
;;
abort-upgrade|abort-remove|abort-deconfigure)
......
......@@ -58,7 +58,11 @@ endif
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
override_dh_auto_configure:
dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/FaceRecognizer -DQt5_DIR=${QT_ROOT}/lib/cmake/Qt5 -DRabbitCommon_DIR=${RabbitCommon_DIR} -DENABLE_DOWNLOAD_MODUEL=${ENABLE_DOWNLOAD_MODULE} ${PARAS}
dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/FaceRecognizer \
-DRabbitCommon_DIR=${RabbitCommon_DIR} \
-DENABLE_DOWNLOAD_MODUEL=${ENABLE_DOWNLOAD_MODULE} \
${PARAS}
override_dh_auto_build:
dh_auto_build -- $(if "`cat /proc/cpuinfo |grep 'cpu cores' |wc -l`" = "0",, -j`cat /proc/cpuinfo |grep 'cpu cores' |wc -l`)
......