OpenCV4를 이용, MacOS app만들기 (catalina)

2019.10.31 18:18컴퓨터

연구관련 프로젝트로 openCV를 이용할 일이 있어서, openCV를 공부하고

간단한 프로그램을 만들게되었는데,

공식적으로 MacOS app을 만들기 위한 라이브러리가 존재하지 않고

구글링으로 정확하게 방법을 다루는 글이 없어서 정리함

 

1. Homebrew install

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

2. Install opencv (aka opencv@4)

brew install opencv 

 

3. XCode 설정

Project -> build settings에서

3.1. Header search path (4.x.x는 알맞은 버젼번호로 바꾸기, recursive로 설정)

/usr/local/Cellar/opencv/4.x.x/include

3.2. Library search path (4.x.x는 알맞은 버젼번호로 바꾸기, recursive로 설정)

usr/local/Cellar/opencv/4.x.x/lib

3.3. Other Linker Flags

Terminal에서 

pkg-config --cflags --libs opencv4

했을때 나오는 flag들을 모두 Other Linker Flags에 입력함. (아래는 예시)

-I/usr/local/Cellar/opencv/4.1.2/include/opencv4/opencv -I/usr/local/Cellar/opencv/4.1.2/include/opencv4 -L/usr/local/Cellar/opencv/4.1.2/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_highgui -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core

 

 

References

https://www.learnopencv.com/install-opencv-4-on-macos/

https://medium.com/beesightsoft/macos-mojave-10-14-3-setup-environment-for-opencv4-0-1-c-develop-fcae955d6b33