Installing OpenCV-4.6.0-dev for python for stereoCalibrateExtended


I’m currently in the process of calibrating and validating a stereo camera.

In the current documentation OpenCV: Camera Calibration and 3D Reconstruction for the openCV 4.6.0-dev version, there exists the function stereoCalibrateExtended(), which returns, among other thing, the objects tvecs and rvecs, corresponding to the pose between the calibrated stereo camera and each target.

As far as I can see, this is the only OpenCV version, which returns these values and I’m very interested in them. I know calibrateCamera() returns these values as well, however, I need the exact values as computed by stereoCalibrate().

Now, for the life of me, I can’t figure out how to install the corresponding openCV version under python. Can someone point me to the right release on github which I need to build for this? So far, I checked out the 4.x branch from this repo: GitHub - opencv/opencv-python: Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages. and then also checked out the 4.x branch in the opencv git submodule directory and then build the python wheel from there. This does not seem to be right though.

Thank you very much


pip install opencv-python


thank you for the reply! This will install 4.6.0 and not 4.6.0-dev and that version does not return tvecs and rvecs, when calling stereoCalibrateExtended.

ignore the opencv-python repo. that’s for packaging a redistributable.

git clone the opencv repo

then run cmake-gui, fill in the source path, which just the root of the cloned repo, let’s say opencv/, and the “build” dir, which can be opencv/build/ (will be created)

then run the “configure” step. if that looks good, run the “generate” step. if that doesn’t look good, dump that output here and ask.

that’ll include a BUILD_ALL target and an INSTALL target. the install target takes care to copy the proper files into whatever python was detected.

Ahh I didn’t notice that.

You will need to build OpenCV yourself as @crackwitz said ignore the opencv-python repo unless you want to manually build a wheel yourself. Its more straight forward to just build install OpenCV with the relavent python variables filled in

Building and packaging OpenCV is not the issue at least i think it’s not.

As far as I understood it, everything should be build correctly and packaged into python wheel, when pulling the latest version from opencv into the opencv-python/opencv directory. At least the wheels that are built like that work perfectly fine.

My problem rather is that, I’m not sure which release/commit contains the stereoCalibrateExtended version that I’m looking for. As far as I can see, no feature branch contains this. I’m wondering where this 4.6.0-dev documentation is coming from.

They were added in this PR

If you need the python bindings for OpenCV you have two options

  1. Install a wheel
  2. Build OpenCV with the python bindings

With (1) the official wheel was built against OpenCV 4.6.0 so it doesn’t contain the update you require, therefore your only option is to either build a wheel against commits after that PR using the opencv_python repository or build OpenCV with python bindings against commits after that PR.

If you do (1) you can pip install your built wheel, if you do (2) the build process should install the bindings for you.

1 Like

Thank you very much, this helped and I got it to work!

Since I don’t like global installations very much, I really wanted to get it to work using the wheel approach, so that I could install it into my local python enviroment.

So for anyone interested: I ended up using the the opencv-python repository afterall. This required me to checkout the latest opencv 4.x branch into the opencv-python/opencv directory and (this is very important) stop the from checking out the 4.6.0. commit during the build process. I ended up just commenting out the git submodule sync lines. This is a very hacky and I bet there are more elegant ways to do this, but it worked for me and should suffice until the latest changes are packaged in an official release.

1 Like

I would suggest using the below which is less hacky. It will build from the latest commit and your wheel should be compatible python >= 3.6.

export ENABLE_ROLLING=1 or set ENABLE_ROLLING=1 on windows
python bdist_wheel --py-limited-api=cp36

1 Like