summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f8e477d)
raw | patch | inline | side by side (parent: f8e477d)
author | Djordje Senicic <x0157990@ti.com> | |
Thu, 28 Feb 2019 17:03:28 +0000 (12:03 -0500) | ||
committer | Djordje Senicic <x0157990@ti.com> | |
Thu, 28 Feb 2019 17:03:28 +0000 (12:03 -0500) |
Signed-off-by: Djordje Senicic <x0157990@ti.com>
examples/ssd_multibox/main.cpp | patch | blob | history |
index 10714c74ae5d99409a7c4e2b97c9064dc0059ee0..5f92c5c85a569d8c3b12a13ffdd8df4433479b7d 100644 (file)
#include <queue>
#include <vector>
#include <cstdio>
+#include <string>
#include <chrono>
#include "executor.h"
/* Enable this macro to record individual output files and */
/* resized, cropped network input files */
-#define DEBUG_FILES
+//#define DEBUG_FILES
std::unique_ptr<ObjectClasses> object_classes;
uint32_t orig_width;
uint32_t orig_height;
uint32_t num_frames_file;
-
bool RunConfiguration(const cmdline_opts_t& opts);
Executor* CreateExecutor(DeviceType dt, uint32_t num, const Configuration& c,
int layers_group_id);
const Configuration& c, const cmdline_opts_t& opts,
VideoCapture &cap, ifstream &ifs);
bool WriteFrameOutput(const ExecutionObjectPipeline& eop,
- const Configuration& c, const cmdline_opts_t& opts);
+ const Configuration& c, const cmdline_opts_t& opts, float confidence_value);
static void DisplayHelp();
/***************************************************************/
/* Slider to control detection confidence level */
/***************************************************************/
-int prob_slider = DEFAULT_OUTPUT_PROB_THRESHOLD;
-int prob_slider_max = 100;
static void on_trackbar( int slider_id, void *inst )
{
//This function is invoked on every slider move.
//No action required, since prob_slider is automatically updated.
//But, for any additional operation on slider move, this is the place to insert code.
- //std::cout << "slider moved to:" << prob_slider << " max val is:" << prob_slider_max << endl;
}
bool RunConfiguration(const cmdline_opts_t& opts)
{
+ int prob_slider = DEFAULT_OUTPUT_PROB_THRESHOLD;
// Read the TI DL configuration file
Configuration c;
std::string config_file = "../test/testvecs/config/infer/tidl_config_"
VideoCapture cap;
if (! SetVideoInputOutput(cap, opts, "SSD_Multibox")) return false;
- char TrackbarName[50];
+ std::string TrackbarName("Confidence(%):");
prob_slider = (int)floor(opts.output_prob_threshold);
- sprintf( TrackbarName, "Prob(%d %%)", prob_slider_max );
- createTrackbar( TrackbarName, "SSD_Multibox", &prob_slider, prob_slider_max, on_trackbar );
+ createTrackbar( TrackbarName.c_str(), "SSD_Multibox", &prob_slider, 100, on_trackbar );
+ std::cout << TrackbarName << std::endl;
// setup preprocessed input
ifstream ifs;
// Wait for previous frame on the same eop to finish processing
if (eop->ProcessFrameWait())
{
- WriteFrameOutput(*eop, c, opts);
+ WriteFrameOutput(*eop, c, opts, (float)prob_slider);
}
// Read a frame and start processing it with current eo
// Create frame with boxes drawn around classified objects
bool WriteFrameOutput(const ExecutionObjectPipeline& eop,
- const Configuration& c, const cmdline_opts_t& opts)
+ const Configuration& c, const cmdline_opts_t& opts, float confidence_value)
{
// Asseembly original frame
int width = c.inWidth;
int height = c.inHeight;
int channel_size = width * height;
- Mat frame, r_frame, bgr[3];
+ Mat frame, bgr[3];
unsigned char *in = (unsigned char *) eop.GetInputBufferPtr();
bgr[0] = Mat(height, width, CV_8UC(1), in);
if (index < 0) break;
float score = out[i * 7 + 2];
- if (score * 100 < (float)prob_slider) continue;
+ if (score * 100 < confidence_value) continue;
int label = (int) out[i * 7 + 1];
int xmin = (int) (out[i * 7 + 3] * width);
object_class.color.red), 2);
}
- r_frame = frame;
if (opts.is_camera_input || opts.is_video_input)
{
- cv::imshow("SSD_Multibox", r_frame);
+ cv::imshow("SSD_Multibox", frame);
#ifdef DEBUG_FILES
// Image files can be converted into video using, example script
// (on desktop Ubuntu, with ffmpeg installed):
else
{
snprintf(outfile_name, 64, "multibox_%d.png", frame_index);
- cv::imwrite(outfile_name, r_frame);
+ cv::imwrite(outfile_name, frame);
printf("Saving frame %d with SSD multiboxes to: %s\n",
frame_index, outfile_name);
}