-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathdisplay_single_image_custom_settings.cpp
58 lines (48 loc) · 1.64 KB
/
display_single_image_custom_settings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* DarkHelp - C++ helper class for Darknet's C API.
* Copyright 2019-2024 Stephane Charette <[email protected]>
* MIT license applies. See "license.txt" for details.
*/
#include "DarkHelp.hpp"
int main(int argc, char * argv[])
{
int rc = 0;
try
{
if (argc != 5)
{
std::cout
<< "Usage:" << std::endl
<< argv[0] << " <filename.cfg> <filename.names> <filename.weights> <filename.jpg>" << std::endl;
throw std::invalid_argument("wrong number of arguments");
}
std::string fn1 = argv[1];
std::string fn2 = argv[2];
std::string fn3 = argv[3];
std::string image = argv[4];
// You can customize settings before you load the network, or after you load the network. Or both, like we do in this example.
DarkHelp::Config config(fn1, fn2, fn3);
config.annotation_auto_hide_labels = false;
config.annotation_include_duration = true;
config.annotation_include_timestamp = false;
config.threshold = 0.25;
// Load the neural network using the configuration object.
DarkHelp::NN nn(config);
/* At this point the "config" object above is no longer used. The DarkHelp::NN object made a copy of it. When you
* want to alter additional config settings after this point, you'll need to do so via that copy in nn.config.
*/
nn.config.enable_tiles = false;
nn.config.annotation_line_thickness = 1;
nn.config.annotation_font_scale = 0.75;
// Call on the neural network to process the given filename
nn.predict(image);
// Display the annotated image.
cv::imshow("annotated", nn.annotate());
cv::waitKey();
}
catch (const std::exception & e)
{
std::cout << e.what() << std::endl;
rc = 1;
}
return rc;
}