2012-12-18 87 views
1

这是我的代码。它打开摄像头,抓取帧,将它们缩小到更小的窗口,并尝试使用GetCaptureProperty获取帧速率。OpenCV GetCaptureProperty:标识符未找到?

它找不到GetCaptureProperty函数,我也不能(我点击Opencv模块文件夹中的每个文件夹)。有任何想法吗?

#include "stdafx.h" 
#include "opencv2/imgproc/imgproc.hpp" 
#include "opencv2/highgui/highgui.hpp" 
#include <stdlib.h> 
#include <stdio.h> 
#include <iostream> 
#include <Windows.h> 
#include <time.h> 

using namespace std; 
using namespace cv; 

Mat output; 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    VideoCapture cap(0); // open the default camera 
    if(!cap.isOpened()) { // check if we succeeded 
     cout << "NO camera found \n"; 
     return -1; 
    } 

    Mat src,smallsrc; 

    cap >> src; //grab 1 frame 
    output.create(src.rows,src.cols,CV_8UC3); //create empty 3 channel frame 
    namedWindow("source", CV_WINDOW_AUTOSIZE); 
    moveWindow("source",2000,100); //create a small original capture off to the side of screen 

    for(;;) 
    { 
     if(GetAsyncKeyState(27)) cin.get() ; //if esc is pressed, pause execution till ENTER is pressed 
     /// Load an image 
     cap >> src; 

     if(!src.data) 
     { return -1; } 

     resize(src,smallsrc,Size(),.5,.5); //smaller scale window of original 
     imshow("source",smallsrc); 

    int msc = cvGetCaptureProperty(smallsrc,CV_CAP_PROP_POS_MSEC); 
    int frmrate = GetCaptureProperty(smallsrc,CV_CAP_PROP_FPS); 
    int frmcount = getCaptureProperty(smallsrc,CV_CAP_PROP_POS_FRAMES); 

     waitKey(30); 
    } 
    return 0; 
} 

和这里的错误:

1>------ Build started: Project: getcaptureproperty, Configuration: Debug x64 ------ 
1> getcaptureproperty.cpp 
1>getcaptureproperty.cpp(34): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data 
1>getcaptureproperty.cpp(46): error C2664: 'cvGetCaptureProperty' : cannot convert parameter 1 from 'cv::Mat' to 'CvCapture *' 
1>   No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 
1>getcaptureproperty.cpp(47): error C3861: 'GetCaptureProperty': identifier not found 
1>getcaptureproperty.cpp(48): error C3861: 'getCaptureProperty': identifier not found 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 
+0

你找不到'GetCaptureProperty'因为没有此名称的OpenCV的功能。在C中有'cvGetCaptureProperty',在OpenCV的C++接口中'cv :: VideoCapture :: get'。 – sgarizvi

回答

1

您使用的是C++的OpenCV接口调用C函数来获取视频拍摄性能。你可以得到cv::VideoCapture对象的属性如下:

int msc = cap.get(CV_CAP_PROP_POS_MSEC); 
int frmrate = cap.get(CV_CAP_PROP_FPS); 
int frmcount = cap.get(CV_CAP_PROP_POS_FRAMES);