Qt 编译 Darknet

7 篇文章 0 订阅
4 篇文章 0 订阅

Qt 编译 Darknet

创建 .pro 文件

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    MainWindow.cpp \
#    Darknet_Detector/Darknet_Detector.cpp \
#    Darknet_Detector/DarknetDetector.cpp

HEADERS += \
    MainWindow.h \
#    Darknet_Detector/Darknet_Detector.h \
#    Darknet_Detector/yolo_v2_class.hpp \
#    Darknet_Detector/DarknetDetector.h

FORMS += \
    MainWindow.ui

# OpenCV
INCLUDEPATH += \
    /home/chli/OpenCV/opencv-3.4.0/build/installed/include \
    /home/chli/OpenCV/opencv-3.4.0/build/installed/include/opencv \
    /home/chli/OpenCV/opencv-3.4.0/build/installed/include/opencv2

LIBS += \
    -L/home/chli/OpenCV/opencv-3.4.0/build/installed/lib \
    -lopencv_highgui \
    -lopencv_core \
    -lopencv_imgproc \
    -lopencv_imgcodecs \
    -lopencv_video \
    -lopencv_videoio

# Darknet
SOURCES += \
    /home/chli/github/darknet/src/softmax_layer.c \
    /home/chli/github/darknet/src/l2norm_layer.c \
    /home/chli/github/darknet/src/yolo_layer.c \
    /home/chli/github/darknet/src/region_layer.c \
    /home/chli/github/darknet/src/shortcut_layer.c \
    /home/chli/github/darknet/src/parser.c \
    /home/chli/github/darknet/src/detection_layer.c \
    /home/chli/github/darknet/src/avgpool_layer.c \
    /home/chli/github/darknet/src/convolutional_layer.c \
    /home/chli/github/darknet/src/maxpool_layer.c \
    /home/chli/github/darknet/src/lstm_layer.c \
    /home/chli/github/darknet/src/crop_layer.c \
    /home/chli/github/darknet/src/cost_layer.c \
    /home/chli/github/darknet/src/blas.c \
    /home/chli/github/darknet/src/activation_layer.c \
    /home/chli/github/darknet/src/route_layer.c \
    /home/chli/github/darknet/src/image.c \
    /home/chli/github/darknet/src/activations.c \
    /home/chli/github/darknet/src/list.c \
    /home/chli/github/darknet/src/gemm.c \
    /home/chli/github/darknet/src/batchnorm_layer.c \
    /home/chli/github/darknet/src/rnn_layer.c \
    /home/chli/github/darknet/src/data.c \
    /home/chli/github/darknet/src/network.c \
    /home/chli/github/darknet/src/cuda.c \
    /home/chli/github/darknet/src/crnn_layer.c \
    /home/chli/github/darknet/src/im2col.c \
    /home/chli/github/darknet/src/dropout_layer.c \
    /home/chli/github/darknet/src/deconvolutional_layer.c \
    /home/chli/github/darknet/src/local_layer.c \
    /home/chli/github/darknet/src/utils.c \
    /home/chli/github/darknet/src/image_opencv.cpp \
    /home/chli/github/darknet/src/upsample_layer.c \
    /home/chli/github/darknet/src/option_list.c \
    /home/chli/github/darknet/src/gru_layer.c \
    /home/chli/github/darknet/src/tree.c \
    /home/chli/github/darknet/src/normalization_layer.c \
    /home/chli/github/darknet/src/box.c \
    /home/chli/github/darknet/src/connected_layer.c \
    /home/chli/github/darknet/src/matrix.c \
    #/home/chli/github/darknet/src/compare.c \
    /home/chli/github/darknet/src/col2im.c \
    /home/chli/github/darknet/src/iseg_layer.c \
    /home/chli/github/darknet/src/logistic_layer.c \
    /home/chli/github/darknet/src/demo.c \
    /home/chli/github/darknet/src/layer.c \
    /home/chli/github/darknet/src/reorg_layer.c \
    /home/chli/github/darknet/examples/regressor.c \
    /home/chli/github/darknet/examples/nightmare.c \
    /home/chli/github/darknet/examples/attention.c \
    #/home/chli/github/darknet/examples/swag.c \
    /home/chli/github/darknet/examples/art.c \
    /home/chli/github/darknet/examples/super.c \
    /home/chli/github/darknet/examples/rnn.c \
    /home/chli/github/darknet/examples/lsd.c \
    #/home/chli/github/darknet/examples/dice.c \
    /home/chli/github/darknet/examples/go.c \
    /home/chli/github/darknet/examples/yolo.c \
    /home/chli/github/darknet/examples/captcha.c \
    /home/chli/github/darknet/examples/detector.c \
    /home/chli/github/darknet/examples/tag.c \
    /home/chli/github/darknet/examples/darknet.c \
    #/home/chli/github/darknet/examples/rnn_vid.c \
    /home/chli/github/darknet/examples/classifier.c \
    /home/chli/github/darknet/examples/segmenter.c \
    #/home/chli/github/darknet/examples/voxel.c \
    /home/chli/github/darknet/examples/coco.c \
    /home/chli/github/darknet/examples/cifar.c \
    /home/chli/github/darknet/examples/instance-segmenter.c \
    #/home/chli/github/darknet/examples/writing.c

HEADERS += \
    /home/chli/github/darknet/src/cost_layer.h \
    /home/chli/github/darknet/src/crnn_layer.h \
    /home/chli/github/darknet/src/layer.h \
    /home/chli/github/darknet/src/utils.h \
    /home/chli/github/darknet/src/maxpool_layer.h \
    /home/chli/github/darknet/src/data.h \
    /home/chli/github/darknet/src/batchnorm_layer.h \
    /home/chli/github/darknet/src/network.h \
    /home/chli/github/darknet/src/list.h \
    /home/chli/github/darknet/src/avgpool_layer.h \
    /home/chli/github/darknet/src/region_layer.h \
    /home/chli/github/darknet/src/stb_image.h \
    /home/chli/github/darknet/src/shortcut_layer.h \
    /home/chli/github/darknet/src/lstm_layer.h \
    /home/chli/github/darknet/src/crop_layer.h \
    /home/chli/github/darknet/src/gemm.h \
    /home/chli/github/darknet/src/im2col.h \
    /home/chli/github/darknet/src/rnn_layer.h \
    /home/chli/github/darknet/src/blas.h \
    /home/chli/github/darknet/src/normalization_layer.h \
    /home/chli/github/darknet/src/reorg_layer.h \
    /home/chli/github/darknet/src/tree.h \
    /home/chli/github/darknet/src/local_layer.h \
    /home/chli/github/darknet/src/col2im.h \
    /home/chli/github/darknet/src/demo.h \
    /home/chli/github/darknet/src/route_layer.h \
    /home/chli/github/darknet/src/upsample_layer.h \
    /home/chli/github/darknet/src/convolutional_layer.h \
    /home/chli/github/darknet/src/iseg_layer.h \
    /home/chli/github/darknet/src/stb_image_write.h \
    /home/chli/github/darknet/src/parser.h \
    /home/chli/github/darknet/src/logistic_layer.h \
    /home/chli/github/darknet/src/gru_layer.h \
    /home/chli/github/darknet/src/image.h \
    /home/chli/github/darknet/src/option_list.h \
    /home/chli/github/darknet/src/activation_layer.h \
    /home/chli/github/darknet/src/activations.h \
    /home/chli/github/darknet/src/softmax_layer.h \
    /home/chli/github/darknet/src/yolo_layer.h \
    /home/chli/github/darknet/src/connected_layer.h \
    /home/chli/github/darknet/src/dropout_layer.h \
    /home/chli/github/darknet/src/classifier.h \
    /home/chli/github/darknet/src/detection_layer.h \
    /home/chli/github/darknet/src/matrix.h \
    /home/chli/github/darknet/src/deconvolutional_layer.h \
    /home/chli/github/darknet/src/l2norm_layer.h \
    /home/chli/github/darknet/src/cuda.h \
    /home/chli/github/darknet/src/box.h \
    /home/chli/github/darknet/include/darknet.h

INCLUDEPATH += \
    /home/chli/github/darknet/include \
    /home/chli/github/darknet/src

CUDA_SOURCES += \
    /home/chli/github/darknet/src/blas_kernels.cu \
    /home/chli/github/darknet/src/deconvolutional_kernels.cu \
    /home/chli/github/darknet/src/activation_kernels.cu \
    /home/chli/github/darknet/src/convolutional_kernels.cu \
    /home/chli/github/darknet/src/avgpool_layer_kernels.cu \
    /home/chli/github/darknet/src/col2im_kernels.cu \
    /home/chli/github/darknet/src/crop_layer_kernels.cu \
    /home/chli/github/darknet/src/maxpool_layer_kernels.cu \
    /home/chli/github/darknet/src/im2col_kernels.cu \
    /home/chli/github/darknet/src/dropout_layer_kernels.cu

CUDA_SDK = "/usr/local/cuda-10.0" # Path to cuda SDK install
CUDA_DIR = "/usr/local/cuda-10.0" # Path to cuda toolkit install

# DO NOT EDIT BEYOND THIS UNLESS YOU KNOW WHAT YOU ARE DOING....

SYSTEM_NAME = ubuntu         # Depending on your system either 'Win32', 'x64', or 'Win64'
SYSTEM_TYPE = 64            # '32' or '64', depending on your system
CUDA_ARCH = sm_50           # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
NVCC_OPTIONS = --use_fast_math

# include paths
INCLUDEPATH += $$CUDA_DIR/include \

# library directories
QMAKE_LIBDIR += $$CUDA_DIR/lib64/

CUDA_OBJECTS_DIR = ./


# Add the necessary libraries
#CUDA_LIBS = -lcuda -lcudart
CUDA_LIBS += -lcudart -lcufft -lcuda -lcublas -lcurand -lcudnn

# The following makes sure all path names (which often include spaces) are put between quotation marks
CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"')
#LIBS += $$join(CUDA_LIBS,'.so ', '', '.so')
LIBS += \
    $$CUDA_LIBS

# Configuration of the Cuda compiler
CONFIG(debug, debug|release) {
    # Debug mode
    cuda_d.input = CUDA_SOURCES
    cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
    cuda_d.commands = $$CUDA_DIR/bin/nvcc -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
    cuda_d.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
    # Release mode
    cuda.input = CUDA_SOURCES
    cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
    cuda.commands = $$CUDA_DIR/bin/nvcc $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
    cuda.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda
}

DISTFILES += \
    /home/chli/github/darknet/examples/detector-scipy-opencv.py \
    /home/chli/github/darknet/examples/detector.py

TRANSLATIONS += \
    Darknet_Detector_Qt_zh_CN.ts

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

修改源码

darknet.h 最开始

#ifndef GPU
#define GPU
#endif

#ifndef CUDNN
#define CUDNN
#endif

#ifndef OPENCV
#define OPENCV
#endif

image_opencv.cpp 最开始

#define OPENCV

im2col.h 最开始

#ifndef GPU
#define GPU
#endif

col2im.h 最开始

#ifndef GPU
#define GPU
#endif

cuda.h 中 #ifdef GPU 前一行添加

#define GPU

cuda.c 最开始

#include "cuda.h"

attention.c 中

void validate_attention_single()

show_image(*, *) 改为

show_image(*, *, 1)

屏蔽

darknet.c

中的函数

int main(int argc, char **argv)

检测调用

详见源码调用方式

darknet.c

尽情享用吧~

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值