0

I'm writing a program like below

        class ocr
    {
    private:
    
    
    public:
        void char2mat(unsigned char* cimg, Mat &mat, int h, int w, int channel);
    
        void rotate(Mat &frame);
    
        void undistort(Mat &frame);
}

The problem is how am i able to set specific argument while running the program without writing down all the arguments. for example:,

is it possible to use char2mat function like this:

char2mat(test_img, output, channel=16)

without claiming h and w which should be default arguments. Maybe a struct would deal with this? Once there's a greater function than this, how's that possible to run it with plenty and plenty arguments written every time?

  • Nope, C++ does not work this way. – Sam Varshavchik Sep 10 '21 at 02:08
  • Maybe it is possible run with other arguments in default value? Or something like python's directory? OR just changing a struct of it ? –  Sep 10 '21 at 05:49
  • Sorry, but C++ is not Python. There's nothing else that can be said about this, really. If all parameters are the same type then an `std::unordered_map` might vaguely resemble something like this, but as soon as there are different types that'll close the books on this endeavor. Of course, there's always `std: variant` but it won't take very long before the work needed to handle maps of variants quickly exceeds the price of any convenience of named parameters. – Sam Varshavchik Sep 10 '21 at 11:50

0 Answers0