0

I am trying to test the cpp version using main.cpp file at this link:

https://github.com/novioleo/crnn.mxnet/blob/master/cpp_invoker/main.cpp

But i am unable to understand how to read file in bytes as const std::vector so that i can pass it to predict function in predictor class.

Please help this is the main function i am using.

int main(int argc, char** argv) {
    predictor obj = predictor(argv[2],argv[3]);
   // read image here in bytes format
    try {
        std::string result = obj.predict(image);
    }catch(std::exception& e){
        std::cout<<e.what()<<std::endl;
    }
 return 0;
}

and this is my prediction function prototype

std::string predict(const std::vector<uchar> &byte_data);

if above things are unclear i can try to explain again. thank you very much.

Mark Storer
  • 15,209
  • 2
  • 37
  • 75
  • Please provide a [mcve]. Don't link to external sources. Don't spam tags. This is C++ and not C. – Thomas Sablik Oct 15 '19 at 09:37
  • You can't store an std::vector in a file. And surely the file doesn't contain one, it just contains bytes. So create the std::vector in your code and push_back the bytes that fread() provides. – Hans Passant Oct 15 '19 at 11:36
  • This is mostly a duplicate of https://stackoverflow.com/a/525103, though with a vector rather than a string. Retooling those answers shouldn't be too hard. – Mark Storer Oct 15 '19 at 12:12
  • Possible duplicate of [What is the best way to read an entire file into a std::string in C++?](https://stackoverflow.com/questions/116038/what-is-the-best-way-to-read-an-entire-file-into-a-stdstring-in-c) – Mark Storer Oct 15 '19 at 12:12

0 Answers0