[{"data":1,"prerenderedAt":1351},["ShallowReactive",2],{"post-ubuntu-opencv-install":3,"post-surround-ubuntu-opencv-install":1345},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"author":11,"summary":12,"category":13,"subcategory":14,"tags":15,"thumbnail":21,"body":22,"_type":1339,"_id":1340,"_source":1341,"_file":1342,"_stem":1343,"_extension":1344},"\u002Fposts\u002Fubuntu-opencv-install","posts",false,"","Ubuntu OpenCV 3.X 설치","이 포스트는 Ubuntu 터미널에서 명령어를 실행하는 것을 가정한다. 소스 다운로드부터 빌드까지 모든 명령어는 홈 디렉토리(~)에서 시작한다.","2019-06-10","Seongdo","Ubuntu에서 OpenCV 3.x를 소스 빌드로 설치하는 방법. 필수·선택 의존성 설치부터 CMake 구성, CUDA 가속 옵션, 빌드·설치까지 단계별로 정리했다.","library","computer-vision",[16,17,18,19,20],"opencv","ubuntu","computer vision","c++","linux","\u002Fimages\u002Fubuntu-opencv-install\u002FOpenCV_Logo_with_text.png",{"type":23,"children":24,"toc":1322},"root",[25,42,65,72,77,131,138,143,230,243,342,347,388,394,399,405,410,447,453,458,518,524,535,562,568,595,632,638,643,648,708,721,778,784,789,835,845,889,907,973,978,1092,1103,1142,1148,1159,1189,1202,1222,1258,1264,1288,1316],{"type":26,"tag":27,"props":28,"children":29},"element","p",{},[30,33,40],{"type":31,"value":32},"text","이 포스트는 Ubuntu 터미널에서 명령어를 실행하는 것을 가정한다. 소스 다운로드부터 빌드까지 모든 명령어는 홈 디렉토리(",{"type":26,"tag":34,"props":35,"children":37},"code",{"className":36},[],[38],{"type":31,"value":39},"~",{"type":31,"value":41},")에서 시작한다.",{"type":26,"tag":43,"props":44,"children":45},"blockquote",{},[46],{"type":26,"tag":27,"props":47,"children":48},{},[49,55,57,63],{"type":26,"tag":50,"props":51,"children":52},"strong",{},[53],{"type":31,"value":54},"참고:",{"type":31,"value":56}," OpenCV 3.4.6 기준으로 작성되었다. 현재 최신 버전은 4.x이며, ",{"type":26,"tag":34,"props":58,"children":60},{"className":59},[],[61],{"type":31,"value":62},"wget",{"type":31,"value":64}," URL의 버전 번호만 교체하면 동일한 절차로 설치할 수 있다.",{"type":26,"tag":66,"props":67,"children":69},"h2",{"id":68},"필수-라이브러리-설치",[70],{"type":31,"value":71},"필수 라이브러리 설치",{"type":26,"tag":27,"props":73,"children":74},{},[75],{"type":31,"value":76},"기본 빌드 도구, CMake, 압축 해제 도구를 먼저 설치한다.",{"type":26,"tag":78,"props":79,"children":83},"pre",{"className":80,"code":81,"language":82,"meta":7,"style":7},"language-bash shiki shiki-themes github-light github-dark","sudo apt-get install -y build-essential cmake unzip\n","bash",[84],{"type":26,"tag":34,"props":85,"children":86},{"__ignoreMap":7},[87],{"type":26,"tag":88,"props":89,"children":92},"span",{"class":90,"line":91},"line",1,[93,99,105,110,116,121,126],{"type":26,"tag":88,"props":94,"children":96},{"style":95},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[97],{"type":31,"value":98},"sudo",{"type":26,"tag":88,"props":100,"children":102},{"style":101},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[103],{"type":31,"value":104}," apt-get",{"type":26,"tag":88,"props":106,"children":107},{"style":101},[108],{"type":31,"value":109}," install",{"type":26,"tag":88,"props":111,"children":113},{"style":112},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[114],{"type":31,"value":115}," -y",{"type":26,"tag":88,"props":117,"children":118},{"style":101},[119],{"type":31,"value":120}," build-essential",{"type":26,"tag":88,"props":122,"children":123},{"style":101},[124],{"type":31,"value":125}," cmake",{"type":26,"tag":88,"props":127,"children":128},{"style":101},[129],{"type":31,"value":130}," unzip\n",{"type":26,"tag":132,"props":133,"children":135},"h3",{"id":134},"gcc-버전-관리-선택",[136],{"type":31,"value":137},"GCC 버전 관리 (선택)",{"type":26,"tag":27,"props":139,"children":140},{},[141],{"type":31,"value":142},"기본 GCC 버전으로 충분하다면 이 절은 건너뛰어도 된다. 특정 버전이 필요하다면 Ubuntu Toolchain PPA를 추가한 뒤 설치한다.",{"type":26,"tag":78,"props":144,"children":146},{"className":80,"code":145,"language":82,"meta":7,"style":7},"sudo add-apt-repository ppa:ubuntu-toolchain-r\u002Ftest\nsudo apt-get update\nsudo apt-get install gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7\n",[147],{"type":26,"tag":34,"props":148,"children":149},{"__ignoreMap":7},[150,167,184],{"type":26,"tag":88,"props":151,"children":152},{"class":90,"line":91},[153,157,162],{"type":26,"tag":88,"props":154,"children":155},{"style":95},[156],{"type":31,"value":98},{"type":26,"tag":88,"props":158,"children":159},{"style":101},[160],{"type":31,"value":161}," add-apt-repository",{"type":26,"tag":88,"props":163,"children":164},{"style":101},[165],{"type":31,"value":166}," ppa:ubuntu-toolchain-r\u002Ftest\n",{"type":26,"tag":88,"props":168,"children":170},{"class":90,"line":169},2,[171,175,179],{"type":26,"tag":88,"props":172,"children":173},{"style":95},[174],{"type":31,"value":98},{"type":26,"tag":88,"props":176,"children":177},{"style":101},[178],{"type":31,"value":104},{"type":26,"tag":88,"props":180,"children":181},{"style":101},[182],{"type":31,"value":183}," update\n",{"type":26,"tag":88,"props":185,"children":187},{"class":90,"line":186},3,[188,192,196,200,205,210,215,220,225],{"type":26,"tag":88,"props":189,"children":190},{"style":95},[191],{"type":31,"value":98},{"type":26,"tag":88,"props":193,"children":194},{"style":101},[195],{"type":31,"value":104},{"type":26,"tag":88,"props":197,"children":198},{"style":101},[199],{"type":31,"value":109},{"type":26,"tag":88,"props":201,"children":202},{"style":101},[203],{"type":31,"value":204}," gcc-5",{"type":26,"tag":88,"props":206,"children":207},{"style":101},[208],{"type":31,"value":209}," g++-5",{"type":26,"tag":88,"props":211,"children":212},{"style":101},[213],{"type":31,"value":214}," gcc-6",{"type":26,"tag":88,"props":216,"children":217},{"style":101},[218],{"type":31,"value":219}," g++-6",{"type":26,"tag":88,"props":221,"children":222},{"style":101},[223],{"type":31,"value":224}," gcc-7",{"type":26,"tag":88,"props":226,"children":227},{"style":101},[228],{"type":31,"value":229}," g++-7\n",{"type":26,"tag":27,"props":231,"children":232},{},[233,235,241],{"type":31,"value":234},"시스템 기본 컴파일러를 교체하려면 ",{"type":26,"tag":34,"props":236,"children":238},{"className":237},[],[239],{"type":31,"value":240},"update-alternatives",{"type":31,"value":242},"로 우선순위를 설정한다.",{"type":26,"tag":78,"props":244,"children":246},{"className":80,"code":245,"language":82,"meta":7,"style":7},"sudo update-alternatives --install \u002Fusr\u002Fbin\u002Fgcc gcc \u002Fusr\u002Fbin\u002Fgcc-7 70\nsudo update-alternatives --install \u002Fusr\u002Fbin\u002Fg++ g++ \u002Fusr\u002Fbin\u002Fg++-7 70\nsudo update-alternatives --config gcc\n",[247],{"type":26,"tag":34,"props":248,"children":249},{"__ignoreMap":7},[250,287,321],{"type":26,"tag":88,"props":251,"children":252},{"class":90,"line":91},[253,257,262,267,272,277,282],{"type":26,"tag":88,"props":254,"children":255},{"style":95},[256],{"type":31,"value":98},{"type":26,"tag":88,"props":258,"children":259},{"style":101},[260],{"type":31,"value":261}," update-alternatives",{"type":26,"tag":88,"props":263,"children":264},{"style":112},[265],{"type":31,"value":266}," --install",{"type":26,"tag":88,"props":268,"children":269},{"style":101},[270],{"type":31,"value":271}," \u002Fusr\u002Fbin\u002Fgcc",{"type":26,"tag":88,"props":273,"children":274},{"style":101},[275],{"type":31,"value":276}," gcc",{"type":26,"tag":88,"props":278,"children":279},{"style":101},[280],{"type":31,"value":281}," \u002Fusr\u002Fbin\u002Fgcc-7",{"type":26,"tag":88,"props":283,"children":284},{"style":112},[285],{"type":31,"value":286}," 70\n",{"type":26,"tag":88,"props":288,"children":289},{"class":90,"line":169},[290,294,298,302,307,312,317],{"type":26,"tag":88,"props":291,"children":292},{"style":95},[293],{"type":31,"value":98},{"type":26,"tag":88,"props":295,"children":296},{"style":101},[297],{"type":31,"value":261},{"type":26,"tag":88,"props":299,"children":300},{"style":112},[301],{"type":31,"value":266},{"type":26,"tag":88,"props":303,"children":304},{"style":101},[305],{"type":31,"value":306}," \u002Fusr\u002Fbin\u002Fg++",{"type":26,"tag":88,"props":308,"children":309},{"style":101},[310],{"type":31,"value":311}," g++",{"type":26,"tag":88,"props":313,"children":314},{"style":101},[315],{"type":31,"value":316}," \u002Fusr\u002Fbin\u002Fg++-7",{"type":26,"tag":88,"props":318,"children":319},{"style":112},[320],{"type":31,"value":286},{"type":26,"tag":88,"props":322,"children":323},{"class":90,"line":186},[324,328,332,337],{"type":26,"tag":88,"props":325,"children":326},{"style":95},[327],{"type":31,"value":98},{"type":26,"tag":88,"props":329,"children":330},{"style":101},[331],{"type":31,"value":261},{"type":26,"tag":88,"props":333,"children":334},{"style":112},[335],{"type":31,"value":336}," --config",{"type":26,"tag":88,"props":338,"children":339},{"style":101},[340],{"type":31,"value":341}," gcc\n",{"type":26,"tag":27,"props":343,"children":344},{},[345],{"type":31,"value":346},"마지막 명령을 실행하면 설치된 버전 목록이 출력되며, 번호를 입력해 기본값을 선택할 수 있다. 기본값은 바꾸지 않고 cmake 빌드에서만 특정 버전을 사용하려면, cmake 실행 시 다음 옵션을 추가한다.",{"type":26,"tag":78,"props":348,"children":350},{"className":80,"code":349,"language":82,"meta":7,"style":7},"-DCMAKE_C_COMPILER=\u002Fusr\u002Fbin\u002Fgcc-5 -DCMAKE_CXX_COMPILER=\u002Fusr\u002Fbin\u002Fg++-5\n",[351],{"type":26,"tag":34,"props":352,"children":353},{"__ignoreMap":7},[354],{"type":26,"tag":88,"props":355,"children":356},{"class":90,"line":91},[357,363,369,374,379,383],{"type":26,"tag":88,"props":358,"children":360},{"style":359},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[361],{"type":31,"value":362},"-DCMAKE_C_COMPILER",{"type":26,"tag":88,"props":364,"children":366},{"style":365},"--shiki-default:#D73A49;--shiki-dark:#F97583",[367],{"type":31,"value":368},"=",{"type":26,"tag":88,"props":370,"children":371},{"style":101},[372],{"type":31,"value":373},"\u002Fusr\u002Fbin\u002Fgcc-5",{"type":26,"tag":88,"props":375,"children":376},{"style":359},[377],{"type":31,"value":378}," -DCMAKE_CXX_COMPILER",{"type":26,"tag":88,"props":380,"children":381},{"style":365},[382],{"type":31,"value":368},{"type":26,"tag":88,"props":384,"children":385},{"style":101},[386],{"type":31,"value":387},"\u002Fusr\u002Fbin\u002Fg++-5\n",{"type":26,"tag":66,"props":389,"children":391},{"id":390},"선택-라이브러리-설치",[392],{"type":31,"value":393},"선택 라이브러리 설치",{"type":26,"tag":27,"props":395,"children":396},{},[397],{"type":31,"value":398},"필요한 기능에 따라 선택적으로 설치한다. 일반적인 개발 환경이라면 아래 항목 전체를 설치하는 것이 무난하다.",{"type":26,"tag":132,"props":400,"children":402},{"id":401},"이미지-포맷",[403],{"type":31,"value":404},"이미지 포맷",{"type":26,"tag":27,"props":406,"children":407},{},[408],{"type":31,"value":409},"JPEG, PNG, TIFF 파일 인코딩\u002F디코딩에 필요하다.",{"type":26,"tag":78,"props":411,"children":413},{"className":80,"code":412,"language":82,"meta":7,"style":7},"sudo apt-get install libjpeg-dev libpng-dev libtiff-dev\n",[414],{"type":26,"tag":34,"props":415,"children":416},{"__ignoreMap":7},[417],{"type":26,"tag":88,"props":418,"children":419},{"class":90,"line":91},[420,424,428,432,437,442],{"type":26,"tag":88,"props":421,"children":422},{"style":95},[423],{"type":31,"value":98},{"type":26,"tag":88,"props":425,"children":426},{"style":101},[427],{"type":31,"value":104},{"type":26,"tag":88,"props":429,"children":430},{"style":101},[431],{"type":31,"value":109},{"type":26,"tag":88,"props":433,"children":434},{"style":101},[435],{"type":31,"value":436}," libjpeg-dev",{"type":26,"tag":88,"props":438,"children":439},{"style":101},[440],{"type":31,"value":441}," libpng-dev",{"type":26,"tag":88,"props":443,"children":444},{"style":101},[445],{"type":31,"value":446}," libtiff-dev\n",{"type":26,"tag":132,"props":448,"children":450},{"id":449},"비디오-관련",[451],{"type":31,"value":452},"비디오 관련",{"type":26,"tag":27,"props":454,"children":455},{},[456],{"type":31,"value":457},"FFmpeg 기반 인코딩·디코딩, V4L2 카메라 입력, Xvid·H.264 코덱을 포함한다.",{"type":26,"tag":78,"props":459,"children":461},{"className":80,"code":460,"language":82,"meta":7,"style":7},"sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev \\\n  libv4l-dev libxvidcore-dev libx264-dev\n",[462],{"type":26,"tag":34,"props":463,"children":464},{"__ignoreMap":7},[465,500],{"type":26,"tag":88,"props":466,"children":467},{"class":90,"line":91},[468,472,476,480,485,490,495],{"type":26,"tag":88,"props":469,"children":470},{"style":95},[471],{"type":31,"value":98},{"type":26,"tag":88,"props":473,"children":474},{"style":101},[475],{"type":31,"value":104},{"type":26,"tag":88,"props":477,"children":478},{"style":101},[479],{"type":31,"value":109},{"type":26,"tag":88,"props":481,"children":482},{"style":101},[483],{"type":31,"value":484}," libavcodec-dev",{"type":26,"tag":88,"props":486,"children":487},{"style":101},[488],{"type":31,"value":489}," libavformat-dev",{"type":26,"tag":88,"props":491,"children":492},{"style":101},[493],{"type":31,"value":494}," libswscale-dev",{"type":26,"tag":88,"props":496,"children":497},{"style":112},[498],{"type":31,"value":499}," \\\n",{"type":26,"tag":88,"props":501,"children":502},{"class":90,"line":169},[503,508,513],{"type":26,"tag":88,"props":504,"children":505},{"style":101},[506],{"type":31,"value":507},"  libv4l-dev",{"type":26,"tag":88,"props":509,"children":510},{"style":101},[511],{"type":31,"value":512}," libxvidcore-dev",{"type":26,"tag":88,"props":514,"children":515},{"style":101},[516],{"type":31,"value":517}," libx264-dev\n",{"type":26,"tag":132,"props":519,"children":521},{"id":520},"gui",[522],{"type":31,"value":523},"GUI",{"type":26,"tag":27,"props":525,"children":526},{},[527,533],{"type":26,"tag":34,"props":528,"children":530},{"className":529},[],[531],{"type":31,"value":532},"cv::imshow()",{"type":31,"value":534}," 등 OpenCV 화면 출력 기능에 필요하다.",{"type":26,"tag":78,"props":536,"children":538},{"className":80,"code":537,"language":82,"meta":7,"style":7},"sudo apt-get install libgtk-3-dev\n",[539],{"type":26,"tag":34,"props":540,"children":541},{"__ignoreMap":7},[542],{"type":26,"tag":88,"props":543,"children":544},{"class":90,"line":91},[545,549,553,557],{"type":26,"tag":88,"props":546,"children":547},{"style":95},[548],{"type":31,"value":98},{"type":26,"tag":88,"props":550,"children":551},{"style":101},[552],{"type":31,"value":104},{"type":26,"tag":88,"props":554,"children":555},{"style":101},[556],{"type":31,"value":109},{"type":26,"tag":88,"props":558,"children":559},{"style":101},[560],{"type":31,"value":561}," libgtk-3-dev\n",{"type":26,"tag":132,"props":563,"children":565},{"id":564},"수학-라이브러리-및-기타",[566],{"type":31,"value":567},"수학 라이브러리 및 기타",{"type":26,"tag":27,"props":569,"children":570},{},[571,577,579,585,587,593],{"type":26,"tag":34,"props":572,"children":574},{"className":573},[],[575],{"type":31,"value":576},"libatlas-base-dev",{"type":31,"value":578},"는 행렬 연산을 가속하는 BLAS\u002FLAPACK 구현이다. ",{"type":26,"tag":34,"props":580,"children":582},{"className":581},[],[583],{"type":31,"value":584},"gfortran",{"type":31,"value":586},"은 ATLAS 일부 컴포넌트 빌드에 필요하고, ",{"type":26,"tag":34,"props":588,"children":590},{"className":589},[],[591],{"type":31,"value":592},"libgflags-dev",{"type":31,"value":594},"는 일부 contrib 모듈이 사용하는 커맨드라인 플래그 라이브러리다.",{"type":26,"tag":78,"props":596,"children":598},{"className":80,"code":597,"language":82,"meta":7,"style":7},"sudo apt-get install libatlas-base-dev gfortran libgflags-dev\n",[599],{"type":26,"tag":34,"props":600,"children":601},{"__ignoreMap":7},[602],{"type":26,"tag":88,"props":603,"children":604},{"class":90,"line":91},[605,609,613,617,622,627],{"type":26,"tag":88,"props":606,"children":607},{"style":95},[608],{"type":31,"value":98},{"type":26,"tag":88,"props":610,"children":611},{"style":101},[612],{"type":31,"value":104},{"type":26,"tag":88,"props":614,"children":615},{"style":101},[616],{"type":31,"value":109},{"type":26,"tag":88,"props":618,"children":619},{"style":101},[620],{"type":31,"value":621}," libatlas-base-dev",{"type":26,"tag":88,"props":623,"children":624},{"style":101},[625],{"type":31,"value":626}," gfortran",{"type":26,"tag":88,"props":628,"children":629},{"style":101},[630],{"type":31,"value":631}," libgflags-dev\n",{"type":26,"tag":66,"props":633,"children":635},{"id":634},"opencv-설치",[636],{"type":31,"value":637},"OpenCV 설치",{"type":26,"tag":132,"props":639,"children":641},{"id":640},"다운로드",[642],{"type":31,"value":640},{"type":26,"tag":27,"props":644,"children":645},{},[646],{"type":31,"value":647},"홈 디렉토리에서 실행한다.",{"type":26,"tag":78,"props":649,"children":651},{"className":80,"code":650,"language":82,"meta":7,"style":7},"wget -O opencv.zip https:\u002F\u002Fgithub.com\u002Fopencv\u002Fopencv\u002Farchive\u002F3.4.6.zip\nunzip opencv.zip\nmv opencv-3.4.6 opencv\n",[652],{"type":26,"tag":34,"props":653,"children":654},{"__ignoreMap":7},[655,677,690],{"type":26,"tag":88,"props":656,"children":657},{"class":90,"line":91},[658,662,667,672],{"type":26,"tag":88,"props":659,"children":660},{"style":95},[661],{"type":31,"value":62},{"type":26,"tag":88,"props":663,"children":664},{"style":112},[665],{"type":31,"value":666}," -O",{"type":26,"tag":88,"props":668,"children":669},{"style":101},[670],{"type":31,"value":671}," opencv.zip",{"type":26,"tag":88,"props":673,"children":674},{"style":101},[675],{"type":31,"value":676}," https:\u002F\u002Fgithub.com\u002Fopencv\u002Fopencv\u002Farchive\u002F3.4.6.zip\n",{"type":26,"tag":88,"props":678,"children":679},{"class":90,"line":169},[680,685],{"type":26,"tag":88,"props":681,"children":682},{"style":95},[683],{"type":31,"value":684},"unzip",{"type":26,"tag":88,"props":686,"children":687},{"style":101},[688],{"type":31,"value":689}," opencv.zip\n",{"type":26,"tag":88,"props":691,"children":692},{"class":90,"line":186},[693,698,703],{"type":26,"tag":88,"props":694,"children":695},{"style":95},[696],{"type":31,"value":697},"mv",{"type":26,"tag":88,"props":699,"children":700},{"style":101},[701],{"type":31,"value":702}," opencv-3.4.6",{"type":26,"tag":88,"props":704,"children":705},{"style":101},[706],{"type":31,"value":707}," opencv\n",{"type":26,"tag":27,"props":709,"children":710},{},[711,713,719],{"type":31,"value":712},"SIFT·SURF 등 특허 알고리즘을 포함한 비상업 모듈이 필요하다면 ",{"type":26,"tag":34,"props":714,"children":716},{"className":715},[],[717],{"type":31,"value":718},"opencv_contrib",{"type":31,"value":720},"도 함께 받는다. 상업적 목적으로 사용할 경우 라이선스를 별도로 확인해야 한다.",{"type":26,"tag":78,"props":722,"children":724},{"className":80,"code":723,"language":82,"meta":7,"style":7},"wget -O opencv_contrib.zip https:\u002F\u002Fgithub.com\u002Fopencv\u002Fopencv_contrib\u002Farchive\u002F3.4.6.zip\nunzip opencv_contrib.zip\nmv opencv_contrib-3.4.6 opencv_contrib\n",[725],{"type":26,"tag":34,"props":726,"children":727},{"__ignoreMap":7},[728,749,761],{"type":26,"tag":88,"props":729,"children":730},{"class":90,"line":91},[731,735,739,744],{"type":26,"tag":88,"props":732,"children":733},{"style":95},[734],{"type":31,"value":62},{"type":26,"tag":88,"props":736,"children":737},{"style":112},[738],{"type":31,"value":666},{"type":26,"tag":88,"props":740,"children":741},{"style":101},[742],{"type":31,"value":743}," opencv_contrib.zip",{"type":26,"tag":88,"props":745,"children":746},{"style":101},[747],{"type":31,"value":748}," https:\u002F\u002Fgithub.com\u002Fopencv\u002Fopencv_contrib\u002Farchive\u002F3.4.6.zip\n",{"type":26,"tag":88,"props":750,"children":751},{"class":90,"line":169},[752,756],{"type":26,"tag":88,"props":753,"children":754},{"style":95},[755],{"type":31,"value":684},{"type":26,"tag":88,"props":757,"children":758},{"style":101},[759],{"type":31,"value":760}," opencv_contrib.zip\n",{"type":26,"tag":88,"props":762,"children":763},{"class":90,"line":186},[764,768,773],{"type":26,"tag":88,"props":765,"children":766},{"style":95},[767],{"type":31,"value":697},{"type":26,"tag":88,"props":769,"children":770},{"style":101},[771],{"type":31,"value":772}," opencv_contrib-3.4.6",{"type":26,"tag":88,"props":774,"children":775},{"style":101},[776],{"type":31,"value":777}," opencv_contrib\n",{"type":26,"tag":132,"props":779,"children":781},{"id":780},"cmake-구성",[782],{"type":31,"value":783},"CMake 구성",{"type":26,"tag":27,"props":785,"children":786},{},[787],{"type":31,"value":788},"빌드 디렉토리를 생성하고 CMake를 실행한다.",{"type":26,"tag":78,"props":790,"children":792},{"className":80,"code":791,"language":82,"meta":7,"style":7},"cd opencv\nmkdir build && cd build\n",[793],{"type":26,"tag":34,"props":794,"children":795},{"__ignoreMap":7},[796,808],{"type":26,"tag":88,"props":797,"children":798},{"class":90,"line":91},[799,804],{"type":26,"tag":88,"props":800,"children":801},{"style":112},[802],{"type":31,"value":803},"cd",{"type":26,"tag":88,"props":805,"children":806},{"style":101},[807],{"type":31,"value":707},{"type":26,"tag":88,"props":809,"children":810},{"class":90,"line":169},[811,816,821,826,830],{"type":26,"tag":88,"props":812,"children":813},{"style":95},[814],{"type":31,"value":815},"mkdir",{"type":26,"tag":88,"props":817,"children":818},{"style":101},[819],{"type":31,"value":820}," build",{"type":26,"tag":88,"props":822,"children":823},{"style":359},[824],{"type":31,"value":825}," && ",{"type":26,"tag":88,"props":827,"children":828},{"style":112},[829],{"type":31,"value":803},{"type":26,"tag":88,"props":831,"children":832},{"style":101},[833],{"type":31,"value":834}," build\n",{"type":26,"tag":27,"props":836,"children":837},{},[838,843],{"type":26,"tag":34,"props":839,"children":841},{"className":840},[],[842],{"type":31,"value":718},{"type":31,"value":844}," 없이 기본 빌드하는 경우:",{"type":26,"tag":78,"props":846,"children":848},{"className":80,"code":847,"language":82,"meta":7,"style":7},"cmake -DCMAKE_BUILD_TYPE=RELEASE \\\n      -DCMAKE_INSTALL_PREFIX=\u002Fusr\u002Flocal \\\n      ..\n",[849],{"type":26,"tag":34,"props":850,"children":851},{"__ignoreMap":7},[852,869,881],{"type":26,"tag":88,"props":853,"children":854},{"class":90,"line":91},[855,860,865],{"type":26,"tag":88,"props":856,"children":857},{"style":95},[858],{"type":31,"value":859},"cmake",{"type":26,"tag":88,"props":861,"children":862},{"style":112},[863],{"type":31,"value":864}," -DCMAKE_BUILD_TYPE=RELEASE",{"type":26,"tag":88,"props":866,"children":867},{"style":112},[868],{"type":31,"value":499},{"type":26,"tag":88,"props":870,"children":871},{"class":90,"line":169},[872,877],{"type":26,"tag":88,"props":873,"children":874},{"style":112},[875],{"type":31,"value":876},"      -DCMAKE_INSTALL_PREFIX=\u002Fusr\u002Flocal",{"type":26,"tag":88,"props":878,"children":879},{"style":112},[880],{"type":31,"value":499},{"type":26,"tag":88,"props":882,"children":883},{"class":90,"line":186},[884],{"type":26,"tag":88,"props":885,"children":886},{"style":101},[887],{"type":31,"value":888},"      ..\n",{"type":26,"tag":27,"props":890,"children":891},{},[892,897,899,905],{"type":26,"tag":34,"props":893,"children":895},{"className":894},[],[896],{"type":31,"value":718},{"type":31,"value":898}," 포함 빌드하는 경우 (",{"type":26,"tag":34,"props":900,"children":902},{"className":901},[],[903],{"type":31,"value":904},"-DOPENCV_ENABLE_NONFREE=ON",{"type":31,"value":906},"은 특허 알고리즘 활성화):",{"type":26,"tag":78,"props":908,"children":910},{"className":80,"code":909,"language":82,"meta":7,"style":7},"cmake -DCMAKE_BUILD_TYPE=RELEASE \\\n      -DCMAKE_INSTALL_PREFIX=\u002Fusr\u002Flocal \\\n      -DOPENCV_ENABLE_NONFREE=ON \\\n      -DOPENCV_EXTRA_MODULES_PATH=..\u002F..\u002Fopencv_contrib\u002Fmodules \\\n      ..\n",[911],{"type":26,"tag":34,"props":912,"children":913},{"__ignoreMap":7},[914,929,940,952,965],{"type":26,"tag":88,"props":915,"children":916},{"class":90,"line":91},[917,921,925],{"type":26,"tag":88,"props":918,"children":919},{"style":95},[920],{"type":31,"value":859},{"type":26,"tag":88,"props":922,"children":923},{"style":112},[924],{"type":31,"value":864},{"type":26,"tag":88,"props":926,"children":927},{"style":112},[928],{"type":31,"value":499},{"type":26,"tag":88,"props":930,"children":931},{"class":90,"line":169},[932,936],{"type":26,"tag":88,"props":933,"children":934},{"style":112},[935],{"type":31,"value":876},{"type":26,"tag":88,"props":937,"children":938},{"style":112},[939],{"type":31,"value":499},{"type":26,"tag":88,"props":941,"children":942},{"class":90,"line":186},[943,948],{"type":26,"tag":88,"props":944,"children":945},{"style":112},[946],{"type":31,"value":947},"      -DOPENCV_ENABLE_NONFREE=ON",{"type":26,"tag":88,"props":949,"children":950},{"style":112},[951],{"type":31,"value":499},{"type":26,"tag":88,"props":953,"children":955},{"class":90,"line":954},4,[956,961],{"type":26,"tag":88,"props":957,"children":958},{"style":112},[959],{"type":31,"value":960},"      -DOPENCV_EXTRA_MODULES_PATH=..\u002F..\u002Fopencv_contrib\u002Fmodules",{"type":26,"tag":88,"props":962,"children":963},{"style":112},[964],{"type":31,"value":499},{"type":26,"tag":88,"props":966,"children":968},{"class":90,"line":967},5,[969],{"type":26,"tag":88,"props":970,"children":971},{"style":101},[972],{"type":31,"value":888},{"type":26,"tag":27,"props":974,"children":975},{},[976],{"type":31,"value":977},"NVidia GPU를 활용하려면 위 명령에 CUDA 관련 옵션을 추가한다.",{"type":26,"tag":78,"props":979,"children":981},{"className":80,"code":980,"language":82,"meta":7,"style":7},"cmake -DCMAKE_BUILD_TYPE=RELEASE \\\n      -DCMAKE_INSTALL_PREFIX=\u002Fusr\u002Flocal \\\n      -DOPENCV_ENABLE_NONFREE=ON \\\n      -DOPENCV_EXTRA_MODULES_PATH=..\u002F..\u002Fopencv_contrib\u002Fmodules \\\n      -DWITH_CUDA=ON \\\n      -DENABLE_FAST_MATH=ON \\\n      -DCUDA_FAST_MATH=ON \\\n      -DWITH_CUBLAS=ON \\\n      ..\n",[982],{"type":26,"tag":34,"props":983,"children":984},{"__ignoreMap":7},[985,1000,1011,1022,1033,1045,1058,1071,1084],{"type":26,"tag":88,"props":986,"children":987},{"class":90,"line":91},[988,992,996],{"type":26,"tag":88,"props":989,"children":990},{"style":95},[991],{"type":31,"value":859},{"type":26,"tag":88,"props":993,"children":994},{"style":112},[995],{"type":31,"value":864},{"type":26,"tag":88,"props":997,"children":998},{"style":112},[999],{"type":31,"value":499},{"type":26,"tag":88,"props":1001,"children":1002},{"class":90,"line":169},[1003,1007],{"type":26,"tag":88,"props":1004,"children":1005},{"style":112},[1006],{"type":31,"value":876},{"type":26,"tag":88,"props":1008,"children":1009},{"style":112},[1010],{"type":31,"value":499},{"type":26,"tag":88,"props":1012,"children":1013},{"class":90,"line":186},[1014,1018],{"type":26,"tag":88,"props":1015,"children":1016},{"style":112},[1017],{"type":31,"value":947},{"type":26,"tag":88,"props":1019,"children":1020},{"style":112},[1021],{"type":31,"value":499},{"type":26,"tag":88,"props":1023,"children":1024},{"class":90,"line":954},[1025,1029],{"type":26,"tag":88,"props":1026,"children":1027},{"style":112},[1028],{"type":31,"value":960},{"type":26,"tag":88,"props":1030,"children":1031},{"style":112},[1032],{"type":31,"value":499},{"type":26,"tag":88,"props":1034,"children":1035},{"class":90,"line":967},[1036,1041],{"type":26,"tag":88,"props":1037,"children":1038},{"style":112},[1039],{"type":31,"value":1040},"      -DWITH_CUDA=ON",{"type":26,"tag":88,"props":1042,"children":1043},{"style":112},[1044],{"type":31,"value":499},{"type":26,"tag":88,"props":1046,"children":1048},{"class":90,"line":1047},6,[1049,1054],{"type":26,"tag":88,"props":1050,"children":1051},{"style":112},[1052],{"type":31,"value":1053},"      -DENABLE_FAST_MATH=ON",{"type":26,"tag":88,"props":1055,"children":1056},{"style":112},[1057],{"type":31,"value":499},{"type":26,"tag":88,"props":1059,"children":1061},{"class":90,"line":1060},7,[1062,1067],{"type":26,"tag":88,"props":1063,"children":1064},{"style":112},[1065],{"type":31,"value":1066},"      -DCUDA_FAST_MATH=ON",{"type":26,"tag":88,"props":1068,"children":1069},{"style":112},[1070],{"type":31,"value":499},{"type":26,"tag":88,"props":1072,"children":1074},{"class":90,"line":1073},8,[1075,1080],{"type":26,"tag":88,"props":1076,"children":1077},{"style":112},[1078],{"type":31,"value":1079},"      -DWITH_CUBLAS=ON",{"type":26,"tag":88,"props":1081,"children":1082},{"style":112},[1083],{"type":31,"value":499},{"type":26,"tag":88,"props":1085,"children":1087},{"class":90,"line":1086},9,[1088],{"type":26,"tag":88,"props":1089,"children":1090},{"style":101},[1091],{"type":31,"value":888},{"type":26,"tag":27,"props":1093,"children":1094},{},[1095,1101],{"type":26,"tag":34,"props":1096,"children":1098},{"className":1097},[],[1099],{"type":31,"value":1100},"ccmake",{"type":31,"value":1102},"를 사용하면 사용 가능한 옵션을 대화형으로 탐색할 수 있다. 단, 모든 옵션이 표시되는 것은 아니므로 필요한 옵션은 cmake 명령에 직접 지정해야 한다.",{"type":26,"tag":78,"props":1104,"children":1106},{"className":80,"code":1105,"language":82,"meta":7,"style":7},"sudo apt-get install cmake-curses-gui\nccmake ..\n",[1107],{"type":26,"tag":34,"props":1108,"children":1109},{"__ignoreMap":7},[1110,1130],{"type":26,"tag":88,"props":1111,"children":1112},{"class":90,"line":91},[1113,1117,1121,1125],{"type":26,"tag":88,"props":1114,"children":1115},{"style":95},[1116],{"type":31,"value":98},{"type":26,"tag":88,"props":1118,"children":1119},{"style":101},[1120],{"type":31,"value":104},{"type":26,"tag":88,"props":1122,"children":1123},{"style":101},[1124],{"type":31,"value":109},{"type":26,"tag":88,"props":1126,"children":1127},{"style":101},[1128],{"type":31,"value":1129}," cmake-curses-gui\n",{"type":26,"tag":88,"props":1131,"children":1132},{"class":90,"line":169},[1133,1137],{"type":26,"tag":88,"props":1134,"children":1135},{"style":95},[1136],{"type":31,"value":1100},{"type":26,"tag":88,"props":1138,"children":1139},{"style":101},[1140],{"type":31,"value":1141}," ..\n",{"type":26,"tag":132,"props":1143,"children":1145},{"id":1144},"빌드-및-설치",[1146],{"type":31,"value":1147},"빌드 및 설치",{"type":26,"tag":27,"props":1149,"children":1150},{},[1151,1157],{"type":26,"tag":34,"props":1152,"children":1154},{"className":1153},[],[1155],{"type":31,"value":1156},"$(nproc)",{"type":31,"value":1158},"은 시스템의 CPU 코어 수를 자동으로 사용해 병렬 컴파일 속도를 높인다. 시스템 사양에 따라 수십 분이 소요된다.",{"type":26,"tag":78,"props":1160,"children":1162},{"className":80,"code":1161,"language":82,"meta":7,"style":7},"make -j$(nproc)\n",[1163],{"type":26,"tag":34,"props":1164,"children":1165},{"__ignoreMap":7},[1166],{"type":26,"tag":88,"props":1167,"children":1168},{"class":90,"line":91},[1169,1174,1179,1184],{"type":26,"tag":88,"props":1170,"children":1171},{"style":95},[1172],{"type":31,"value":1173},"make",{"type":26,"tag":88,"props":1175,"children":1176},{"style":112},[1177],{"type":31,"value":1178}," -j$(",{"type":26,"tag":88,"props":1180,"children":1181},{"style":95},[1182],{"type":31,"value":1183},"nproc",{"type":26,"tag":88,"props":1185,"children":1186},{"style":112},[1187],{"type":31,"value":1188},")\n",{"type":26,"tag":27,"props":1190,"children":1191},{},[1192,1194,1200],{"type":31,"value":1193},"빌드 완료 후 ",{"type":26,"tag":34,"props":1195,"children":1197},{"className":1196},[],[1198],{"type":31,"value":1199},"make test",{"type":31,"value":1201},"로 테스트를 실행할 수 있지만, OpenCV 전체 테스트 스위트는 1시간 이상 걸리므로 생략해도 무방하다.",{"type":26,"tag":27,"props":1203,"children":1204},{},[1205,1207,1212,1214,1220],{"type":31,"value":1206},"시스템 디렉토리에 설치하므로 ",{"type":26,"tag":34,"props":1208,"children":1210},{"className":1209},[],[1211],{"type":31,"value":98},{"type":31,"value":1213},"가 필요하다. 설치 후 ",{"type":26,"tag":34,"props":1215,"children":1217},{"className":1216},[],[1218],{"type":31,"value":1219},"ldconfig",{"type":31,"value":1221},"로 링커 캐시를 갱신한다.",{"type":26,"tag":78,"props":1223,"children":1225},{"className":80,"code":1224,"language":82,"meta":7,"style":7},"sudo make install\nsudo ldconfig\n",[1226],{"type":26,"tag":34,"props":1227,"children":1228},{"__ignoreMap":7},[1229,1246],{"type":26,"tag":88,"props":1230,"children":1231},{"class":90,"line":91},[1232,1236,1241],{"type":26,"tag":88,"props":1233,"children":1234},{"style":95},[1235],{"type":31,"value":98},{"type":26,"tag":88,"props":1237,"children":1238},{"style":101},[1239],{"type":31,"value":1240}," make",{"type":26,"tag":88,"props":1242,"children":1243},{"style":101},[1244],{"type":31,"value":1245}," install\n",{"type":26,"tag":88,"props":1247,"children":1248},{"class":90,"line":169},[1249,1253],{"type":26,"tag":88,"props":1250,"children":1251},{"style":95},[1252],{"type":31,"value":98},{"type":26,"tag":88,"props":1254,"children":1255},{"style":101},[1256],{"type":31,"value":1257}," ldconfig\n",{"type":26,"tag":132,"props":1259,"children":1261},{"id":1260},"설치-확인",[1262],{"type":31,"value":1263},"설치 확인",{"type":26,"tag":78,"props":1265,"children":1267},{"className":80,"code":1266,"language":82,"meta":7,"style":7},"pkg-config --modversion opencv\n",[1268],{"type":26,"tag":34,"props":1269,"children":1270},{"__ignoreMap":7},[1271],{"type":26,"tag":88,"props":1272,"children":1273},{"class":90,"line":91},[1274,1279,1284],{"type":26,"tag":88,"props":1275,"children":1276},{"style":95},[1277],{"type":31,"value":1278},"pkg-config",{"type":26,"tag":88,"props":1280,"children":1281},{"style":112},[1282],{"type":31,"value":1283}," --modversion",{"type":26,"tag":88,"props":1285,"children":1286},{"style":101},[1287],{"type":31,"value":707},{"type":26,"tag":27,"props":1289,"children":1290},{},[1291,1293,1299,1301,1306,1308,1314],{"type":31,"value":1292},"설치한 버전 번호(예: ",{"type":26,"tag":34,"props":1294,"children":1296},{"className":1295},[],[1297],{"type":31,"value":1298},"3.4.6",{"type":31,"value":1300},")가 출력되면 정상 설치된 것이다. OpenCV 4.x를 설치한 경우에는 ",{"type":26,"tag":34,"props":1302,"children":1304},{"className":1303},[],[1305],{"type":31,"value":16},{"type":31,"value":1307}," 대신 ",{"type":26,"tag":34,"props":1309,"children":1311},{"className":1310},[],[1312],{"type":31,"value":1313},"opencv4",{"type":31,"value":1315},"로 확인한다.",{"type":26,"tag":1317,"props":1318,"children":1319},"style",{},[1320],{"type":31,"value":1321},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":169,"depth":169,"links":1323},[1324,1327,1333],{"id":68,"depth":169,"text":71,"children":1325},[1326],{"id":134,"depth":186,"text":137},{"id":390,"depth":169,"text":393,"children":1328},[1329,1330,1331,1332],{"id":401,"depth":186,"text":404},{"id":449,"depth":186,"text":452},{"id":520,"depth":186,"text":523},{"id":564,"depth":186,"text":567},{"id":634,"depth":169,"text":637,"children":1334},[1335,1336,1337,1338],{"id":640,"depth":186,"text":640},{"id":780,"depth":186,"text":783},{"id":1144,"depth":186,"text":1147},{"id":1260,"depth":186,"text":1263},"markdown","content:posts:ubuntu-opencv-install.md","content","posts\u002Fubuntu-opencv-install.md","posts\u002Fubuntu-opencv-install","md",[1346,1350],{"_path":1347,"title":1348,"category":1349},"\u002Fposts\u002Fsanta-cruz-restaurants","산타크루즈 맛집 정리","reviews",null,1782525822194]