yolov3源码darknet在vscode下调试

时间:2023-01-07 12:26:59

1. 安装配置:

2. 配置vscode

打开安装好的vscode并安装扩展C/C++(ms-vscode.cpptools);在开始处打开文件夹打开darknet文件夹;

首先分析一下目录结构:

├── backup
├── cfg
├── darknet //编译的可执行文件
├── data
├── examples //重要:examples/darknet.c exmapels/detector.c等文件是主要执行文件的入口;调用src下的源码
├── ILSVRC2015_train_00755001.mp4
├── include
├── libdarknet.a
├── libdarknet.so
├── LICENSE
├── LICENSE.fuck
├── LICENSE.gen
├── LICENSE.gpl
├── LICENSE.meta
├── LICENSE.mit
├── LICENSE.v1
├── Makefile
├── obj
├── predictions.jpg
├── python
├── README.md
├── results
├── scripts
├── src // 重要代码;各个层的实现,src/demo实现摄像头实时检测
├── yolov3-tiny.weights
└── yolov3.weights

- vscode默认从系统和${workspaceFolder}(当前打开的文件夹,即darknet目录)下找头文件,所以我们要将工作区的include文件夹加入到配置文件中去。vscode下的C或C++项目的配置文件是c_cpp_properties.json,用快捷键ctrl+shift+p调出vscode命令搜索框,搜索Edit Configurations并点击就会跳转到c_cpp_properties.json文件的编辑界面,将include加入到includePath即可:

{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

3. 调试

要启动调试,vscode需要知道编译的可调式的可执行文件的目录,以及带进去的参数,这些内容需要配置到launch.json中。按F5启动调试,选择GDB环境,编辑launch.json如下所示:主要修改program和args,具体参数请根据自己具体的情况配置;

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/darknet",
"args": ["detector","test"," cfg/coco.data","cfg/yolov3.cfg","yolov3.weights","data/dog.jpg"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

- 调试主要进入darknet.c文件,选择进入相应的子函数:

int main(int argc, char **argv)
{
//test_resize("data/bad.jpg");
//test_box();
//test_convolutional_layer();
if(argc < ){
fprintf(stderr, "usage: %s <function>\n", argv[]);
return ;
}
gpu_index = find_int_arg(argc, argv, "-i", );
if(find_arg(argc, argv, "-nogpu")) {
gpu_index = -;
} #ifndef GPU
gpu_index = -;
#else
if(gpu_index >= ){
cuda_set_device(gpu_index);
}
#endif if ( == strcmp(argv[], "average")){
average(argc, argv);
} else if ( == strcmp(argv[], "yolo")){
run_yolo(argc, argv);
} else if ( == strcmp(argv[], "super")){
run_super(argc, argv);
} else if ( == strcmp(argv[], "lsd")){
run_lsd(argc, argv);
} else if ( == strcmp(argv[], "detector")){
run_detector(argc, argv);
} else if ( == strcmp(argv[], "detect")){
float thresh = find_float_arg(argc, argv, "-thresh", .);
char *filename = (argc > ) ? argv[]: ;
char *outfile = find_char_arg(argc, argv, "-out", );
int fullscreen = find_arg(argc, argv, "-fullscreen");
test_detector("cfg/coco.data", argv[], argv[], filename, thresh, ., outfile, fullscreen);
} else if ( == strcmp(argv[], "cifar")){
run_cifar(argc, argv);
} else if ( == strcmp(argv[], "go")){
run_go(argc, argv);
} else if ( == strcmp(argv[], "rnn")){
run_char_rnn(argc, argv);
} else if ( == strcmp(argv[], "coco")){
run_coco(argc, argv);
} else if ( == strcmp(argv[], "classify")){
predict_classifier("cfg/imagenet1k.data", argv[], argv[], argv[], );
} else if ( == strcmp(argv[], "classifier")){
run_classifier(argc, argv);
} else if ( == strcmp(argv[], "regressor")){
run_regressor(argc, argv);
} else if ( == strcmp(argv[], "isegmenter")){
run_isegmenter(argc, argv);
} else if ( == strcmp(argv[], "segmenter")){
run_segmenter(argc, argv);
} else if ( == strcmp(argv[], "art")){
run_art(argc, argv);
} else if ( == strcmp(argv[], "tag")){
run_tag(argc, argv);
} else if ( == strcmp(argv[], "3d")){
composite_3d(argv[], argv[], argv[], (argc > ) ? atof(argv[]) : );
} else if ( == strcmp(argv[], "test")){
test_resize(argv[]);
} else if ( == strcmp(argv[], "nightmare")){
run_nightmare(argc, argv);
} else if ( == strcmp(argv[], "rgbgr")){
rgbgr_net(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "reset")){
reset_normalize_net(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "denormalize")){
denormalize_net(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "statistics")){
statistics_net(argv[], argv[]);
} else if ( == strcmp(argv[], "normalize")){
normalize_net(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "rescale")){
rescale_net(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "ops")){
operations(argv[]);
} else if ( == strcmp(argv[], "speed")){
speed(argv[], (argc > && argv[]) ? atoi(argv[]) : );
} else if ( == strcmp(argv[], "oneoff")){
oneoff(argv[], argv[], argv[]);
} else if ( == strcmp(argv[], "oneoff2")){
oneoff2(argv[], argv[], argv[], atoi(argv[]));
} else if ( == strcmp(argv[], "print")){
print_weights(argv[], argv[], atoi(argv[]));
} else if ( == strcmp(argv[], "partial")){
partial(argv[], argv[], argv[], atoi(argv[]));
} else if ( == strcmp(argv[], "average")){
average(argc, argv);
} else if ( == strcmp(argv[], "visualize")){
visualize(argv[], (argc > ) ? argv[] : );
} else if ( == strcmp(argv[], "mkimg")){
mkimg(argv[], argv[], atoi(argv[]), atoi(argv[]), atoi(argv[]), argv[]);
} else if ( == strcmp(argv[], "imtest")){
test_resize(argv[]);
} else {
fprintf(stderr, "Not an option: %s\n", argv[]);
}
return ;
}

4. 测试Real-Time Detection on a Webcam

Running YOLO on test data isn't very interesting if you can't see the result. Instead of running it on a bunch of images let's run it on the input from a webcam!

To run this demo you will need to compile Darknet with CUDA and OpenCV. Then run the command:

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights

YOLO will display the current FPS and predicted classes as well as the image with bounding boxes drawn on top of it.

You will need a webcam connected to the computer that OpenCV can connect to or it won't work. If you have multiple webcams connected and want to select which one to use you can pass the flag -c <num> to pick (OpenCV uses webcam 0 by default).

You can also run it on a video file if OpenCV can read the video:

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights <video file>

That's how we made the YouTube video above.

yolov3源码darknet在vscode下调试的更多相关文章

  1. vscode下调试caffe源码

    caffe目录: ├── build -> .build_release // make生成目录,生成各种可执行bin文件,直接调用入口: ├── cmake ├── CMakeLists.tx ...

  2. Pytorch版本yolov3源码阅读

    目录 Pytorch版本yolov3源码阅读 1. 阅读test.py 1.1 参数解读 1.2 data文件解析 1.3 cfg文件解析 1.4 根据cfg文件创建模块 1.5 YOLOLayer ...

  3. QTimer源码分析&lpar;以Windows下实现为例&rpar;

    QTimer源码分析(以Windows下实现为例) 分类: Qt2011-04-13 21:32 5026人阅读 评论(0) 收藏 举报 windowstimerqtoptimizationcallb ...

  4. eos源码分析和应用&lpar;一&rpar;调试环境搭建

    转载自 http://www.limerence2017.com/2018/09/02/eos1/#more eos基于区块链技术实现的开源引擎,开发人员可以基于该引擎开发DAPP(分布式应用).下面 ...

  5. Android之源码之模块编译和调试

    Android之源码之模块编译调试 (一) 进行源码模块修改进行编译的调试 1.首先是从git或者svn上拉一套完整的工程下来,然后全编一下,一般这个时间比较长,大概会得2,3个小时左右, 2,编译成 ...

  6. JDK源码重新编译——支持eclipse调试JDK源码--转载

    最近在研究jdk源码,发现debug时无法查看源码里的变量值. 因为sun提供的jdk并不能查看运行中的局部变量,需要重新编译一下rt.jar. 下面这六步是编译jdk的具体步骤: Step 1:   ...

  7. Golang源码探索&lpar;一&rpar; 编译和调试源码&lpar;转&rpar;

    GO可以说是近几年最热门的新兴语言之一了, 一般人看到分布式和大数据就会想到GO,这个系列的文章会通过研究golang的源代码来分析内部的实现原理,和CoreCLR不同的是, golang的源代码已经 ...

  8. vlc源码分析(七) 调试学习HLS协议

    HTTP Live Streaming(HLS)是苹果公司提出来的流媒体传输协议.与RTP协议不同的是,HLS可以穿透某些允许HTTP协议通过的防火墙. 一.HLS播放模式 (1) 点播模式(Vide ...

  9. &period;NET框架源码解读之SSCLI的调试支持

    阅读源码一个比较快的手段就是在调试器里阅读,这样可以在实际运行SSCLI的过程中,通过堆栈跟踪的方式查看完整的程序执行路径. 当在SSCLI环境里执行一个托管程序的时候,堆栈上通常有托管和非托管代码同 ...

随机推荐

  1. Caliburn&period;Micro学习笔记目录——Zhouyongh

    解析Caliburn.Micro(一) 解析Caliburn.Micro(二) 解析Caliburn.Micro(三) 解析Caliburn.Micro(四) Illusion = Caliburn. ...

  2. php 分词 —— PHPAnalysis无组件分词系统

    分词,顾名思义就是把词语分开,从哪里分开?当然是一大堆词语里了,一大堆词语是什么?是废话或者名言.这在数据库搜索时非常有用. 官方网站 http://www.phpbone.com/phpanalys ...

  3. 网页优化URI(http URI scheme与data URI scheme)

    网页优化的一大首要任务是减少HTTP 请求 (http request) 的次数,例如通过合并多个JS文件,合并CSS样式文件.除此之外,还有一个data URL 的密技,让我们直接把图像的内容崁入网 ...

  4. thinkphp 模板中赋值

    在项目开发的时候,有时候希望直接在模板中调用 一些自定义方法,或者内置方法来,处理获得一些数据,并且赋值给一个变量给后面调用,这个时候如果用原生Php 的方式调用如下:<?php $abc = ...

  5. IOS中用模型取代字典的好处

    使用字典的坏处 一般情况下,设置数据和取出数据都是用“字符串类型的key”,编写这些key时,编译器不会有任何友情提示,需要手敲 dict[@“name”]=@“Kevin”; NSString *n ...

  6. Javascript*拖拽类

    基本拖拽配置 new Dragdrop({target 拖拽元素 HTMLElemnt 必选bridge 指定鼠标按下哪个元素时开始拖拽,实现模态对话框时用到 dragable 是否可拖拽 (true ...

  7. web2py官方文档翻译

    00前言 我相信能够轻松地构建高质量增长的web应用程序是至关重要的一个*和开放的社会.这可以防止玩家最大的垄断信息的流通. 因此我从2007年开始web2py项目,主要是作为一种教学工具与简化we ...

  8. 1112&colon; &lbrack;POI2008&rsqb;砖块Klo

    1112: [POI2008]砖块Klo Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1245  Solved: 426[Submit][Statu ...

  9. 感恩节活动中奖名单 i春秋喊你领礼物啦!

    上周我们组织的感恩节活动,得到了小伙伴们积极踊跃的回复,看到你们这么真诚的留言,我们也是满满的感动,在众多留言中,我们选出了八位幸运用户,让我们一起恭喜获奖的小伙伴们吧. 恭喜以上8位幸运的小伙伴,我 ...

  10. yum 安装fuser命令

    yum install -y psmisc 转自:https://www.cnblogs.com/saneri/p/5465718.html 有时候我们需要umount某个挂载目录时会遇到如下问题: ...