Fix saving result video in demoDepth, add automatic download for monodepth2 weights

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2022-01-19 10:22:06 -08:00
parent 907df27e07
commit decd73d298
3 changed files with 16 additions and 5 deletions
+6 -3
View File
@@ -55,9 +55,9 @@ int main(int argc, char *argv[]) {
cv::VideoWriter resultVideo; cv::VideoWriter resultVideo;
if(save) { if(save) {
int w = cap.get(cv::CAP_PROP_FRAME_WIDTH); int w = depthNN.output_w;
int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT); int h = depthNN.output_h;
resultVideo.open("result.mp4", cv::VideoWriter::fourcc('M','P','4','V'), 30, cv::Size(w, h)); resultVideo.open("result.mp4", cv::VideoWriter::fourcc('M','J','P','G'), 30, cv::Size(w, h));
} }
if(show) if(show)
@@ -87,6 +87,9 @@ int main(int argc, char *argv[]) {
cv::waitKey(1); cv::waitKey(1);
} }
if(save)
resultVideo << depthNN.depthMats[0];
} }
std::cout<<"detection end\n"; std::cout<<"detection end\n";
+6
View File
@@ -30,6 +30,9 @@ class DepthNN {
dnnType *input_d; dnnType *input_d;
float* depth_h; float* depth_h;
int output_w;
int output_h;
int nBatches = 1; int nBatches = 1;
cv::Mat bgr[3]; cv::Mat bgr[3];
@@ -69,6 +72,9 @@ class DepthNN {
depth_h = (float *)malloc(netRT->buffersDIM[1].tot() * sizeof(float)); depth_h = (float *)malloc(netRT->buffersDIM[1].tot() * sizeof(float));
output_h = netRT->buffersDIM[1].h;
output_w = netRT->buffersDIM[1].w;
} }
+4 -2
View File
@@ -66,11 +66,13 @@ const char* output_bin[] = {
"monodepth2/debug/outputs/output-disp-3.bin" "monodepth2/debug/outputs/output-disp-3.bin"
}; };
const char* input_monodepth2_bin[] = {"monodepth2/debug/input.bin","monodepth2/debug/input2.bin"}; const char* input_bin = "monodepth2/debug/input.bin";
int main(){ int main(){
downloadWeightsifDoNotExist(input_bin, "monodepth2", "https://cloud.hipert.unimore.it/s/iYw9QwgP6CsqxLR/download");
tk::dnn::dataDim_t dim(1,3,192,640,1); tk::dnn::dataDim_t dim(1,3,192,640,1);
tk::dnn::Network net(dim); tk::dnn::Network net(dim);
@@ -204,7 +206,7 @@ int main(){
dnnType *data; dnnType *data;
dnnType *input_H; dnnType *input_H;
readBinaryFile(input_monodepth2_bin[0],dim.tot(),&input_H,&data); readBinaryFile(input_bin, dim.tot(),&input_H,&data);
std::cout<<"INPUT DIMENSIONS : "<<dim.tot()<<std::endl; std::cout<<"INPUT DIMENSIONS : "<<dim.tot()<<std::endl;
net.print(); net.print();