install python

mac It comes with its own , Mainly used python3

install opencv

         One way is through homebrew To install , Installation command brew install
opencv@3( without “@3”, Will be installed opencv4,opencv4 Debugging failed , Finally, it will appear symbol not found Dynamic library for bug

ImportError:
dlopen(/opt/homebrew/Cellar/opencv/4.5.5/lib/python3.9/site-packages/cv2/python-3.9/cv2.cpython-39-darwin.so,
0x0002):

Symbol not found:
__ZN2cv3dnn14dnn4_v202112203Net10getLayerIdERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE

  Referenced from:
/opt/homebrew/Cellar/opencv/4.5.5/lib/python3.9/site-packages/cv2/python-3.9/cv2.cpython-39-darwin.so

  Expected in: /usr/local/lib/libopencv_dnn.4.5.5.dylib

)

         Pass in one way cmake To compile the source code .cmake There are two kinds of compilation , One is brew install cmake, use cmake Command to compile ,( After this method is installed ,opencv Library of /usr/local/lib in , Header file in /usr/local/include in , Not easy to find ). One is cmake Program compilation source code .( This approach and brew Are installed in a folder ,brew Is installed on homebrew In the installation folder of ,cmake Program is customized )

install opencv after , Enter commands at the terminal

        python3

        import cv2

If there is no prompt, it means opencv Correct installation

vscode debugging

The trickiest part of debugging is #include<opencv2/opencv.hpp> Wavy lines appear , Tips opencv.hpp unfound Error of

         terms of settlement : stay /usr/local/include establish opencv2 Soft links for

ps: It's said on the Internet vscode of c_cpp_properties Medium includepath It doesn't work ,( The specific reason is probably vscode of includepath Does not affect debug, Just matching is useful -- To be verified )

error 2:#include<opencv2/opencv.hpp> appear #include error

        terms of settlement : stay c_cpp_properties Correct setting in compile path.[ Usually /usr/bin/clang++]

error 3:Undefined symbols for architecture arm64:

        terms of settlement :tasks.json of args Last add "`pkg-config --cflags --libs
opencv`"[ This step is mainly to link dynamic libraries ,macos Dynamic libraries are not automatically linked ]

error 4: It is possible to encounter it again c++ Version requirements c++11 Situation of ( Generally, there is no such problem )

        terms of settlement :task.json of args add to "--std=c++11",

Configuration after completion ( Generally, you only need to tasks.json change )

tasks.json

 c_cpp_properties.json

launch.json

 

This is mainly a record , Mainly about the general idea and some of the most difficult problems , Sorry for the lack of details

homebrew stay m1 The specific installation process of Baidu .

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?