Structure used to store interesting information on predictions. More...
#include "DarkHelpPredictionResult.hpp"
Public Member Functions | |
PredictionResult () | |
Constructor. More... | |
PredictionResult & | clear () |
Erase all the information in this prediction object. More... | |
bool | empty () const |
Returns true if this prediction hasn't yet been initialized, or if clear() has been called. More... | |
Public Attributes | |
MClassProbabilities | all_probabilities |
This is only useful if you have multiple classes, and an object may be one of several possible classes. More... | |
int | best_class |
The class that obtained the highest probability. More... | |
float | best_probability |
The probability of the class that obtained the highest value. More... | |
std::string | name |
A name to use for the object. More... | |
size_t | object_id |
If object tracking is in use, then the unique object ID will be stored here by the tracker. More... | |
cv::Point2f | original_point |
The original normalized X and Y coordinate returned by darknet. More... | |
cv::Size2f | original_size |
The original normalized width and height returned by darknet. More... | |
cv::Rect | rect |
OpenCV rectangle which describes where the object is located in the original image. More... | |
int | tile |
The tile number on which this object was found. More... | |
Structure used to store interesting information on predictions.
A vector of these is created and returned to the caller every time DarkHelp::NN::predict() is called. The most recent predictions are also stored in DarkHelp::NN::prediction_results.
|
inline |
|
inline |
Erase all the information in this prediction object.
References all_probabilities, best_class, best_probability, name, object_id, original_point, original_size, rect, and tile.
Referenced by PredictionResult().
|
inline |
Returns true
if this prediction hasn't yet been initialized, or if clear() has been called.
References all_probabilities, original_size, and rect.
MClassProbabilities DarkHelp::PredictionResult::all_probabilities |
This is only useful if you have multiple classes, and an object may be one of several possible classes.
For example, if your classes in your names
file are defined like this:
Then an image of a truck may be 10.5% car, 0% person, 95.8% truck, and 60.3% bus. Only the non-zero values are ever stored in this map, which for this example would be the following:
The C++ map would contains the following values:
(Note how person
is not stored in the map, since the probability for that class is 0%.)
In addition to all_probabilities
, the best results will also be duplicated in DarkHelp::PredictionResult::best_class and DarkHelp::PredictionResult::best_probability, which in this example would contain the values representing the truck:
Referenced by clear(), empty(), DarkHelp::NN::name_prediction(), DarkHelp::operator<<(), DarkHelp::NN::predict_internal_darknet(), and DarkHelp::yolo_load_annotations().
int DarkHelp::PredictionResult::best_class |
The class that obtained the highest probability.
For example, if an object is predicted to be 80% car or 60% truck, then the class id of the car would be stored in this variable.
Referenced by clear(), DarkHelp::NN::name_prediction(), DarkHelp::operator<<(), DarkHelp::NN::predict_internal_darknet(), and DarkHelp::yolo_load_annotations().
float DarkHelp::PredictionResult::best_probability |
The probability of the class that obtained the highest value.
For example, if an object is predicted to be 80% car or 60% truck, then the value of 0.80 would be stored in this variable.
Referenced by clear(), DarkHelp::NN::name_prediction(), DarkHelp::operator<<(), DarkHelp::NN::predict_internal_darknet(), and DarkHelp::yolo_load_annotations().
std::string DarkHelp::PredictionResult::name |
A name to use for the object.
If an object has multiple probabilities, then the one with the highest probability will be listed first. For example, a name could be "car 80%, truck 60%"
. The name
is used as a label when calling DarkHelp::NN::annotate().
Referenced by clear(), DarkHelp::NN::name_prediction(), DarkHelp::operator<<(), and DarkHelp::yolo_load_annotations().
size_t DarkHelp::PredictionResult::object_id |
If object tracking is in use, then the unique object ID will be stored here by the tracker.
Otherwise, this field will be zero
. Object tracking is not active by default.
Referenced by clear(), and DarkHelp::operator<<().
cv::Point2f DarkHelp::PredictionResult::original_point |
The original normalized X and Y coordinate returned by darknet.
This is the normalized mid-point, not the corner. If in doubt, you probably want to use rect.x
and rect.y
instead of this value.
Given this example annotated 230x134 image:
The original_point
returned would be:
original_point.x
= 0.652174 (mid x / image width, or 150 / 230) original_point.y
= 0.608209 (mid y / image height, or 81.5 / 134)Referenced by clear(), DarkHelp::NN::predict_internal_darknet(), DarkHelp::NN::snap_annotation(), and DarkHelp::yolo_load_annotations().
cv::Size2f DarkHelp::PredictionResult::original_size |
The original normalized width and height returned by darknet.
If in doubt, you probably want to use rect.width
and rect.height
instead of this value.
Given this example annotated 230x134 image:
The original_size
returned would be:
original_size.width
= 0.469565 (rect width / image width, or 108 / 230) original_size.height
= 0.649254 (rect height / image height, or 87 / 134)Referenced by clear(), empty(), DarkHelp::NN::predict_internal_darknet(), DarkHelp::NN::snap_annotation(), and DarkHelp::yolo_load_annotations().
cv::Rect DarkHelp::PredictionResult::rect |
OpenCV rectangle which describes where the object is located in the original image.
Given this example annotated 230x134 image:
The red rectangle returned would be:
rect.x
= 96 (top left) rect.y
= 38 (top left) rect.width
= 108 rect.height
= 87Referenced by clear(), empty(), DarkHelp::operator<<(), DarkHelp::NN::predict_internal_darknet(), DarkHelp::NN::snap_annotation(), and DarkHelp::yolo_load_annotations().
int DarkHelp::PredictionResult::tile |
The tile number on which this object was found.
This is mostly for debug purposes and only if tiling has been enabled (see DarkHelp::Config::enable_tiles), otherwise the value will always be zero.
Referenced by clear(), DarkHelp::operator<<(), DarkHelp::NN::predict_internal_darknet(), DarkHelp::NN::predict_internal_opencv(), and DarkHelp::yolo_load_annotations().