class stuff
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "Yolo3Detection.h"
|
||||
#include "send.h"
|
||||
|
||||
bool gRun;
|
||||
|
||||
@@ -33,6 +34,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
tk::dnn::Yolo3Detection yolo;
|
||||
yolo.init(net);
|
||||
yolo.thresh = 0.25;
|
||||
|
||||
gRun = true;
|
||||
|
||||
@@ -45,8 +47,21 @@ int main(int argc, char *argv[]) {
|
||||
cv::Mat frame;
|
||||
cv::Mat dnn_input;
|
||||
cv::namedWindow("detection", cv::WINDOW_NORMAL);
|
||||
|
||||
/*CAMID*/
|
||||
const int CAM_IDX = 0;
|
||||
|
||||
/*projection matrix*/
|
||||
float* proj_matrix = (float*) malloc(9*sizeof(float));
|
||||
int proj_matrix_read = 0;
|
||||
|
||||
/*socket*/
|
||||
int sock;
|
||||
int socket_opened = 0;
|
||||
|
||||
while(gRun) {
|
||||
|
||||
|
||||
cap >> frame;
|
||||
if(!frame.data) {
|
||||
continue;
|
||||
@@ -57,6 +72,15 @@ int main(int argc, char *argv[]) {
|
||||
// TODO: async infer
|
||||
yolo.update(dnn_input);
|
||||
|
||||
int coord_i = 0;
|
||||
struct obj_coords *coords = (struct obj_coords*)malloc(yolo.detected.size()*sizeof(struct obj_coords));
|
||||
if(proj_matrix_read == 0)
|
||||
read_projection_matrix(proj_matrix, proj_matrix_read);
|
||||
|
||||
/*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[6],proj_matrix[7],proj_matrix[8]);*/
|
||||
|
||||
// draw dets
|
||||
for(int i=0; i<yolo.detected.size(); i++) {
|
||||
tk::dnn::box b = yolo.detected[i];
|
||||
@@ -65,11 +89,23 @@ int main(int argc, char *argv[]) {
|
||||
int y0 = b.y;
|
||||
int y1 = b.y + b.h;
|
||||
int obj_class = b.cl;
|
||||
|
||||
|
||||
if(obj_class == 0 /*person*/ || obj_class == 1/*bicycle*/ || obj_class == 2/*car*/
|
||||
|| obj_class == 3/*motorbike*/ || obj_class == 5/*bus*/)
|
||||
{
|
||||
convert_coords(coords, coord_i,x0+b.w/2, y1,obj_class, proj_matrix);
|
||||
coord_i++;
|
||||
}
|
||||
|
||||
float prob = b.prob;
|
||||
|
||||
std::cout<<obj_class<<" ("<<prob<<"): "<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<"\n";
|
||||
cv::rectangle(frame, cv::Point(x0, y0), cv::Point(x1, y1), yolo.colors[obj_class], 2);
|
||||
}
|
||||
|
||||
send_client_dummy(coords, coord_i, sock, socket_opened, CAM_IDX);
|
||||
free(coords);
|
||||
|
||||
cv::imshow("detection", frame);
|
||||
cv::waitKey(1);
|
||||
|
||||
Reference in New Issue
Block a user