spacewalk01 / depth-anything-tensorrt

TensorRT implementation of Depth-Anything V1, V2
https://depth-anything.github.io/
MIT License
228 stars 28 forks source link

If I use the python version, will it be slower than the c++ version? #28

Closed gwxxx closed 2 months ago

spacewalk01 commented 2 months ago

I haven't tested it with python but I think so (from my experience, python inference often slower than that of c++). Hope it helps

gwxxx commented 2 months ago

I haven't tested it with python but I think so (from my experience, python inference often slower than that of c++). Hope it helps

Thanks for your reply. If I want to use c++ version, how can I save not only depth images but also the original float32 file?

spacewalk01 commented 2 months ago

You mean original depth values in float32? Currently, the code only generates a depth image. You need to add a function to write it into raw binary file. Here is an example but didn't test it!

#include <iostream>
#include <fstream>

using namespace std;

// Function to write a float pointer to a binary file
void writeFloatPointerToFile(const float* data, int size, const string& filename) {
    ofstream outFile(filename, ios::binary);

    if (!outFile) {
        cerr << "Unable to open file: " << filename << endl;
        return;
    }

    // Write the data to the file
    outFile.write(reinterpret_cast<const char*>(data), sizeof(float) * size);

    outFile.close();
}