opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

README.md error?

Open johncblacker opened this issue 2 years ago • 1 comments

Expected behaviour

README.md instructions for building old releases (or other than current) don't seem to work According to the README.md, to build using an older version of opencv or opencv_contrib one should perform a git checkout of the older release from within the opencv/opencv_contrib sub directories. When I did that, checking out version 4.5.5. I issued a git status and I'm indeed at that release in both subdirectories.

Actual behaviour

When I build the wheel with pip wheel . --verbose as directed in the README.me, it actually builds the 4.8 version instead.

Steps to reproduce

cd opencv git checkout dad26339a975b49cfb6c7dbe4bd5276c9dcb36e2 git status HEAD detached at dad26339a9 nothing to commit, working tree clean

cd opencv_contrib git git rev-list -n 1 4.5.5 fatal: ambiguous argument '4.5.5': unknown revision or path not in the working tree. git branch --all

  • 4.x remotes/origin/3.4 remotes/origin/33 remotes/origin/4.x remotes/origin/5.x remotes/origin/HEAD -> origin/4.x remotes/origin/feat/aarch64 remotes/origin/feat/manylinux2014 remotes/origin/feat/python39 remotes/origin/feat/qt5 remotes/origin/feat/sdist remotes/origin/gs/test-github-actions remotes/origin/gs/update-3.4 remotes/origin/gs/update-opencv-3.4-license remotes/origin/master
  • example code
  • operating system
  • architecture (e.g. x86)
  • opencv-python version

So, I presume opencv_contrib 4.x is sufficient and correct because there doen't appear to be a tag for 4.5.5

I notice that at the beginning of the build process, a git submobule update --init --recursive <cmake_source_dir> (the directory I presume is the opencv submodule subdirectory). It appears that after that command is issued a "git checkout" results in the following: Submodule path 'opencv': checked out 'f9a59f2592993d3dcc080e495f4f5e02dd8ec7ef' indicating that my checkout of 4.5.5 has been overridden with the 4.8 version.

I see no instructions in the README.md indicating that I forgot to do something. So, either the 4.8 version is somehow "baked" into the setup/config process somewhere or the git submodule update... command is the culprit but there needs to be some way of overriding that behavior; otherwise one can't build from an older source. I have verified that the git submodule update --init --recursive opencv command will indeed set the opencv HEAD back to version 4.8.

There needs to be either more clarity in the instructions or the process needs to be changed to allow building from older sources.

Issue submission checklist
  • [ x ] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • [x ] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • [x ] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • [x ] I'm using the latest version of opencv-python

johncblacker avatar Jul 25 '23 15:07 johncblacker

Yes, worked the last time I used opencv-python in this way, about a year ago. It looks like this was introduced with commit 615f3dff836d820398105b82b6ada39d0155cbdc. As a workaround, in setup.py, I commented out the whole if os.path.exists(".git"): block and everything worked as expected to build an older OpenCV version.

bjmcculloch avatar Aug 11 '23 18:08 bjmcculloch