forked from VIAME/VIAME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetector4.cxx
59 lines (42 loc) · 1.91 KB
/
detector4.cxx
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
#include <vital/algorithm_plugin_manager.h>
#include <vital/config/config_block_io.h>
#include <vital/algo/image_object_detector.h>
#include <arrows/ocv/image_container.h>
#include <arrows/ocv/image_io.h>
#include <string>
int main( int argc, char* argv[] )
{
// (1) Create logger to use for reporting errors and other diagnostics.
kwiver::vital::logger_handle_t logger( kwiver::vital::get_logger( "detector_test" ));
// (2) Initialize and load all discoverable plugins
kwiver::vital::algorithm_plugin_manager::load_plugins_once();
// (3) get file name for input image
std::string filename = argv[1];
// (4) Look for name of config file as second parameter
kwiver::vital::config_block_sptr config;
config = kwiver::vital::read_config_file( argv[2] );
// (5) create image reader
kwiver::vital::algo::image_io_sptr image_reader( new kwiver::arrows::ocv::image_io() );
// (6) Read the image
kwiver::vital::image_container_sptr the_image = image_reader->load( filename );
// (7) Create the detector
kwiver::vital::algo::image_object_detector_sptr detector;
kwiver::vital::algo::image_object_detector::set_nested_algo_configuration( "detector", config, detector );
if ( ! detector )
{
LOG_ERROR( logger, "Unable to create detector" );
return 1;
}
kwiver::vital::algo::image_object_detector::get_nested_algo_configuration( "detector", config, detector );
// Check config so it will give run-time diagnostic of config problems
if ( ! kwiver::vital::algo::image_object_detector::check_nested_algo_configuration( "detector", config ) )
{
LOG_ERROR( logger, "Configuration check failed." );
return 1;
}
// (5) Send image to detector and get detections.
kwiver::vital::detected_object_set_sptr detections = detector->detect( the_image );
// (6) See what was detected
std::cout << "There were " << detections->size() << " detections in the image." << std::endl;
return 0;
}