Add camera calibration file reading for demo3d and demoTracker.

Some minor fixes.

Signed-off-by: Davide Sapienza <sapienza.dav@gmail.com>
This commit is contained in:
Davide Sapienza
2021-07-21 16:14:53 +02:00
parent be2d361ac6
commit 1216e8bb74
7 changed files with 83 additions and 49 deletions
+23 -20
View File
@@ -31,27 +31,31 @@ int main(int argc, char *argv[]) {
if(argc > 2)
input = argv[2];
char ntype = 'c';
std::string calib_params = "";
if(argc > 3)
ntype = argv[3][0];
int n_classes = 3;
calib_params = argv[3];
char ntype = 'c';
if(argc > 4)
n_classes = atoi(argv[4]);
int n_batch = 1;
ntype = argv[4][0];
int n_classes = 3;
if(argc > 5)
n_batch = atoi(argv[5]);
bool show = true;
n_classes = atoi(argv[5]);
int n_batch = 1;
if(argc > 6)
show = atoi(argv[6]);
float conf_thresh=0.3;
n_batch = atoi(argv[6]);
bool show = true;
if(argc > 7)
conf_thresh = atof(argv[7]);
show = atoi(argv[7]);
float conf_thresh=0.3;
if(argc > 8)
conf_thresh = atof(argv[8]);
if(n_batch < 1 || n_batch > 64)
FatalError("Batch dim not supported");
if(!show)
SAVE_RESULT = true;
SAVE_RESULT = true;
tk::dnn::CenternetDetection3D cnet;
@@ -66,15 +70,14 @@ int main(int argc, char *argv[]) {
FatalError("Network type not allowed (3rd parameter)\n");
}
std::vector<cv::Mat> calibs;
// cv::Mat calib = cv::Mat::zeros(cv::Size(3,3), CV_32F);
// calib.at<float>(0,0) = 864.1243196486207;// * 512.0;//884.081444212;//864.1243196486207 * 512.0;// 633.0;
// calib.at<float>(0,2) = 726.7271690557819;// * 512.0;//0.0;//726.7271690557819 * 512.0;// 0.0; //w/2
// calib.at<float>(1,1) = 883.6552349216504;// * 512.0;//884.081444212;//883.6552349216504 * 512.0;// 633.0;
// calib.at<float>(1,2) = 506.8548506986564;// * 512.0;//0.0;//506.8548506986564 * 512.0;// 0.0; //h/2
// calibs.push_back(calib);
// calibs.push_back(calib);
// calibs.push_back(calib);
// calibs.push_back(calib);
if(!calib_params.empty() && calib_params!="NULL") {
std::cout<<"calib_params: "<<calib_params<<std::endl;
cv::Mat calib;
// the calibration matrix must be a 3x3 matrix
readCalibrationMatrix(calib_params, calib);
for(int bi=0; bi< n_batch; ++bi)
calibs.push_back(calib);
}
detNN->init(net, n_classes, n_batch, conf_thresh, calibs);
gRun = true;
+24 -22
View File
@@ -31,29 +31,32 @@ int main(int argc, char *argv[]) {
if(argc > 2)
input = argv[2];
char ntype = 'c';
std::string calib_params = "";
if(argc > 3)
ntype = argv[3][0];
int n_classes = 3;
calib_params = argv[3];
char ntype = 'c';
if(argc > 4)
n_classes = atoi(argv[4]);
int n_batch = 1;
ntype = argv[4][0];
int n_classes = 3;
if(argc > 5)
n_batch = atoi(argv[5]);
bool show = true;
n_classes = atoi(argv[5]);
int n_batch = 1;
if(argc > 6)
show = atoi(argv[6]);
float conf_thresh=0.3;
n_batch = atoi(argv[6]);
bool show = true;
if(argc > 7)
conf_thresh = atof(argv[7]);
bool t3d = true;
show = atoi(argv[7]);
float conf_thresh=0.3;
if(argc > 8)
t3d = atoi(argv[8]);
conf_thresh = atof(argv[8]);
bool t3d = true;
if(argc > 9)
t3d = atoi(argv[9]);
if(n_batch < 1 || n_batch > 64)
FatalError("Batch dim not supported");
if(!show)
SAVE_RESULT = true;
SAVE_RESULT = true;
tk::dnn::CenterTrack ctrack;
@@ -68,15 +71,14 @@ int main(int argc, char *argv[]) {
FatalError("Network type not allowed (3rd parameter)\n");
}
std::vector<cv::Mat> calibs;
// cv::Mat calib = cv::Mat::zeros(cv::Size(3,3), CV_32F);
// calib.at<float>(0,0) = 864.1243196486207;// * 512.0;//884.081444212;//864.1243196486207 * 512.0;// 633.0;
// calib.at<float>(0,2) = 726.7271690557819;// * 512.0;//0.0;//726.7271690557819 * 512.0;// 0.0; //w/2
// calib.at<float>(1,1) = 883.6552349216504;// * 512.0;//884.081444212;//883.6552349216504 * 512.0;// 633.0;
// calib.at<float>(1,2) = 506.8548506986564;// * 512.0;//0.0;//506.8548506986564 * 512.0;// 0.0; //h/2
// calibs.push_back(calib);
// calibs.push_back(calib);
// calibs.push_back(calib);
// calibs.push_back(calib);
if(!calib_params.empty() && calib_params!="NULL") {
std::cout<<"calib_params: "<<calib_params<<std::endl;
cv::Mat calib;
// the calibration matrix must be a 3x3 matrix
readCalibrationMatrix(calib_params, calib);
for(int bi=0; bi< n_batch; ++bi)
calibs.push_back(calib);
}
trackNN->init(net, n_classes, n_batch, conf_thresh, t3d, calibs);
gRun = true;