2013-02-08 4 views
3

두 대의 opencv 카메라에 대한 래퍼를 작성하려고하는데 오류가 발생합니다 : ‘VideoCapture’ in namespace ‘cv’ does not name a type. 헤더 파일에 cv::VideoCapture leftcv::VideoCapture right을 올바르게 선언하지 않았기 때문에 그럴 것이라고 생각합니다.헤더 파일의 변수 선언하기

stereo.h :

#ifndef _GUARD_STEREO_GUARD_ 
#define _GUARD_STEREO_GUARD_ 

#include "cv.h" 

class Stereo { 

public: 
Stereo(int, int); 
cv::Mat getLeft(); 
cv::Mat getRight(); 

private: 
cv::VideoCapture left; 
cv::VideoCapture right; 

}; 

#endif 

Stereo.cpp :

cv::VideoCapture capLeft; // open the Left camera 
cv::VideoCapture capRight; // open the Right camera 

capLeft = cv::VideoCapture(0); 
capRight = cv::VideoCapture(1); 
+0

'VideoCapture'의 정의를 볼 수 있습니까? – 0x499602D2

+0

@David : OpenCV로 정의됩니다. 질문에 (성공한) 예제 사용법을 추가했습니다. – alexdavey

+0

올바른 .h 또는 .cpp 파일을 포함했는지 확인 했습니까? – 0x499602D2

답변

2

OpenCV 문서에서, 당신은 포함해야합니다

#include "cv.h" 
#include <iostream> 

#include "stereo.h" 

using namespace cv; 

Stereo::Stereo(int leftId, int rightId) { 
    left = VideoCapture(leftId); 
    right = VideoCapture(rightId); 

    if (!left.opened() || !right.opened()) { 
      std::cerr << "Could not open camera!" << std::endl; 
    } 
} 

Mat Stereo::getLeft() { 
    Mat frame; 
    left >> frame; 
    return frame; 
} 

Mat Stereo::getRight() { 
    Mat frame; 
    right >> frame; 
    return frame; 
} 

그러나 나는 성공적으로 VideoCapture like this 사용할 수 있습니다 highgui.h

#include "cv.h" 
#include "highgui.h" 
+0

그건 내 바보 같았 어 ... 고마워. – alexdavey