이미 빌드되어있는 dll과 헤더들은 사용X - opengl 관련 함수들이 같이 컴파일되지 않은 상태라 사용불가, getBuildInformation() 으로 확인 가능


cmake를 통해 새로 빌드해주어야 한다.



cmake에서 configure하고 난 뒤 WITH_OPENGL 체크하고 다시 configure한 후에 generate한다.

생성된 ALL_BUILD를 통해 빌드하면 release/debug모드의 bin(.dll)/lib(.lib)을 얻을 수 있다.


바뀐 .dll을 등록하기 위해 이전에 등록해두었던 환경변수를 수정하고

사용하고 있던 프로젝트의 경로들도 수정해준다.



과정을 완료하면 위의 사진처럼 getBuildInformation() 함수를 통해 확인할 수 있다.


그 후 테스트해보면 opengl관련 함수들도 잘 작동된다!




참고 : http://cinaburo.tistory.com/1

VideoCapture를 이용해서 카메라 출력한 뒤 opengl 도형 띄우는 예제를 실행시켜봤는데 색이 이상하게 나온다

피부나 붉은 계통은 푸르게 나오고 푸른 계통은 붉게 나오는 것


Mat은 capture.read(frame); 할 시 BGR로 이미지를 read하나보다.

cvtColor(frame, frame, CV_BGR2RGB); 사용하니 색이 바르게 나온다.

http://jepsonsblog.blogspot.kr/2012/11/rotation-in-3d-using-opencvs.html


회전행렬 사용한 듯

1
2
3
4
5
Mat sticker;
sticker.create(height, width, CV_8UC4);
//캔버스 배경색 투명하게 만들기
//맨 끝의 0값 - alpha
sticker = Scalar(2552552550);
cs


Scalar를 이용해서 채널들의 값을 바꿔주면 된다

alpha값을 0으로!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
inline std::vector<image_window::overlay_line> render_face_detections (
        const std::vector<full_object_detection>& dets,
        const rgb_pixel color = rgb_pixel(0,255,0)
    )
    {
        std::vector<image_window::overlay_line> lines;
        for (unsigned long i = 0; i < dets.size(); ++i)
        {
            DLIB_CASSERT(dets[i].num_parts() == 68,
                "\t std::vector<image_window::overlay_line> render_face_detections()"
                << "\n\t Invalid inputs were given to this function. "
                << "\n\t dets["<<i<<"].num_parts():  " << dets[i].num_parts() 
            );
 
            const full_object_detection& d = dets[i];
            // Around Chin. Ear to Ear
            for (unsigned long i = 1; i <= 16++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
                
            // Line on top of nose
            for (unsigned long i = 28; i <= 30++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            
            // left eyebrow
            for (unsigned long i = 18; i <= 21++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            // Right eyebrow
            for (unsigned long i = 23; i <= 26++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            // Bottom part of the nose
            for (unsigned long i = 31; i <= 35++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            // Line from the nose to the bottom part above
            lines.push_back(image_window::overlay_line(d.part(30), d.part(35), color));
 
            // Left eye
            for (unsigned long i = 37; i <= 41++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            lines.push_back(image_window::overlay_line(d.part(36), d.part(41), color));
 
            // Right eye
            for (unsigned long i = 43; i <= 47++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            lines.push_back(image_window::overlay_line(d.part(42), d.part(47), color));
 
            // Lips outer part
            for (unsigned long i = 49; i <= 59++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            lines.push_back(image_window::overlay_line(d.part(48), d.part(59), color));
 
            // Lips inside part
            for (unsigned long i = 61; i <= 67++i)
                lines.push_back(image_window::overlay_line(d.part(i), d.part(i-1), color));
            lines.push_back(image_window::overlay_line(d.part(60), d.part(67), color));
        }
        return lines;
    }
cs



1~16 : 턱

18~21 : 왼쪽 눈썹

23~26 : 오른쪽 눈썹

28~30 : 콧대

31~35 : 콧망울

37~41 : 왼쪽 눈

43~47 : 오른쪽 눈

49~59 : 입술 바깥 라인

61~67 : 입술 안쪽 라인

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    //cam open
    cv::VideoCapture cap(0);
    if (!cap.isOpened()){
        MessageBox(_T("Cam is not open"));
        return;
    }
 
    //calculate fps values
    time_t start, end;
    double seconds;
    float dFps;
    int count = 0;
 
    //window create
    image_window win;
    //frame
    cv::Mat temp;
 
    //Start Time
    time(&start);
    // Grab and process frames until the main window is closed by the user.
    while (!win.is_closed()){
        // Grab a frame
        cap >> temp;
            
        //End Time
        time(&end);
        //frame plus
        count++;
 
        seconds = difftime(end, start);
        dFps = count / seconds;
 
        cv_image<bgr_pixel> cimg(temp);
 
        rectangle r;            
        //r.set_top(10);
        //r.set_bottom(10);
        //r.set_left(10);
        //r.set_right(10);
 
        stringstream ss;
        ss << "fps : " << dFps << endl;
        string str;
        str = ss.str();
 
        // Display it all on the screen
        win.clear_overlay();
        win.set_image(cimg);
        win.add_overlay(dlib::image_window::overlay_rect(r, rgb_pixel(25500), str));
    }
cs


fps를 출력하는 부분이 이상함(윈도우창 내부가 아니라 테두리에 걸쳐서 시작함)

추후에 수정!

http://www.learnopencv.com/speeding-up-dlib-facial-landmark-detector/

[작업환경]

DLIB버전 : DLIB 19.2 
VS 버전 : vs2015 Community
Debug ver./Release ver.

[DLIB 설치 방법]
1. DLIB 다운
최신 버전으로 다운로드(ver 19.2)

2. Cmake 컴파일
위의 포스트 참조하여 cmake로 컴파일

3. VS 2015 설정
1) 구성 속성 -> 링커 -> 일반 -> 추가 라이브러리 디렉터리
Debug : D:\Program Files (x86)\dlib-19.2(dilb 설치 경로)\build\dlib_build\Debug 추가
Release : D:\Program Files (x86)\dlib-19.2(dilb 설치 경로)\build\dlib_build\Release 추가

2) 구성 속성 -> 링커 -> 입력 -> 추가 종속성
dlib.lib 추가

3) 구성 속성 -> C/C++ -> 전처리기 -> 전처리기 정의
DLIB_JPEG_STATIC
DLIB_JPEG_SUPPORT
DLIB_PNG_STATIC
DLIB_PNG_SUPPORT
추가

4) 프로젝트 파일 소스코드 내부에 dlib 폴더 복사








[작업환경]
openCV버전 : openCV 3.0.0 
VS 버전 : vs2015 Community
Debug ver./Release ver. 

[openCV 설치 방법]
1. openCV 다운로드
3.0.0 버전으로 다운로드

2. 환경변수 설정
1) 시스템 변수 -> 새로 만들기
변수 이름 : OPENCV_3_0_0_BUILD
변수 값 : D:\Program Files (x86)\openCV_3.0.0 (CV 설치한 경로) \opencv\build 

<OPENCV_X86/OPENCV_X64가 있으면 > 

2)시스템 변수 ->  OPENCV_X86 

맨 뒤에  %OPENCV_3_0_0_BUILD%\x86\vc12\bin; 추가


3)시스템 변수 -> OPENCV_X64

맨 뒤에 %OPENCV_3_0_0_BUILD%\x64\vc12\bin; 추가

4) 시스템 변수 -> path

맨 뒤에 ;%OPENCV_X86%;%OPENCV_X64%; 추가


<OPENCV_X86/OPENCV_X64가 없으면> 

2) 시스템 변수 -> 새로 만들기

변수 명 : OPENCV_X86

변수 내용 : %OPENCV_3_0_0_BUILD%\x86\vc12\bin;


3) 시스템 변수 -> 새로 만들기

변수 명 : OPENCV_X64

변수 내용 : %OPENCV_3_0_0_BUILD%\x64\vc12\bin; 


4) 시스템 변수 -> path

맨 뒤에 ;%OPENCV_X86%;%OPENCV_X64%; 추가



5) 재부팅


3. VS 2015 설정 

1) 구성 속성 -> C/C++ -> 일반 -> 추가 포함 디렉터리

$(OPENCV_3_0_0_BUILD)\include


2) 링커 -> 일반 -> 추가 라이브러리 디렉터리

32bit : $(OPENCV_3_0_0_BUILD)\x86\vc12\lib

64bit : $(OPENCV_3_0_0_BUILD)\x64\vc12\lib


3) 링커 -> 입력 -> 추가 종속성

<Debug>

opencv_ts300d.lib

opencv_world300d.lib


<Release>

opencv_ts300.lib

opencv_world300.lib






1
2
3
4
5
6
7
8
9
10
for(int i=0;i<sketch.cols;i++){
        for(int j=0;j<sketch.rows;j++){
            if(blur.at<uchar>(j, i) == 255){
                result.at<uchar>(j, i) = sketch.at<uchar>(j, i);
            }
            else{
                result.at<uchar>(j, i) = min(255, (sketch.at<uchar>(j, i)<<8)/(255-blur.at<uchar>(j, i)));
            }
        }
    }
cs


위 코드처럼 color dodge 함수를 만들고 테스트해봤더니 계속 abort() has been called 오류가 났다.

처음에는 여러개의 Mat들이 얕은 복사로 연결되어 있어서 오류나는 줄 알았는데 아니었다.


결과물을 저장할 result가 초기화되지 않아 지정 위치의 픽셀에 접근할 수가 없었던 것

result를 초기화 시켜주고 픽셀에 접근하니 잘 됐다.

'이미지 프로세싱 > OPENCV' 카테고리의 다른 글

[3.0.0] Mat 배경 투명하게 만들기  (0) 2017.02.14
[3.0.0] VS2015/openCV3.0.0 개발환경 설정  (0) 2017.01.20
[2.4.10] jpeg 이미지 디코딩  (0) 2017.01.04
[2.4.10->3.0] Mat의 기초  (0) 2016.11.30
[2.4.10] cvType  (0) 2016.11.25

+ Recent posts