we usually use functions that return one or no return value.
More than one different type of return value was recently returned on a project. You can use vector to return multiple parameters of the same type. If you can use the C++11 standard, you can use my method below
(1)import the header file.
More than one different type of return value was recently returned on a project. You can use vector to return multiple parameters of the same type. If you can use the C++11 standard, you can use my method below
(1)import the header file.
#include <tuple>
using namespace std;
(2)defined function,you can refer to the following code:
std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> Table_Detection(Mat srcImage,double firstblackline_rows_ratio_thresh,bool isHorizonLine,double left_right_cols_ratio_thresh,double up_down_rows_ratio_thresh,Mat srcImageBin);
(3)function,you can refer to the following code:The type returned should be the same as the defined type.
std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> Table_Detection(Mat srcImage,double firstblackline_rows_ratio_thresh,bool isHorizonLine,double left_right_cols_ratio_thresh,double up_down_rows_ratio_thresh,Mat srcImageBin)
{
;
return std::make_tuple(CUT_Table,table_new,Page_Info,isHorizonLine,table_new_cut,istablerecognition,Integrity_Check_Bottom,Integrity_Check_Top,Bottom_Integrity,Top_Integrity,tablesize);
}
(4)Now,you can call the return value. you can refer to the following code:Define a variable to receive the return parameter,the following code defines is the same as the define function.
std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> data;
You also can use the auto to define. Auto is an adaptive variable in the C++11 standard.
auto data;
You can use the get method to get the data. you can refer to the following code. The code of the get<0>data actually get is CUT_Table.
std::get<0>(data);
std::get<1>(data);
std::get<2>(data);
I hope I can help you,If you have any questions, please comment on this blog or send me a private message. I will reply in my free time.
Read More:
- Error c2371: ‘xxx’: redefinition; different basic types solutions
- Under the “return-d” mode, the number of “return / return” is 1
- Android:More than one file was found with OS independent path ‘res/values/values.xml
- Arrow function should not return assignment no-return-assign
- Unsupported operation types unsupported operation data types
- C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
- Analysis of compilation errors of “error conflicting types for function”
- About java “Error: bad binary operator types”
- ValueError: too many values to unpack
- ValueError: need more than 0 values to unpack
- Typeerror: UFUNC ‘isn’t supported for the input types
- Python — magic identify file types
- Ora-00947: not enough values
- Linux getsockopt SO_ERROR values (errno.h)
- error: ‘::main’ must return ‘int’
- Cannot find module ‘internal / util / types’ appears during gulp build
- Python3-ValueError:not enough values to unpack (expected 2, got 0)
- C++:error C2228: left of ‘.str’ must have class/struct/union
- ValueError: not enough values to unpack (expected 6, got 1)
- NPM error ‘cannot find module’ internal / util / types’ solution;