depth_anything_cpp icon indicating copy to clipboard operation
depth_anything_cpp copied to clipboard

time cost

Open dapao-0808 opened this issue 1 year ago • 2 comments

Hi! I've been able to run it on my own environment, and I've found that the time cost after acceleration via tensortt is not ideal, with an inference time of about 100ms. Instead of using google test, I added the new Main function.

int main(int argc,char** argv) { auto model = CreateModel(); model->InitPipeline(); auto [image] = ReadTestImages();

auto async_func = & { return model->ComputeDepthAsync(image); };

auto start = std::chrono::high_resolution_clock::now(); auto thread_fut = std::async(std::launch::async, async_func);

auto stereo_fut = thread_fut.get();

CHECK(stereo_fut.valid());

cv::Mat depth = stereo_fut.get();

auto end = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_caststd::chrono::milliseconds(end - start).count(); std::cout << "cost: " << duration << " ms" << std::endl;

double minVal, maxVal; cv::minMaxLoc(depth, &minVal, &maxVal); cv::Mat normalized_disp_pred; depth.convertTo(normalized_disp_pred, CV_8UC1, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));

cv::Mat color_normalized_disp_pred; cv::applyColorMap(normalized_disp_pred, color_normalized_disp_pred, cv::COLORMAP_JET); cv::imshow("depth",color_normalized_disp_pred); cv::waitKey(0);

//cv::imwrite("//home/nvidia/yolo/code/depth_anything_cpp/models/test_data/depth_anything_result_color.png", color_normalized_disp_pred); return 0; }

May I ask what the cost of your time is? My platform is a RTX 4060 laptop.

dapao-0808 avatar Mar 26 '25 07:03 dapao-0808

Hi! In the first running of the wrapped trt_core, it will initialize the TensorRT model context. So the latency of the whole pipeline will not be ideal. You could try another test case whose name is ended with *speed.

zz990099 avatar Mar 26 '25 07:03 zz990099

Hi! In the first running of the wrapped , it will initialize the TensorRT model context. So the latency of the whole pipeline will not be ideal. You could try another test case whose name is ended with .trt_core``*speed

Thank you very much! It is only the first processing that is time consuming

dapao-0808 avatar Mar 26 '25 08:03 dapao-0808