Skip to content

Commit

Permalink
Merge pull request #151 from anarkiwi/minmax
Browse files Browse the repository at this point in the history
add min max of predicted bbox region.
  • Loading branch information
rashley-iqt authored Nov 29, 2023
2 parents cd21811 + bea6765 commit adfb7bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/image_inference_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,14 @@ void image_inference_impl::get_inference_() {
cv::Rect rssi_rect(int(tlx * xf), int(tly * yf), int(w * xf),
int(h * yf));
cv::Mat rssi_points = (*output_item.points_buffer)(rssi_rect);
double rssi_min, rssi_max;
cv::minMaxLoc(rssi_points, &rssi_min, &rssi_max);
float rssi = cv::mean(rssi_points)[0];
auto &augmented = results_json[prediction_class.key()][i];
augmented["rssi"] = rssi;
augmented["rssi_samples"] = rssi_points.cols * rssi_points.rows;
augmented["rssi_min"] = rssi_min;
augmented["rssi_max"] = rssi_max;
if (rssi >= min_peak_points_) {
++rendered_predictions;
cv::rectangle(*output_item.image_buffer, bbox_rect, white);
Expand Down
2 changes: 1 addition & 1 deletion python/iqtlabs/qa_image_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def test_instance(self):
self.assertGreaterEqual(rssi_max, rssi_mean, metadata_result)
self.assertTrue(os.path.exists(metadata_result["image_path"]))
self.assertTrue(os.path.exists(metadata_result["predictions_image_path"]))
for k in ("rssi", "rssi_samples"):
for k in ("rssi", "rssi_samples", "rssi_min", "rssi_max"):
del result["predictions"]["modulation"][0][k]
self.assertEqual(result["predictions"], predictions_result)

Expand Down

0 comments on commit adfb7bf

Please sign in to comment.