반응형

학교에서 프로젝트를 받아버려서.. 해야하는 상황..

내 프로젝트를 위해선 DLIB와 OPENCV가 필요한데..

정말 2~3일동안 수없이 도전해보다가 굉장히 간단한 방법을 찾아서 알려줄까함! (왜이리 dlib는 잘 안깔리는거야)

 

일단 설치 방법은 요약하면 VCPKG를 설치해서 DLIB와 OPENCV를 설치하면 된다!

이미 VCPKG가 깔려있다면 2번으로 넘어가주세요.

1. VCPKG 설치하기

설치는 아래 링크로 들어가서 보시면 되겠습니다~~

https://cheongpark.tistory.com/15

 

윈도우에서 VCPKG 설치하기

VCPKG는 대충 C++ 그런거의 패키지를 자동으로 설치해주는? 느낌인 것 같다.. 자동화로 설치해줘서 짜증나는 오류들을 경험하지 않고 빠르게 설치해주는 엄청난 놈인 것 같다! VCPKG 설치하기 https://

cheongpark.tistory.com

 

2. dlib와 opencv 설치

vcpkg install dlib:x64-windows
vcpkg install opencv:x64-windows

위 명령어를 커맨드 창에 입력해주세요!

만약 vcpkg가 없는 명령어로 뜨면 환경 변수 설정이 안되거나 환경 변수 경로를 잘 못 지정했을 겁니다!

x64-windows는 vcpkg 패키지 리스트에서 보고 자기꺼에 맞는 걸로 선택하시면 됩니다!

 

이렇게 하면 모든 것이 설치 완료!!

이제 Visual Studio에서 include에서 사용하시면 됩니다!

// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*

    This is an example illustrating the use of the perspective_window tool
    in the dlib C++ Library.  It is a simple tool for displaying 3D point 
    clouds on the screen.

*/

#include <dlib/gui_widgets.h>
#include <dlib/image_transforms.h>
#include <cmath>

using namespace dlib;
using namespace std;

// ----------------------------------------------------------------------------------------

int main()
{
    // Let's make a point cloud that looks like a 3D spiral.
    std::vector<perspective_window::overlay_dot> points;
    dlib::rand rnd;
    for (double i = 0; i < 20; i+=0.001)
    {
        // Get a point on a spiral
        dlib::vector<double> val(sin(i),cos(i),i/4);

        // Now add some random noise to it
        dlib::vector<double> temp(rnd.get_random_gaussian(),
                                  rnd.get_random_gaussian(),
                                  rnd.get_random_gaussian());
        val += temp/20;

        // Pick a color based on how far we are along the spiral
        rgb_pixel color = colormap_jet(i,0,20);

        // And add the point to the list of points we will display
        points.push_back(perspective_window::overlay_dot(val, color));
    }

    // Now finally display the point cloud.
    perspective_window win;
    win.set_title("perspective_window 3D point cloud");
    win.add_overlay(points);
    win.wait_until_closed();
}

//  ----------------------------------------------------------------------------

위 소스는 dlib.net의 기본 예제입니다.

위 소스를 Visual Studio에서 빈 프로젝트로 하나 만들고 소스 파일에서 test.cpp 하나 만들고 위 코드를 입력해서 실행해보시면 아주 잘 되는 것을 알 수 있습니다!

이런식으로 창이 나오면 잘 작동한다는 것이죠!

마우스로 회전도 되더라구요.. (그래프로 만들면 재밌겠다)

 

뭐 어쨌든 이 방식으로 설치했다면 빌드 폴더에 dll 파일도 나오는 경우가 있는데 이걸 같이 이동 시켜줘야지 다른 컴퓨터에서도 정상적으로 작동할 겁니다! (아무것도 설치 안되어있어도 잘 작동하더라구요.. 뭐 다른 한개는 설치해줘야 하긴 하는데..)

 

찾아보니 x64-windows-static 버전은 exe에다가 dll 파일 연결 안하고 모조리 다 때려 넣는 것 같군요! 하지만 설정은 더 힘드니 저 혼자만 하도록 하죠!

 

다만 맥이나 리눅스에서는 안될지도?

 

어쨌든 이만 끝!

VCPKG는 진짜 엄청나다..!

 

반응형

+ Recent posts