Fix segmentation fault on yolo3Detection object copy

This commit fixes a segmentation fault appeared in yolo3 network
updating. Now in Camera_t structure type there is a network pointer.

Signed-off-by: Davide Sapienza <sapienza.dav@gmail.com>
This commit is contained in:
Davide Sapienza
2019-10-18 19:05:42 +02:00
parent d5ae26dfef
commit 1af2b792b8
2 changed files with 16 additions and 16 deletions
+15 -15
View File
@@ -167,6 +167,7 @@ void *computationTask(void *x_void_ptr)
Camera_t *camera = (Camera_t *)x_void_ptr; Camera_t *camera = (Camera_t *)x_void_ptr;
pthread_t visual, originalshow, detectionshow, topviewshow, disparityshow; pthread_t visual, originalshow, detectionshow, topviewshow, disparityshow;
pthread_t videocap; pthread_t videocap;
tk::dnn::Yolo3Detection yolo = *(camera->yolo);
//create video capture thread //create video capture thread
Frame_t info_f; Frame_t info_f;
info_f.input = camera->input; info_f.input = camera->input;
@@ -216,7 +217,6 @@ void *computationTask(void *x_void_ptr)
return (void *)1; return (void *)1;
}; };
} }
char *pmatrix = camera->pmatrix; char *pmatrix = camera->pmatrix;
/*projection matrix from camera to map*/ /*projection matrix from camera to map*/
cv::Mat H(cv::Size(3, 3), CV_64FC1); cv::Mat H(cv::Size(3, 3), CV_64FC1);
@@ -306,6 +306,7 @@ void *computationTask(void *x_void_ptr)
cv::Mat frame_crop; cv::Mat frame_crop;
cv::Mat dnn_input; cv::Mat dnn_input;
bool first_iteration = true; bool first_iteration = true;
while (gRun) while (gRun)
{ {
TIMER_START TIMER_START
@@ -338,8 +339,8 @@ void *computationTask(void *x_void_ptr)
// this will be resized to the net format // this will be resized to the net format
dnn_input = frame.clone(); dnn_input = frame.clone();
// TODO: async infer // TODO: async infer
camera->yolo.update(dnn_input); yolo.update(dnn_input);
int num_detected = camera->yolo.detected.size(); int num_detected = yolo.detected.size();
if (num_detected > MAX_DETECT_SIZE) if (num_detected > MAX_DETECT_SIZE)
num_detected = MAX_DETECT_SIZE; num_detected = MAX_DETECT_SIZE;
@@ -409,7 +410,7 @@ void *computationTask(void *x_void_ptr)
for (int i = 0; i < num_detected; i++) for (int i = 0; i < num_detected; i++)
{ {
b = camera->yolo.detected[i]; b = yolo.detected[i];
x0 = b.x; x0 = b.x;
// w = b.w; // w = b.w;
// x1 = b.x + w; // x1 = b.x + w;
@@ -509,7 +510,7 @@ void *computationTask(void *x_void_ptr)
info_show.adfGeoTransform[i] = adfGeoTransform[i]; info_show.adfGeoTransform[i] = adfGeoTransform[i];
// cv::Mat H; // cv::Mat H;
info_show.H = H.clone(); info_show.H = H.clone();
info_show.yolo = camera->yolo; info_show.yolo = yolo;
// std::copy(camera->yolo.begin(), camera->yolo.end(), info_show.yolo.begin()); // std::copy(camera->yolo.begin(), camera->yolo.end(), info_show.yolo.begin());
info_show.mask = mask.clone(); info_show.mask = mask.clone();
info_show.sem.unlock(); info_show.sem.unlock();
@@ -540,13 +541,12 @@ int main(int argc, char *argv[])
if(!read_parameters(argc, argv, &par)) if(!read_parameters(argc, argv, &par))
return -1; return -1;
// tk::dnn::Yolo3Detection yolo[par.n_cameras]; tk::dnn::Yolo3Detection yolo[par.n_cameras];
// for(int i=0; i<par.n_cameras; i++) for(int i=0; i<par.n_cameras; i++)
// { {
// std::cout<<"par net: "<<par.net<<std::endl; yolo[i].init(par.net);
// yolo[i].init(par.net); yolo[i].thresh = 0.25;
// yolo[i].thresh = 0.25; }
// }
// tk::dnn::Yolo3Detection yolo; // tk::dnn::Yolo3Detection yolo;
// yolo.init(net); // yolo.init(net);
// yolo.thresh = 0.25; // yolo.thresh = 0.25;
@@ -563,9 +563,9 @@ int main(int argc, char *argv[])
{ {
for(int j = 0; j < 6; j++ ) for(int j = 0; j < 6; j++ )
par.cameras[i].adfGeoTransform[j] = adfGeoTransform[j]; par.cameras[i].adfGeoTransform[j] = adfGeoTransform[j];
// par.cameras[i].yolo = yolo[i]; par.cameras[i].yolo = &yolo[i];
par.cameras[i].yolo.init(par.net); // par.cameras[i].yolo.init(par.net);
par.cameras[i].yolo.thresh = 0.25; // par.cameras[i].yolo.thresh = 0.25;
// cameras[i].yolo = yolo[i]; // cameras[i].yolo = yolo[i];
// cameras[i].yolo = yolo; // cameras[i].yolo = yolo;
+1 -1
View File
@@ -16,7 +16,7 @@ struct Camera_t
char *cameraCalib; char *cameraCalib;
char *maskFileOrient; char *maskFileOrient;
bool to_show; bool to_show;
tk::dnn::Yolo3Detection yolo; tk::dnn::Yolo3Detection *yolo;
double adfGeoTransform[6]; double adfGeoTransform[6];
}; };