Updated to have more launching parameters
This commit is contained in:
+28
-7
@@ -12,6 +12,10 @@
|
|||||||
#include "Yolo3Detection.h"
|
#include "Yolo3Detection.h"
|
||||||
#include "send.h"
|
#include "send.h"
|
||||||
|
|
||||||
|
#define MAX_DETECT_SIZE 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
|
|
||||||
void sig_handler(int signo) {
|
void sig_handler(int signo) {
|
||||||
@@ -31,6 +35,16 @@ int main(int argc, char *argv[]) {
|
|||||||
char *input = "../demo/yolo_test.mp4";
|
char *input = "../demo/yolo_test.mp4";
|
||||||
if(argc > 2)
|
if(argc > 2)
|
||||||
input = argv[2];
|
input = argv[2];
|
||||||
|
char *pmatrix = "/home/classfog1/repos/MASA_server/pmatrix/proj_matrix_20937.txt";
|
||||||
|
if(argc > 3)
|
||||||
|
pmatrix = argv[3];
|
||||||
|
/*CAMID*/
|
||||||
|
int CAM_IDX = 0;
|
||||||
|
if(argc > 4)
|
||||||
|
CAM_IDX = atoi(argv[4]);
|
||||||
|
bool to_show = true;
|
||||||
|
if(argc > 5)
|
||||||
|
to_show = atoi(argv[5]);
|
||||||
|
|
||||||
tk::dnn::Yolo3Detection yolo;
|
tk::dnn::Yolo3Detection yolo;
|
||||||
yolo.init(net);
|
yolo.init(net);
|
||||||
@@ -48,9 +62,6 @@ int main(int argc, char *argv[]) {
|
|||||||
cv::Mat dnn_input;
|
cv::Mat dnn_input;
|
||||||
cv::namedWindow("detection", cv::WINDOW_NORMAL);
|
cv::namedWindow("detection", cv::WINDOW_NORMAL);
|
||||||
|
|
||||||
/*CAMID*/
|
|
||||||
const int CAM_IDX = 0;
|
|
||||||
|
|
||||||
/*projection matrix*/
|
/*projection matrix*/
|
||||||
float* proj_matrix = (float*) malloc(9*sizeof(float));
|
float* proj_matrix = (float*) malloc(9*sizeof(float));
|
||||||
int proj_matrix_read = 0;
|
int proj_matrix_read = 0;
|
||||||
@@ -59,6 +70,8 @@ int main(int argc, char *argv[]) {
|
|||||||
int sock;
|
int sock;
|
||||||
int socket_opened = 0;
|
int socket_opened = 0;
|
||||||
|
|
||||||
|
struct obj_coords *coords = (struct obj_coords*)malloc(MAX_DETECT_SIZE*sizeof(struct obj_coords));
|
||||||
|
|
||||||
while(gRun) {
|
while(gRun) {
|
||||||
|
|
||||||
|
|
||||||
@@ -73,16 +86,19 @@ int main(int argc, char *argv[]) {
|
|||||||
yolo.update(dnn_input);
|
yolo.update(dnn_input);
|
||||||
|
|
||||||
int coord_i = 0;
|
int coord_i = 0;
|
||||||
struct obj_coords *coords = (struct obj_coords*)malloc(yolo.detected.size()*sizeof(struct obj_coords));
|
int num_detected = yolo.detected.size();
|
||||||
|
if (num_detected > MAX_DETECT_SIZE)
|
||||||
|
num_detected = MAX_DETECT_SIZE;
|
||||||
|
|
||||||
if(proj_matrix_read == 0)
|
if(proj_matrix_read == 0)
|
||||||
read_projection_matrix(proj_matrix, proj_matrix_read);
|
read_projection_matrix(proj_matrix, proj_matrix_read, pmatrix);
|
||||||
|
|
||||||
/*printf("%f %f %f \n%f %f %f\n %f %f %f\n\n", proj_matrix[0],proj_matrix[1],
|
/*printf("%f %f %f \n%f %f %f\n %f %f %f\n\n", proj_matrix[0],proj_matrix[1],
|
||||||
proj_matrix[2],proj_matrix[3],proj_matrix[4],proj_matrix[5],
|
proj_matrix[2],proj_matrix[3],proj_matrix[4],proj_matrix[5],
|
||||||
proj_matrix[6],proj_matrix[7],proj_matrix[8]);*/
|
proj_matrix[6],proj_matrix[7],proj_matrix[8]);*/
|
||||||
|
|
||||||
// draw dets
|
// draw dets
|
||||||
for(int i=0; i<yolo.detected.size(); i++) {
|
for(int i=0; i<num_detected; i++) {
|
||||||
tk::dnn::box b = yolo.detected[i];
|
tk::dnn::box b = yolo.detected[i];
|
||||||
int x0 = b.x;
|
int x0 = b.x;
|
||||||
int x1 = b.x + b.w;
|
int x1 = b.x + b.w;
|
||||||
@@ -105,12 +121,17 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_client_dummy(coords, coord_i, sock, socket_opened, CAM_IDX);
|
send_client_dummy(coords, coord_i, sock, socket_opened, CAM_IDX);
|
||||||
free(coords);
|
|
||||||
|
|
||||||
|
if (to_show)
|
||||||
|
{
|
||||||
cv::imshow("detection", frame);
|
cv::imshow("detection", frame);
|
||||||
cv::waitKey(1);
|
cv::waitKey(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(coords);
|
||||||
|
free(proj_matrix);
|
||||||
|
|
||||||
std::cout<<"detection end\n";
|
std::cout<<"detection end\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -99,21 +99,21 @@ void convert_coords(struct obj_coords *coords, int i, int x, int y, int detected
|
|||||||
{
|
{
|
||||||
coords[i].LAT = coords[i].LAT / tmp_z;
|
coords[i].LAT = coords[i].LAT / tmp_z;
|
||||||
coords[i].LONG = coords[i].LONG / tmp_z;
|
coords[i].LONG = coords[i].LONG / tmp_z;
|
||||||
printf("lat: %f, long %f\n", coords[i].LAT, coords[i].LONG);
|
//printf("lat: %f, long %f\n", coords[i].LAT, coords[i].LONG);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Division by 0 (tmp_z)\n");
|
printf("Division by 0 (tmp_z)\n");
|
||||||
coords[i].cl = map_class_coco_to_voc(detected_class);
|
coords[i].cl = map_class_coco_to_voc(detected_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_projection_matrix(float * proj_matrix, int &proj_matrix_read)
|
void read_projection_matrix(float * proj_matrix, int &proj_matrix_read, char* path)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
|
|
||||||
fp = fopen("/home/classfog1/repos/MASA_server/pmatrix/proj_matrix_20937.txt", "r");
|
fp = fopen(path, "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user