yolov3源码darknet在vscode下调试
1. 安装配置:
- https://pjreddie.com/darknet/yolo/
- darknet文件夹下make命令搞定;
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下调试的更多相关文章
- vscode下调试caffe源码
caffe目录: ├── build -> .build_release // make生成目录,生成各种可执行bin文件,直接调用入口: ├── cmake ├── CMakeLists.tx ...
- Pytorch版本yolov3源码阅读
目录 Pytorch版本yolov3源码阅读 1. 阅读test.py 1.1 参数解读 1.2 data文件解析 1.3 cfg文件解析 1.4 根据cfg文件创建模块 1.5 YOLOLayer ...
- QTimer源码分析(以Windows下实现为例)
QTimer源码分析(以Windows下实现为例) 分类: Qt2011-04-13 21:32 5026人阅读 评论(0) 收藏 举报 windowstimerqtoptimizationcallb ...
- eos源码分析和应用(一)调试环境搭建
转载自 http://www.limerence2017.com/2018/09/02/eos1/#more eos基于区块链技术实现的开源引擎,开发人员可以基于该引擎开发DAPP(分布式应用).下面 ...
- Android之源码之模块编译和调试
Android之源码之模块编译调试 (一) 进行源码模块修改进行编译的调试 1.首先是从git或者svn上拉一套完整的工程下来,然后全编一下,一般这个时间比较长,大概会得2,3个小时左右, 2,编译成 ...
- JDK源码重新编译——支持eclipse调试JDK源码--转载
最近在研究jdk源码,发现debug时无法查看源码里的变量值. 因为sun提供的jdk并不能查看运行中的局部变量,需要重新编译一下rt.jar. 下面这六步是编译jdk的具体步骤: Step 1: ...
- Golang源码探索(一) 编译和调试源码(转)
GO可以说是近几年最热门的新兴语言之一了, 一般人看到分布式和大数据就会想到GO,这个系列的文章会通过研究golang的源代码来分析内部的实现原理,和CoreCLR不同的是, golang的源代码已经 ...
- vlc源码分析(七) 调试学习HLS协议
HTTP Live Streaming(HLS)是苹果公司提出来的流媒体传输协议.与RTP协议不同的是,HLS可以穿透某些允许HTTP协议通过的防火墙. 一.HLS播放模式 (1) 点播模式(Vide ...
- .NET框架源码解读之SSCLI的调试支持
阅读源码一个比较快的手段就是在调试器里阅读,这样可以在实际运行SSCLI的过程中,通过堆栈跟踪的方式查看完整的程序执行路径. 当在SSCLI环境里执行一个托管程序的时候,堆栈上通常有托管和非托管代码同 ...
随机推荐
- java多线程快速入门(三)
通过实现Runnable接口实现多线程 package com.cppdy; //通过实现Runnable接口实现多线程 class MyThread1 implements Runnable{ @O ...
- P3660 【[USACO17FEB]Why Did the Cow Cross the Road III G】
题外话:维护区间交集子集的小套路 开两个树状数组,一个维护进入区间,一个维护退出区间 $Query:$ 给定询问区间$l,r$和一些其他区间,求其他区间中与$[l,r]$交集非空的区间个数 用上面维护 ...
- Jmeter NonGUI模式
一般情况下我们都是在NonGUI模式下运行jmeter.这样做有两个好处 节省系统资源,能够产生更大的负载 可以通过命令行参数对测试场景进行更精细的配置 示例 创建luzhi.jmx脚本 jmeter ...
- notepad++颜色修改
设置-->>语言格式设置-->> https://blog.csdn.net/onceing/article/details/51554399(别人博客园的内容) 另外下面是N ...
- 在php中调用以及编写接口(转)
如: http://localhost/openUser.php?act=get_user_list&type=json 在这里openUser.php相当于一个接口,其中get_user_l ...
- hdu 1875 给出每个结点的坐标 权值为两点间的距离 (MST)
Sample Input2210 10 //坐标20 2031 12 21000 1000 Sample Output1414.2 //最小权值和*100 保留1位小数oh! //不 ...
- Zookeeper笔记(三)部署与启动Zookeeper
下载zookeeper安装包 去Zookeeper官网,下载地址http://zookeeper.apache.org/releases.html,建议下载稳定版本,我下载的是zookeeper-3. ...
- 【BZOJ4927】第一题 双指针+DP
题解: 虽然是过了,不过做的十分智障 首先是有 2根 2 1 1 , 3根 1 1 1 这两种方法 然后考虑2 2 1 1 two-point-two没啥好说的 3 1 1 1 我很智障的以为数据范围 ...
- Codeforces 901C Bipartite Segments
Bipartite Segments 因为图中只存在奇数长度的环, 所以它是个只有奇数环的仙人掌, 每条边只属于一个环. 那么我们能把所有环给扣出来, 所以我们询问的区间不能包含每个环里的最大值和最小 ...
- HDU4686 Arc of Dream 矩阵
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - HDU4686 题意概括 a0 = A0 ai = ai-1*AX+AY b0 = B0 bi = bi-1* ...