OpenCV GetCaptureProperty:未找到标识符?

时间:2012-12-18 10:02:26

标签: opencv

这是我的代码。它打开网络摄像头,抓取帧,缩小它们到一个较小的窗口,并尝试使用GetCaptureProperty获得帧速率。

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

#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 ==========

1 个答案:

答案 0 :(得分:1)

您正在使用OpenCV的C ++接口并调用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);