Structure used to store interesting information on predictions. More...
Public Member Functions | |
PredictionResult () | |
Constructor. More... | |
bool | empty () const |
Returns true if this prediction hasn't yet been initialized, or if clear() has been called. More... | |
PredictionResult & | clear () |
Erase all the information in this prediction object. More... | |
Public Attributes | |
cv::Rect | rect |
OpenCV rectangle which describes where the object is located in the original image. 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... | |
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... | |
int | tile |
The tile number on which this object was found. More... | |
size_t | object_id |
If object tracking is in use, then the unique object ID will be stored here by the tracker. 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 |
Constructor.
|
inline |
Returns true
if this prediction hasn't yet been initialized, or if clear() has been called.
|
inline |
Erase all the information in this prediction object.
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
= 87cv::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)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)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:
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.
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.
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().
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.
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.