OpenCV SuperResolution OutputArray帧

时间:2015-11-09 18:22:41

标签: c++ opencv image-processing machine-learning opencv3.0

SuperResolution的文档中
输出nextframe所需的代码是:
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方法的参数,但是如何初始化生成输出所需的propertyToInitialize

1 个答案:

答案 0 :(得分:3)

我认为您无法使用frame作为setInput的参数,并且您不需要将OutputArray frame初始化。

检查this example

FrameSource的创建方式如下:

   121. frameSource = createFrameSource_Video(inputVideoName);

然后使用outputArray框架:

   142. Mat result; // no intialization, just declaration
   144. MEASURE_TIME(superRes->nextFrame(result));