블로그 이미지
Kanais
Researcher & Developer 퍼즐을 완성하려면 퍼즐 조각들을 하나 둘씩 맞춰나가야 한다. 인생의 퍼즐 조각들을 하나 둘씩 맞춰나가다 보면 인생이란 퍼즐도 완성되는 날이 오려나...?

calendar

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

Notice

05-11 19:03

Recent Post

Recent Comment

Recent Trackback

Archive

2015. 4. 15. 17:30 Computer Vision/Face Detection



개발환경


사용툴       : Visual Studio 2013

라이브러리 : openCV library 2.4.10

프로젝트    : Visual C++ console application

개발날짜    : 2015-04-15


출처 및 참고 : MARE's Computer Vision Study




void FaceDetection::Usinggpu_FaceDetection(const char* filename)

{ 

        //load xml file 

        string trainface = "haarcascade_frontalface_alt.xml";

        //declaration 

        CascadeClassifier ada_cpu;

        gpu::CascadeClassifier_GPU ada_gpu;

        CvCapture* capture;

        capture = cvCaptureFromFile(filename);


        assert(capture != NULL);

 

        if (!(ada_cpu.load(trainface)))

        {

               printf(" cpu ada xml load fail! \n");

               return;

        }

        if (!(ada_gpu.load(trainface)))

        {

               printf(" gpu ada xml load fail! \n");

               return;

        }

        IplImage* bgr_frame;

 

        CvSize size = cvSize((int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH), 

                             (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT));

 

        cvNamedWindow("CV_Window", 0);

        cvResizeWindow("CV_Window", 2048, 1024);

 

        while ((bgr_frame = cvQueryFrame(capture)) != NULL)

        {

           Mat gray;

           Mat frame;

           frame = cvarrToMat(bgr_frame);

           cvtColor(frame, gray, CV_BGR2GRAY);

 

           equalizeHist(gray, gray);

 

           ////////////////////////////////////////////// 

           //cpu case face detection code 

           vector< Rect > faces;

           ada_cpu.detectMultiScale(gray, faces);

           if (faces.size() >= 1)

           {

               for (int ji = 0; ji < faces.size(); ++ji)

               {

                 rectangle(frame, faces[ji], CV_RGB(0, 0, 255), CV_FILLED, 4);

               }

           }

           ///////////////////////////////////////////// 

           //gpu case face detection code 

           

           gpu::GpuMat faceBuf_gpu;

           gpu::GpuMat GpuImg;

           GpuImg.upload(gray);

          int detectionNumber = ada_gpu.detectMultiScale(GpuImg, faceBuf_gpu);

           Mat faces_downloaded;

           if (detectionNumber >= 1)

           {

          faceBuf_gpu.colRange(0, detectionNumber).download(faces_downloaded);

           Rect* faces = faces_downloaded.ptr< Rect>();

 

           for (int ji = 0; ji < detectionNumber; ++ji)

           {

               rectangle(frame, Point(faces[ji].x, faces[ji].y), Point(faces[ji].x + faces[ji].width, 

                         faces[ji].y + faces[ji].height), CV_RGB(255, 0, 0), 2);

           }

        }

           ///////////////////////////////////////////////// 

           //result display

           imshow("CV_Window", frame);

           waitKey(1);

        }

        cvReleaseImage(&bgr_frame);

        //cvReleaseVideoWriter(&writer);

        cvReleaseCapture(&capture);

        cvDestroyWindow("CV_Window");

}



결과화면

얼굴인식 안된 부분은 개인 프라이버시를 위해 별도로 모자이크 처리함.



posted by Kanais
2015. 4. 15. 17:07 Computer Vision/OpenCV



개발환경


사용툴       : Visual Studio 2013

라이브러리 : openCV library 2.4.10

프로젝트    : Visual C++ console application

개발날짜    : 2015-04-15



출처 : 크프로그래머님의 티스토리



Adaboost fast detection 테스트 코드를 실행하던 중.. 뜬 에러.


무엇이 문제인가 찾아보다  다크프로그래머님의 티스토리 글에서 좋은 글을 발견!!




그러나...


CUDA를 지원하는 그래픽카드가 따로 있는 듯 하다..


현재 내 PC의 그래픽카드로는 사용하지 못하는 듯 싶다..


posted by Kanais
2015. 4. 15. 16:28 Programming/Error Clear!



개발환경


사용 툴   : Visual Studio 2013

개발 날짜 : 2015-04-15


참고 : David Kline 님의 MSDN Blog

       프라이데이님의 Naver Blog



열심히 디버깅 돌리던 중 언제나 그랬듯이 나를 받겨주는 오류 메시지.

exception이 error 보다는 반갑긴한데.. 그래도 찜찜한건 어쩔 수 없다.



뭐 계속해도 결과는 뜨지만...

그래도 exception은 잡을 수 있다면 잡는게 좋으니까..


first-chance exception 에 대한 설명은

kuaaan 님의 tistory에 잘 설명이 되어있으니.. 밑에 링크를 참고하면되겠다.

http://kuaaan.tistory.com/38


posted by Kanais