32 namespace perception {
35 bool Equal(
float x,
float target,
float eps = 1e-6f);
36 bool Equal(
double x,
double target,
double eps = 1e-6);
43 return inter.
Area() / rect1.
Area() > thresh;
49 if (inter.
Area() > 0) {
58 if (inter.
Area() > 0) {
65 bool Contain(
const std::vector<T> &array,
const T &element) {
66 for (
const auto &item : array) {
67 if (item == element) {
76 const T border_size = 0) {
77 if (box.
xmin < border_size || box.
ymin < border_size) {
80 if (box.
xmax + border_size > width || box.
ymax + border_size > height) {
87 const T border_size = 0) {
100 box_out->
width += box_out->
x;
103 if (box_out->
y < 0) {
107 if (box_out->
x >= width) {
111 if (box_out->
y >= height) {
116 : width - box_out->
x;
119 : height - box_out->
y;
120 if (box_out->
width < 0) {
123 if (box_out->
height < 0) {
128 template <
typename T>
139 bool LoadAnchors(
const std::string &path, std::vector<float> *anchors);
141 std::vector<base::ObjectSubType> *types);
142 bool LoadExpand(
const std::string &path, std::vector<float> *expands);
151 template <
typename T>
154 if (!mean || !variance) {
162 T sum = std::accumulate(data.begin(), data.end(),
static_cast<T
>(0));
163 *mean = sum / data.size();
165 std::vector<T>
diff(data.size());
166 std::transform(data.begin(), data.end(),
diff.begin(),
167 [mean](T x) {
return x - *mean; });
168 T sum_of_diff_sqrs = std::inner_product(
diff.begin(),
diff.end(),
169 diff.begin(),
static_cast<T
>(0));
170 *variance = sum_of_diff_sqrs / data.size();
bool IsCoveredHorizon(const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
Definition: util.h:46
T ymin
Definition: box.h:154
void FillObjectPolygonFromBBox3D(base::Object *object_ptr)
T width
Definition: box.h:119
bool LoadExpand(const std::string &path, std::vector< float > *expands)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool LoadAnchors(const std::string &path, std::vector< float > *anchors)
void CalculateMeanAndVariance(const std::vector< T > &data, T *mean, T *variance)
Definition: util.h:152
void RefineBox(const base::Rect< T > &box_in, const T width, const T height, base::Rect< T > *box_out)
Definition: util.h:93
bool ResizeCPU(const base::Blob< uint8_t > &src_gpu, std::shared_ptr< base::Blob< float >> dst, int stepwidth, int start_axis)
bool OutOfValidRegion(const base::BBox2D< T > box, const T width, const T height, const T border_size=0)
Definition: util.h:75
bool LoadTypes(const std::string &path, std::vector< base::ObjectSubType > *types)
bool Equal(float x, float target, float eps=1e-6f)
bool IsCoveredVertical(const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
Definition: util.h:55
T ymax
Definition: box.h:156
T height
Definition: box.h:120
T xmin
Definition: box.h:153
T xmax
Definition: box.h:155
std::string GetCyberWorkRoot()
bool IsCovered(const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
Definition: util.h:40
float diff(Image< float > *I, int x1, int y1, int x2, int y2)
Definition: segment_image.h:44
T Area() const
Definition: box.h:66
bool Contain(const std::vector< T > &array, const T &element)
Definition: util.h:65