diff --git a/CMakeLists.txt b/CMakeLists.txt index bea0917..cb2b1c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,9 @@ include_directories(${EIGEN3_INCLUDE_DIR}) find_package(OpenCV REQUIRED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV") +if(OpenCV_CUDA_VERSION) + add_compile_definitions(OPENCV_CUDACONTRIB) +endif() # gives problems in cross-compiling, probably malformed cmake config find_package(yaml-cpp REQUIRED) diff --git a/include/tkDNN/CenternetDetection3DTrack.h b/include/tkDNN/CenternetDetection3DTrack.h index dd092fa..4c036f4 100644 --- a/include/tkDNN/CenternetDetection3DTrack.h +++ b/include/tkDNN/CenternetDetection3DTrack.h @@ -151,7 +151,7 @@ public: std::vector> tr_res; std::vector> batchTracked; std::vector count_tr; - int track_id=0; + std::vector track_id; bool init_preprocessing(); @@ -161,7 +161,7 @@ public: void pre_inf(const int bi); void _get_additional_inputs(); cv::Mat transform_preds_with_trans(float x1, float x2); - void tracking(int bi); + void tracking(const int bi); public: tk::dnn::Network *pre_phase_net = nullptr; diff --git a/src/CenternetDetection3DTrack.cpp b/src/CenternetDetection3DTrack.cpp index 25c4c0b..3653896 100644 --- a/src/CenternetDetection3DTrack.cpp +++ b/src/CenternetDetection3DTrack.cpp @@ -14,12 +14,12 @@ bool CenternetDetection3DTrack::init(const std::string& tensor_path, const int n confThreshold = conf_thresh; inputCalibs = k_calibs; tr_res.resize(nBatches); + count_tr.resize(nBatches, 0); init_preprocessing(); init_pre_inf(); init_postprocessing(); init_visualization(n_classes); - count_tr.resize(nBatches, 0); } bool CenternetDetection3DTrack::init_preprocessing(){ @@ -203,6 +203,11 @@ bool CenternetDetection3DTrack::init_postprocessing(){ // Alloc array used in the kernel checkCuda( cudaMalloc(&src_out, K *sizeof(float)) ); checkCuda( cudaMalloc(&ids_out, K *sizeof(int)) ); + + for(int bi=0; bi& stream_size){ // -----------------------------------pre-process ------------------------------------------ - batchTracked.clear(); cv::Size sz = originalSize[bi]; float scale = 1.0; float new_height = sz.height * scale; @@ -375,7 +379,7 @@ void CenternetDetection3DTrack::preprocess(cv::Mat &frame, const int bi, const s cv::warpAffine(imageF, imageF, trans, cv::Size(dim.w, dim.h), cv::INTER_LINEAR ); - cv::imshow("warp", imageF); + //cv::imshow("warp", imageF); sz = imageF.size(); imageF.convertTo(imageF, CV_32FC3, 1/255.0); @@ -418,8 +422,7 @@ cv::Mat CenternetDetection3DTrack::transform_preds_with_trans(float x1, float x2 return trans_out * target_coords; } -void CenternetDetection3DTrack::tracking(int bi){ - +void CenternetDetection3DTrack::tracking(const int bi) { float item_size[count_det]; int item_cl[count_det]; float dets[2*count_det]; @@ -495,7 +498,7 @@ void CenternetDetection3DTrack::tracking(int bi){ int tr_id = matched_indices[2*i]; int d_id = matched_indices[2*i+1]; - // tr_res[bi][tr_id].det_res = det_res[d_id]; + // tr_res[tr_id].det_res = det_res[d_id]; tr_res[bi][tr_id].det_res.score = det_res[d_id].score; tr_res[bi][tr_id].det_res.cl = det_res[d_id].cl; tr_res[bi][tr_id].det_res.ct = det_res[d_id].ct; @@ -527,7 +530,6 @@ void CenternetDetection3DTrack::tracking(int bi){ tr_res[bi].clear(); count_tr[bi] = 0; } - int old_count_tr = count_tr[bi]; if(count_tr[bi] != 0 && new_count_tr != count_tr[bi]) { std::vector new_tr_res; @@ -535,7 +537,7 @@ void CenternetDetection3DTrack::tracking(int bi){ for(int i=0; i v_new_tr_res_; + v_new_tr_res_.push_back(new_tr_res_); + tr_res.push_back(v_new_tr_res_); + } + else + tr_res[bi].push_back(new_tr_res_); } } + count_tr[bi] = count_tr_; - if(track_id==1000) - track_id=0; + if(track_id[bi]==1000) + track_id[bi]=0; det_res.clear(); } @@ -747,8 +756,8 @@ void CenternetDetection3DTrack::draw(std::vector& frames) { int thickness = 2; for(int bi=0; bibuildEngineWithConfig(*networkRT, *configRT); #else //engineRT = builderRT->buildCudaEngine(*networkRT); - engineRT = std::shared_ptr(builderRT->buildCudaEngine(*networkRT)); + engineRT = builderRT->buildCudaEngine(*networkRT); #endif if(engineRT == nullptr) FatalError("cloud not build cuda engine")