1

这是我的代码。它打开网络摄像头,抓取帧,将它们缩小到较小的窗口,并尝试使用 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 ==========
4

1 回答 1

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);
于 2012-12-18T11:53:03.003 回答