在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
呢? 最佳答案
我认为您不能将frame
用作setInput
的参数,并且不需要初始化OutputArray frame
。
checkout this example:
FrameSource是这样创建的:
121. frameSource = createFrameSource_Video(inputVideoName);
然后使用outputArray框架,如下所示:
142. Mat result; // no intialization, just declaration
144. MEASURE_TIME(superRes->nextFrame(result));
关于c++ - OpenCV SuperResolution OutputArray框架,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33615650/