| | |
| | | class Detector { |
| | | std::shared_ptr<void> detector_gpu_ptr; |
| | | std::deque<std::vector<bbox_t>> prev_bbox_vec_deque; |
| | | const int cur_gpu_id; |
| | | public: |
| | | float nms = .4; |
| | | |
| | |
| | | |
| | | sync_PyrLKOpticalFlow_gpu = cv::cuda::SparsePyrLKOpticalFlow::create(); |
| | | sync_PyrLKOpticalFlow_gpu->setWinSize(cv::Size(21, 21)); // 15, 21, 31 |
| | | sync_PyrLKOpticalFlow_gpu->setMaxLevel(5); // +- 50 ptx |
| | | sync_PyrLKOpticalFlow_gpu->setNumIters(2000); // def: 30 |
| | | sync_PyrLKOpticalFlow_gpu->setMaxLevel(3); // +- 5 ptx |
| | | sync_PyrLKOpticalFlow_gpu->setNumIters(1000); // def: 30 |
| | | |
| | | cv::cuda::setDevice(old_gpu_id); |
| | | } |
| | |
| | | void update_tracking_flow(cv::Mat src_mat) |
| | | { |
| | | int const old_gpu_id = cv::cuda::getDevice(); |
| | | if (old_gpu_id != gpu_id) |
| | | cv::cuda::setDevice(gpu_id); |
| | | |
| | | //cv::cuda::Stream stream; |
| | | |
| | | if (src_mat.channels() == 3) { |
| | | if (src_mat_gpu.cols == 0) { |
| | | src_mat_gpu = cv::cuda::GpuMat(src_mat.size(), src_mat.type()); |
| | |
| | | src_mat_gpu.upload(src_mat, stream); |
| | | cv::cuda::cvtColor(src_mat_gpu, src_grey_gpu, CV_BGR2GRAY, 0, stream); |
| | | } |
| | | if (old_gpu_id != gpu_id) |
| | | cv::cuda::setDevice(old_gpu_id); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | int const old_gpu_id = cv::cuda::getDevice(); |
| | | if(old_gpu_id != gpu_id) |
| | | cv::cuda::setDevice(gpu_id); |
| | | |
| | | //cv::cuda::Stream stream; |
| | | |
| | | if (dst_mat_gpu.cols == 0) { |
| | | dst_mat_gpu = cv::cuda::GpuMat(dst_mat.size(), dst_mat.type()); |
| | | dst_grey_gpu = cv::cuda::GpuMat(dst_mat.size(), CV_8UC1); |
| | | tmp_grey_gpu = cv::cuda::GpuMat(dst_mat.size(), CV_8UC1); |
| | | } |
| | | |
| | | |
| | | dst_mat_gpu.upload(dst_mat, stream); |
| | | |
| | | |
| | | cv::cuda::cvtColor(dst_mat_gpu, dst_grey_gpu, CV_BGR2GRAY, 0, stream); |
| | | |
| | | if (src_grey_gpu.rows != dst_grey_gpu.rows || src_grey_gpu.cols != dst_grey_gpu.cols) { |
| | |
| | | return cur_bbox_vec; |
| | | } |
| | | |
| | | //return cur_bbox_vec; |
| | | |
| | | cv::Mat prev_pts, prev_pts_flow_cpu, cur_pts_flow_cpu; |
| | | |
| | | for (auto &i : cur_bbox_vec) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (old_gpu_id != gpu_id) |
| | | cv::cuda::setDevice(old_gpu_id); |
| | | |
| | | return result_bbox_vec; |