Skip to content

Commit

Permalink
Merge pull request #2 from MistySOM/show-fps
Browse files Browse the repository at this point in the history
Show FPS + Fix warnings + Use c++ std libraries when possible + GStreamer Parameters
  • Loading branch information
matinlotfali authored Mar 2, 2023
2 parents 012e208 + 0306dfa commit da11f20
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 343 deletions.
4 changes: 3 additions & 1 deletion gst-plugin/src/ascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#ifndef ASCII_H
#define ASCII_H

const char g_ascii_table[][6] =
#include <array>

const static std::vector<std::array<char, 6>> g_ascii_table =
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* ' '*/
{0x00, 0x00, 0x79, 0x00, 0x00, 0x00}, /* ! */
Expand Down
21 changes: 8 additions & 13 deletions gst-plugin/src/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,14 @@ float box_iou(Box a, Box b)
* th_nms = threshold for nms
* Return value : -
******************************************/
void filter_boxes_nms(std::vector<detection> &det, int32_t size, float th_nms)
void filter_boxes_nms(std::vector<detection> &det, float th_nms)
{
int32_t count = size;
int32_t i = 0;
int32_t j = 0;
Box a;
Box b;
float b_intersection = 0;
for (i = 0; i < count; i++)
std::size_t count = det.size();

for (std::size_t i = 0; i < count; i++)
{
a = det[i].bbox;
for (j = 0; j < count; j++)
Box a = det[i].bbox;
for (std::size_t j = 0; j < count; j++)
{
if (i == j)
{
Expand All @@ -121,8 +117,8 @@ void filter_boxes_nms(std::vector<detection> &det, int32_t size, float th_nms)
{
continue;
}
b = det[j].bbox;
b_intersection = box_intersection(a, b);
Box b = det[j].bbox;
float b_intersection = box_intersection(a, b);
if ((box_iou(a, b)>th_nms) || (b_intersection >= a.h * a.w - 1) || (b_intersection >= b.h * b.w - 1))
{
if (det[i].prob > det[j].prob)
Expand All @@ -136,5 +132,4 @@ void filter_boxes_nms(std::vector<detection> &det, int32_t size, float th_nms)
}
}
}
return;
}
8 changes: 4 additions & 4 deletions gst-plugin/src/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#define BOX_H

#include <vector>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>

/*****************************************
* Box : Bounding box coordinates and its size
Expand All @@ -55,6 +55,6 @@ float box_iou(Box a, Box b);
float overlap(float x1, float w1, float x2, float w2);
float box_intersection(Box a, Box b);
float box_union(Box a, Box b);
void filter_boxes_nms(std::vector<detection> &det, int32_t size, float th_nms);
void filter_boxes_nms(std::vector<detection> &det, float th_nms);

#endif
23 changes: 8 additions & 15 deletions gst-plugin/src/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,22 @@
/*****************************************
* includes
******************************************/
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <cerrno>
#include <vector>
#include <array>
#include <map>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <float.h>
#include <math.h>

/*****************************************
* Common Static Variables
* - input_img = input image to DRP-AI (size and format are determined in DRP-AI Translator)
* - output_img = output image from the application with bounding box
******************************************/
const static std::string input_img = "sample.bmp";
const static std::string output_img = "sample_output.bmp";
#include <cfloat>
#include <cmath>

/*****************************************
* Static Variables and Macro for each YOLO model
Expand Down Expand Up @@ -107,11 +100,11 @@ const static std::vector<std::string> label_file_map = { "aeroplane", "bicycle",
/* Number of output layers. This value MUST match with the length of num_grids[] below */
#define NUM_INF_OUT_LAYER (1)
/* Number of grids in the image. The length of this array MUST match with the NUM_INF_OUT_LAYER */
const static uint8_t num_grids[] = { 13 };
const static std::array<uint8_t, NUM_INF_OUT_LAYER> num_grids = { 13 };
/* Number of DRP-AI output */
const static uint32_t num_inf_out = (NUM_CLASS + 5)* NUM_BB * num_grids[0] * num_grids[0];
/* Anchor box information */
const static double anchors[] =
const static std::vector<float> anchors =
{
1.3221, 1.73145,
3.19275, 4.00944,
Expand Down
Loading

0 comments on commit da11f20

Please sign in to comment.