detected-object.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3 
5 
6 
7 namespace
8 {
9  // Returns <intersection> / <union> of two rectangles ("source" and "destination").
10  // The higher the quotient (max 1), the more confidence we have that it's the same
11  // rectangle...
12  float calcIoU( cv::Rect const & src, cv::Rect const & dst )
13  {
14  cv::Rect i = src & dst;
15  cv::Rect u = src | dst;
16 
17  return static_cast<float>(i.area()) / static_cast<float>(u.area());
18  }
19 }
20 
21 
22 namespace openvino_helpers
23 {
25  size_t id,
26  std::string const & label,
27  cv::Rect const & location,
28  cv::Rect const & depth_location,
29  float intensity,
30  float depth
31  )
32  : _location( location )
33  , _depth_location( depth_location )
34  , _intensity( intensity )
35  , _depth( depth )
36  , _id( id )
37  , _label( label )
38  {
39  }
40 
41 
43  {
44  detected_object::ptr face_ptr;
45 
46  // The more static the face locations, the higher we can set the maxIoU; if a face stays put
47  // but grows/shrinks (gets closer/farther), the IoU doesn't change much, but if it moves then
48  // the IoU gets small very fast.
49  float maxIoU = 0.35f;
50 
51  for( auto && f : objects )
52  {
53  float iou = calcIoU( rect, f->get_location() );
54  if( iou > maxIoU )
55  {
56  face_ptr = f;
57  maxIoU = iou;
58  }
59  }
60 
61  return face_ptr;
62  }
63 }
detected_object(size_t id, std::string const &label, cv::Rect const &location, cv::Rect const &depth_location=cv::Rect{}, float intensity=1, float depth=0)
GLint location
std::list< detected_object::ptr > detected_objects
GLint GLint GLsizei GLsizei GLsizei depth
GLenum GLenum dst
Definition: glext.h:1751
GLsizei const GLchar *const * string
GLenum src
Definition: glext.h:1751
GLdouble f
Definition: example.hpp:70
GLuint GLsizei const GLchar * label
detected_object::ptr find_object(cv::Rect rect, detected_objects const &objects)
int i
std::shared_ptr< detected_object > ptr


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:12