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:
@@ -4,6 +4,7 @@
|
|||||||
//#include <unistd.h>
|
//#include <unistd.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "demo_utils.h"
|
||||||
#include "CenternetDetection3D.h"
|
#include "CenternetDetection3D.h"
|
||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
//#include <unistd.h>
|
//#include <unistd.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
#include "demo_utils.h"
|
||||||
#include "CenterTrack.h"
|
#include "CenterTrack.h"
|
||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -15,11 +15,7 @@
|
|||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <opencv2/core/core.hpp>
|
|
||||||
#include <opencv2/highgui/highgui.hpp>
|
|
||||||
#include <opencv2/imgproc/imgproc.hpp>
|
|
||||||
|
|
||||||
#include <yaml-cpp/yaml.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ios>
|
#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 getMemUsage(double& vm_usage_kb, double& resident_set_kb);
|
||||||
void printCudaMemUsage();
|
void printCudaMemUsage();
|
||||||
void removePathAndExtension(const std::string &full_string, std::string &name);
|
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) {
|
static inline bool isCudaPointer(void *data) {
|
||||||
cudaPointerAttributes attr;
|
cudaPointerAttributes attr;
|
||||||
return cudaPointerGetAttributes(&attr, data) == 0;
|
return cudaPointerGetAttributes(&attr, data) == 0;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -241,20 +241,3 @@ void removePathAndExtension(const std::string &full_string, std::string &name){
|
|||||||
|
|
||||||
// std::cout<<"full string: "<<full_string<<" name: "<<name<<std::endl;
|
// 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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user