Cv::stereo_calibration() could not convert ‘16648’ from ‘int’ to ‘cv::TermCriteria’


The problem encountered when I tried to build Azure-kinect sdk, and it is require OpenCV installed to build the sdk, the os is ubuntu 16.04, and I install the OpenCV by sudo apt install libopencv-dev.

Now I have opencv and opencv2 installed in my computer, when I start build sdk, the following error has occured:

FAILED: /usr/bin/c++   -I/usr/include/opencv -Isrc/sdk/include -I../include -O2 -g -DNDEBUG -fPIE -fvisibility=hidden -fvisibility-inlines-hidden   -Wall -Wextra -Wno-missing-field-initializers -Werror -std=gnu++11 -MD -MT examples/green_screen/CMakeFiles/green_screen.dir/main.cpp.o -MF examples/green_screen/CMakeFiles/green_screen.dir/main.cpp.o.d -o examples/green_screen/CMakeFiles/green_screen.dir/main.cpp.o -c ../examples/green_screen/main.cpp
../examples/green_screen/main.cpp: In function ‘Transformation stereo_calibration(const k4a::calibration&, const k4a::calibration&, const std::vector<std::vector<cv::Point_<float> > >&, const std::vector<std::vector<cv::Point_<float> > >&, const Size&, const Size&, float)’:
../examples/green_screen/main.cpp:505:116: error: could not convert ‘16648’ from ‘int’ to ‘cv::TermCriteria’
                                        cv::CALIB_FIX_INTRINSIC | cv::CALIB_RATIONAL_MODEL | cv::CALIB_CB_FAST_CHECK);
ninja: build stopped: subcommand failed.

The error code is like this:

double error = cv::stereoCalibrate(chessboard_corners_world_nested_for_cv,
                                       tr.R, // output
                                       tr.t, // output
                                       cv::CALIB_FIX_INTRINSIC | cv::CALIB_RATIONAL_MODEL | cv::CALIB_CB_FAST_CHECK);

I guess it is the problem of the OpenCV version, Does anyone has some ideas in solving this problem?

Deepest thanks for your reply!

Please read the doc
in last doc last argument is TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6). you can find specific doc version with menu (top left) 3.0 to 4.5.2
You can find all version here
For opencv 2 doc is here Camera Calibration and 3D Reconstruction — OpenCV documentation

you’re getting OpenCV v2.4.9 or something close to that. Absolutely nobody should be using that anymore. any source code you find these days will be written for OpenCV v4.x or v3.x, and it will have trouble compiling against such an old version. the APIs are much improved now.

you should either get a fresher source of packages, or consider building OpenCV yourself from source.

Thanks a lot for your prompt reply!

I think I need to try build the OpenCV from the source, but before that, I need to figure out which version I need, thanks for providing these useful links!

Thanks again!

Thanks for your prompt reply!

The version of my OpenCV is v2.4.9. I do know that it is a very old version, but the code which had the error using #include <opencv2/core.hpp> , so I think it is using OpenCV v2.x.

And also it has a problem that is the core.hpp in my opencv 2 is located at opencv2/core/core.hpp , so I changed it to #include <opencv2/core/core.hpp> , otherwise it cannot find the location.

The reason why I used sudo apt install libopencv-dev to install OpenCv is followed the Kinect official instruction, but they only tested in ubuntu 18.04. So I wonder whether the version of OpenCV is installed different by this command in ubuntu 18.04 and ubuntu 16.04?

Maybe I need to try build OpenCV from source, but before that, I need to know the correct version.

Sorry for not provide more clear information before, do you have any ideas about which version I need to build from the source? Thanks again!

no. “opencv2” has been the directory for those includes since OpenCV v2, and even v4.x uses that directory.

it is certainly different. debian/ubuntu packages are always outdated (concerning OpenCV that’s certain).

go with the latest release of OpenCV. the Kinect SDK should say. if they don’t, they need to fix that.

1 Like

Deepest thanks for your reply! This problem has confused me a lot, I’ll try build latest version from the source.