-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathprocess_using_bundle_and_dhthreads.cpp
64 lines (52 loc) · 1.5 KB
/
process_using_bundle_and_dhthreads.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
59
60
61
62
63
64
/* 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"
#include "DarkHelpThreads.hpp"
int main(int argc, char * argv[])
{
int rc = 0;
try
{
if (argc < 4)
{
std::cout
<< "Usage:" << std::endl
<< argv[0] << " <filename.dh> <key> <image.jpg> [<image2.jpg> ...]" << std::endl;
throw std::invalid_argument("wrong number of arguments");
}
std::string dh = argv[1];
std::string key = argv[2];
const size_t number_of_threads_to_start = 10;
DarkHelp::DHThreads dht(dh, key, number_of_threads_to_start);
// if you want to change some of the configuration settings, you'll need to do it *after* the network has been loaded
for (size_t i = 0; i < number_of_threads_to_start; i++)
{
DarkHelp::NN * nn = dht.get_nn(i);
if (nn)
{
nn->config.threshold = 0.2f;
nn->config.enable_tiles = false;
nn->config.snapping_enabled = false;
}
}
// add the images and immediately start processing them on different threads
for (int i = 3; i < argc; i++)
{
dht.add_images(argv[i]);
}
const auto results = dht.wait_for_results();
// display all of the filenames and the results for each one
for (const auto & [fn, predictions] : results)
{
std::cout << fn << ": " << predictions << std::endl;
}
}
catch (const std::exception & e)
{
std::cout << e.what() << std::endl;
rc = 1;
}
return rc;
}