1

I have a development machine working with ubuntu 22, python 3.10 and cv2; when I try to replicate on another machine then I get runtime error: from section calling age prediciton from haarclassifier and age_net.caffemodel: line 118 return age_net-forward() cv2.error: OpenCV(4.7.0-dev) (note this after building files from source orcv2 4.7.0 or 4.6.0 same result) /home/art/opencv_build/opencv/modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.cpp:401: error: (-215:Assertion failed) CONV_WINO_IBLOCK == 3 && CONV_WINO_ATOM_F32 == 4 in function 'winofunc_BtXB_8x8_f32'

I have tried various permutations of installing opencv-python or opencv-contrib-python or building and compiling the opencv files from source, always with the same result. Works on the original machine but always throws this error on the second machine when running the same python code.

I have searched online generally and in stackoverflow and I don't see anyone noting this error. Anyone know?

Tried to duplicate machine where it is working and various permuations of installing opencv either directly: pip3 install opencv-python or pip3 install opencv-contrib-python or build the opencv files from source,

which is generally to build the dependencies:

sudo apt install build-essential cmake git pkg-config libgtk-3-dev \    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \    libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \    gfortran openexr libatlas-base-dev python3-dev python3-numpy \    libtbb2 libtbb-dev libdc1394-dev

clone the repositories:

    $ mkdir ~/opencv_build && cd ~/opencv_build
    $ git clone https://github.com/opencv/opencv.git
    $ git clone https://github.com/opencv/opencv_contrib.git

make:

    Sudo ~/opencv_build/opencv/cmake -D CMAKE_BUILD_TYPE=RELEASE \  -D WITH_VTK=OFF -D    BUILD_opencv_viz=OFF
  -D CMAKE_INSTALL_PREFIX=/usr/local \    -D INSTALL_C_EXAMPLES=ON \    -D INSTALL_PYTHON_EXAMPLES=ON \    -D OPENCV_GENERATE_PKGCONFIG=ON \    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \    -D BUILD_EXAMPLES=ON ..

and then install

I check all the python code, file folder setup etc is the same, both running ubuntu 22, amd 64 bit. Works in the original machine, always throws the error in the second. The python code correctly captures an image, recognizes the face, crops the image and saves it before encountering the error, so the error is specifically to the haarclassifier and age prediction. I can't find any documentation or comments on the subject.

Community
  • 1
  • 1

3 Answers3

0

Today I tried out OpenCV 4.5.5. Works for me now.

baechlju
  • 56
  • 6
0

yes I reverted to 4.6.0.66 by 'sudo pip install opencv-contrib-python==4.6.0.66' to call the specific version and this version works whereas 4.7 does not work so I'm sure they will figure out whatever bug exists in their newest release.

0

This Allows using 4.7.0 and DNN will work ->

opencv-contrib-python-rolling==4.7.0.20230211

Edit: I found this workaround deep in a github issues comments somewhere in the opencv repos. I tested it myself and have our userbase using it as well for CPU based DNN and it works.

I am trying to find the link to the actual comment and issue thread where I found the info. Im fairly certain it was an openCV contributor who posted that workaround. I will update this answer with the link when I find it.

Edit 2: https://github.com/opencv/opencv/issues/23183#issuecomment-1407284812 - You can see in the original poster's issue that they receive the same/similar error cv2.error: OpenCV(4.7.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp:147: error: (-215:Assertion failed) _FX_WINO_IBLOCK == 3 && _FX_WINO_KBLOCK == 4 in function '_fx_winograd_accum_f32'. Even though the issue is Mac M1 focused, it pertains to all AVX instructions as well.

baudneo
  • 1
  • 2
  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit](https://stackoverflow.com/posts/76202641/edit) to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken May 11 '23 at 05:17