Add demo_utils.

This commit splits the utils file into two different files:
utils and demo_utils, to overcome some opencv problems caused
by demo_utils includes.

Signed-off-by: Davide Sapienza <sapienza.dav@gmail.com>
This commit is contained in:
Davide Sapienza
2021-07-22 10:45:18 +02:00
parent 1216e8bb74
commit b9f82510d3
6 changed files with 43 additions and 22 deletions
+1
View File
@@ -4,6 +4,7 @@
//#include <unistd.h>
#include <mutex>
#include "demo_utils.h"
#include "CenternetDetection3D.h"
bool gRun;
+1
View File
@@ -4,6 +4,7 @@
//#include <unistd.h>
#include <mutex>
#include "demo_utils.h"
#include "CenterTrack.h"
bool gRun;
+22
View File
@@ -0,0 +1,22 @@
#ifndef DEMO_UTILS_H
#define DEMO_UTILS_H
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#ifdef __linux__
#include <unistd.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <yaml-cpp/yaml.h>
#endif
void readCalibrationMatrix(const std::string& path, cv::Mat& calib_mat);
#endif //DEMO_UTILS_H
-5
View File
@@ -15,11 +15,7 @@
#ifdef __linux__
#include <unistd.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <yaml-cpp/yaml.h>
#endif
#include <ios>
@@ -137,7 +133,6 @@ void matrixMulAdd( cublasHandle_t handle, dnnType* srcData, dnnType* dstData,
void getMemUsage(double& vm_usage_kb, double& resident_set_kb);
void printCudaMemUsage();
void removePathAndExtension(const std::string &full_string, std::string &name);
void readCalibrationMatrix(const std::string& path, cv::Mat& calib_mat);
static inline bool isCudaPointer(void *data) {
cudaPointerAttributes attr;
return cudaPointerGetAttributes(&attr, data) == 0;
+19
View File
@@ -0,0 +1,19 @@
#include "demo_utils.h"
void readCalibrationMatrix(const std::string& path, cv::Mat& calib_mat){
YAML::Node config = YAML::LoadFile(path);
//read camera matrix
int rows = config["camera_matrix"]["rows"].as<int>();
int cols = config["camera_matrix"]["cols"].as<int>();
cv::Mat calib = cv::Mat(cv::Size(rows, cols), CV_32F);
float *vals = (float *)calib.data;
for(int i=0; i < config["camera_matrix"]["data"].size(); ++i )
vals[i] = config["camera_matrix"]["data"][i].as<float>();
calib_mat = calib;
}
-17
View File
@@ -241,20 +241,3 @@ void removePathAndExtension(const std::string &full_string, std::string &name){
// std::cout<<"full string: "<<full_string<<" name: "<<name<<std::endl;
}
void readCalibrationMatrix(const std::string& path, cv::Mat& calib_mat){
YAML::Node config = YAML::LoadFile(path);
//read camera matrix
int rows = config["camera_matrix"]["rows"].as<int>();
int cols = config["camera_matrix"]["cols"].as<int>();
cv::Mat calib = cv::Mat(cv::Size(rows, cols), CV_32F);
float *vals = (float *)calib.data;
for(int i=0; i < config["camera_matrix"]["data"].size(); ++i )
vals[i] = config["camera_matrix"]["data"][i].as<float>();
calib_mat = calib;
}