【发布时间】:2016-02-10 11:37:03
【问题描述】:
在SuperResolution 的文档中
输出下一帧所需的代码是:
void superres::SuperResolution::nextFrame(OutputArray frame)
输入帧源必须设置为:
void superres::SuperResolution::setInput(const Ptr<FrameSource>& frameSource)
我有一个从视频中获取帧的代码:
#include "opencv2/opencv.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main(int, char**)
{
VideoCapture cap ( "video1.mp4" ); // open the default camera
if( ! cap.isOpened () ) // check if we succeeded
return -1;
/* Mat edges; */
namedWindow ( "Video" , 1 );
double frnb ( cap.get ( CV_CAP_PROP_FRAME_COUNT ) );
std::cout << "frame count = " << frnb << endl;
for(;;)
{
Mat frame;
double fIdx;
std::cout << "frame index ? ";
std::cin >> fIdx;
if ( fIdx < 0 || fIdx >= frnb ) break;
cap.set ( CV_CAP_PROP_POS_FRAMES , fIdx );
bool success = cap.read(frame);
if ( ! success )
{
cout << "Cannot read frame " << endl;
break;
}
/* cap >> frame; // get a new frame from camera */
imshow("Video", frame);
if ( waitKey (0) == 27 ) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
鉴于此,我可以使用frame 变量作为setInput 方法的参数,但是如何初始化生成输出所需的OutputArray frame?
【问题讨论】:
标签: c++ opencv image-processing machine-learning opencv3.0