opencv问题记录

1.pycharm里不会提示函数

一开始觉得这个问题不大,大不了自己手打函数,但是真正用下来才发现,自动补全真的是IDE里最“伟大”的功能之一,且只有opencv库里的函数不会提示,在网上搜了几个方法,先谈谈无效的。

(1)添加解释器路径

最后一行可以看到我已经添加了cv库的路径了,然而并没有什么变化

(2)修改init.py文件

 

在cv的init文件中添加这两行,然而实测也无效 

最终找到一个有用的方法,那就是将cv版本降级。。。

在将4.6版本降为4.5之后,终于有提示了 

所以还是先用着4.5版本吧,看看后续有没有什么其他办法解决再更新。。


2.OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

此时无法正常打开视频

错误原因:

合成视频时,编码类型错误

解决方法:

  • 1.将fourcc = cv2.VideoWriter_fourcc(*“MJPG”)的"MJPG"改成"mp4v"
  • 2.将vw = cv2.VideoWriter(path, fourcc, fps, im.size)的fourcc直接改成 0x00000021

 实测第一种可以用,参考文章M2det问题:win10运行错误总结_callmeCassie的博客-CSDN博客


3.ModuleNotFoundError: No module named ‘skbuild’ 

参考这篇文章,ModuleNotFoundError: No module named ‘skbuild‘解决办法_月夜竹清的博客-CSDN博客

 解决方法:

pip install scikit-build

此时又报错

Problem with the CMake installation, aborting build. CMake executable is cmake

解决方法:

pip install cmake

结果到这里仍然报错

pip install opencv-python
Collecting opencv-python
  Downloading https://files.pythonhosted.org/packages/40/93/655af887bafece2a655998f53b9bd21ad94b0627d81d44aef35c79f40de6/opencv-python-4.7.0.72.tar.gz (91.1MB)
    100% |████████████████████████████████| 91.1MB 12kB/s
Requirement already satisfied: numpy>=1.13.3 in d:\programdata\anaconda3\envs\pytorch_test\lib\site-packages (from opencv-python)
Building wheels for collected packages: opencv-python
  Running setup.py bdist_wheel for opencv-python ... error
  Complete output from command D:\ProgramData\Anaconda3\envs\pytorch_test\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-2q8jwyor\\opencv-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\ADMINI~1\AppData\Local\Temp\tmp0jak8wsnpip-wheel- --python-tag cp36:


  --------------------------------------------------------------------------------
  -- Trying 'Ninja (Visual Studio 17 2022 x64 v143)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja (Visual Studio 17 2022 x64 v143)' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Visual Studio 17 2022 x64 v143' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 17 2022

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Visual Studio 17 2022 x64 v143' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Ninja (Visual Studio 16 2019 x64 v142)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja (Visual Studio 16 2019 x64 v142)' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Visual Studio 16 2019 x64 v142' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 16 2019

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Visual Studio 16 2019 x64 v142' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Ninja (Visual Studio 15 2017 x64 v141)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Ninja

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja (Visual Studio 15 2017 x64 v141)' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'Visual Studio 15 2017 x64 v141' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 15 2017

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Visual Studio 15 2017 x64 v141' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 17 2022 x64 v143)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 17 2022 x64 v143)' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 16 2019 x64 v142)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 16 2019 x64 v142)' generator - failure
  --------------------------------------------------------------------------------



  --------------------------------------------------------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 15 2017 x64 v141)' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      NMake Makefiles

    does not support platform specification, but platform

      x64

    was specified.


  -- Configuring incomplete, errors occurred!
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'NMake Makefiles (Visual Studio 15 2017 x64 v141)' generator - failure
  --------------------------------------------------------------------------------

  ********************************************************************************
  scikit-build could not get a working generator for your system. Aborting build.

  Building windows wheels for Python 3.6 requires Microsoft Visual Studio 2022.
  Get it with "Visual Studio 2017":

    https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2019":

      https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2022":

      https://visualstudio.microsoft.com/vs/

  ********************************************************************************

  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python
Failed to build opencv-python
Installing collected packages: opencv-python
  Running setup.py install for opencv-python ... error
    Complete output from command D:\ProgramData\Anaconda3\envs\pytorch_test\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-2q8jwyor\\opencv-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-9fjkd7n3-record\install-record.txt --single-version-externally-managed --compile:
    D:\ProgramData\Anaconda3\envs\pytorch_test\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      setuptools.SetuptoolsDeprecationWarning,


    --------------------------------------------------------------------------------
    -- Trying 'Ninja (Visual Studio 17 2022 x64 v143)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Ninja

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Ninja (Visual Studio 17 2022 x64 v143)' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'Visual Studio 17 2022 x64 v143' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Visual Studio 17 2022

      could not find any instance of Visual Studio.



    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Visual Studio 17 2022 x64 v143' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'Ninja (Visual Studio 16 2019 x64 v142)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Ninja

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Ninja (Visual Studio 16 2019 x64 v142)' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'Visual Studio 16 2019 x64 v142' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Visual Studio 16 2019

      could not find any instance of Visual Studio.



    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Visual Studio 16 2019 x64 v142' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'Ninja (Visual Studio 15 2017 x64 v141)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Ninja

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Ninja (Visual Studio 15 2017 x64 v141)' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'Visual Studio 15 2017 x64 v141' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        Visual Studio 15 2017

      could not find any instance of Visual Studio.



    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'Visual Studio 15 2017 x64 v141' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 17 2022 x64 v143)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        NMake Makefiles

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 17 2022 x64 v143)' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 16 2019 x64 v142)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        NMake Makefiles

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 16 2019 x64 v142)' generator - failure
    --------------------------------------------------------------------------------



    --------------------------------------------------------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 15 2017 x64 v141)' generator
    --------------------------------
    ---------------------------
    ----------------------
    -----------------
    ------------
    -------
    --
    Not searching for unused variables given on the command line.
    CMake Error at CMakeLists.txt:2 (PROJECT):
      Generator

        NMake Makefiles

      does not support platform specification, but platform

        x64

      was specified.


    -- Configuring incomplete, errors occurred!
    --
    -------
    ------------
    -----------------
    ----------------------
    ---------------------------
    --------------------------------
    -- Trying 'NMake Makefiles (Visual Studio 15 2017 x64 v141)' generator - failure
    --------------------------------------------------------------------------------

    ********************************************************************************
    scikit-build could not get a working generator for your system. Aborting build.

    Building windows wheels for Python 3.6 requires Microsoft Visual Studio 2022.
    Get it with "Visual Studio 2017":

      https://visualstudio.microsoft.com/vs/

    Or with "Visual Studio 2019":

        https://visualstudio.microsoft.com/vs/

    Or with "Visual Studio 2022":

        https://visualstudio.microsoft.com/vs/

    ********************************************************************************

    ----------------------------------------
Command "D:\ProgramData\Anaconda3\envs\pytorch_test\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-2q8jwyor\\opencv-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-9fjkd7n3-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-2q8jwyor\opencv-python\

 又查了一下,发现是版本问题,参考这篇文章解决

安装cv报错_小鲨鱼停止了思考的博客-CSDN博客

解决方法:

pip install opencv-python==3.2.0.7

提示安装成功 

pip install opencv-python==3.2.0.7
Collecting opencv-python==3.2.0.7
  Downloading https://files.pythonhosted.org/packages/df/14/291f9dd3c73aa35942aece85ee40235a1a3f471856b1c96d37df51142e97/opencv_python-3.2.0.7-cp36-cp36m-win_amd64.whl (22.2MB)
    100% |████████████████████████████████| 22.2MB 52kB/s
Requirement already satisfied: numpy>=1.11.3 in d:\programdata\anaconda3\envs\pytorch_test\lib\site-packages (from opencv-python==3.2.0.7)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.2.0.7
You are using pip version 9.0.1, however version 23.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OpenCV是一个开源的计算机视觉库,而FreeType是一个用于渲染字体的库。它们可以结合使用,以在图像或视觉应用程序中添加和呈现文字。 在OpenCV中,我们可以使用FreeType库来创建和渲染文本。首先,我们需要下载和安装FreeType库。然后,通过使用OpenCV的图像处理功能,我们可以创建一个图像对象并在其中绘制文本。接下来,使用FreeType库中的函数,我们可以选择字体类型、大小和属性,并将文本绘制到图像中的指定位置。最后,我们可以将生成的带有文本的图像显示出来,或者保存到磁盘上。 使用OpenCV和FreeType的组合,我们可以在图像、视频流或实时视频中添加文字标签、注释或其他文本信息。这对于图像处理、计算机视觉和机器学习应用非常有用,因为我们可以利用文本来描述和解释图像中的对象、特征和事件。例如,在监控系统中,我们可以在图像中标记和识别人脸、车辆或其他感兴趣的目标,并显示有关其位置、ID或其他属性的文本。另外,在计算机视觉的研究中,我们可以使用文本来记录实验结果、图像处理参数、算法描述等。 综上所述,OpenCV和FreeType的结合提供了一个强大的工具,用于在图像和视觉应用程序中添加和呈现文字。它们的结合使我们能够创建具有更多信息的视觉内容,并为图像处理、计算机视觉和机器学习任务提供更多可视化和解释能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值