Post List

레이블이 OpenCV인 게시물을 표시합니다. 모든 게시물 표시
레이블이 OpenCV인 게시물을 표시합니다. 모든 게시물 표시

2014년 12월 28일 일요일

[OpenCV] 2.4.6 동영상 재생

#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;

int main()
{
        Mat frame;
        string path = "D:\\outputVideo\\outputVideo.avi";
        VideoCapture capture(path);
        namedWindow("my_window");

        for (;;) {
               capture >> frame;
               imshow("my_window", frame);

               if (cv::waitKey(30) >= 0) break;
        }

}

[OpenCV] 2.4.3 Video Capture Console using VS 2010 C++

아래 동영상은 OpenCV 2.4.3 을 설치한 VS 2010에서 WebCam 영상을 화면에 출력하는 예제이다.

OpenCV 2.4.6 을 VS 2008에 설치하여서 똑같이 진행해 보았는데, 정상적으로 WebCam 영상이 출력되었다.

보통 검색하면 나오는 OpenCV Video Capture 예제의 경우 OpenCV 1.0으로 된 경우가 많은데, 요즘 노트PC에 내장된 WebCam의 경우 OpenCV 2.1 이상에서만  잘 된다고 한다.


#include <opencv\cv.h>
#include <opencv\highgui.h>
using namespace cv;
int main()
{
        //create an image to store the video screen grab
        Mat image;
        //setup the video capture method using the default camera
        VideoCapture cap;
        cap.open(0);
        //create the window that will show the video feed
        namedWindow("VideoCaptureTutorial", 1);
        //create a loop to update the image with video camera image capture
        while (1)
        {
               //grad a frame from the video camers
               cap >> image;
              //show the image on the screen
               imshow("VideoCaptureTutorial", image);
               //create a 33ms delay
               waitKey(33);
        }
        return 0;
}

원문 : http://mymobilerobots.com/myblog/academic/tutorial-opencv-2-4-3-video-capture-console-using-vs-2010-c/

[OpenCV] 2.4.6 Setup Guide for MS Visual Studio with C++

해당 동영상은 2.4.3 버전을 Visual Studio 2010에 설치하는 영상이다.



OpenCV 는 아래 사이트에서 다운로드가 가능하다.
http://opencv.org/downloads.html

2.4.6 버전을 Visual Studio 2008에 설정을 해 보았는데, 동영상과 똑같이 하면 되었다.

Step 1. 환경변수로 OPENCV_DIR 에 OpenCV가 설치된 Directory의 build Folder 로 설정한다.

ex ) D:\03.Source Code\OpenCV\build

Step 2. 환경변수 Path의 마지막에 %OPENCV_DIR%\x86\vc9\bin 을 추가한다. (Visual Studio 2010, 2012의 경우는 각각 vc10, vc11 이며, 64bit 실행파일의 경우 x64 Folder 이다.)

Step 3. Debug settings : [C/C++ | General | Additional Include Directories]
           : $(OPENCV_DIR)\include 추가

Step 4. Debug settings : [Linker | General | Additional Library Directories]
           : $(OPENCV_DIR)\x86\vc9\lib 추가

Step 5. Debug settings : [Linker | Input | Additional Dependencies] 에 아래 lib File들 추가

opencv_core246d.lib
opencv_imgproc246d.lib
opencv_highgui246d.lib
opencv_ml246d.lib
opencv_video246d.lib
opencv_features2d246d.lib
opencv_calib3d246d.lib
opencv_objdetect246d.lib
opencv_contrib246d.lib
opencv_legacy246d.lib
opencv_flann246d.lib

Step 6. step 3, 4 를 Release Mode 에 추가

Step 7. Release settings : [Linker | Input | Additional Dependencies] 에 아래 lib 파일들 추가 (Debug Mode DLL 파일에 마지막 d만 삭제)

opencv_core246.lib
opencv_imgproc246.lib
opencv_highgui246.lib
opencv_ml246.lib
opencv_video246.lib
opencv_features2d246.lib
opencv_calib3d246.lib
opencv_objdetect246.lib
opencv_contrib246.lib
opencv_legacy246.lib
opencv_flann246.lib

동영상에 나오듯 property 파일을 추가하여 진행을 하였으며, 해당 property 파일을 첨부하였다.

OPENCV_DEBUG.vsprops

OPENCV_RELEASE.vsprops

원문 : http://mymobilerobots.com/myblog/academic/tutorial-opencv-2-4-3-setup-guide-for-ms-visual-studio-2010-with-c/