0

我在下面编写了以下代码以在 OpenCV 中显示视频。我已经很好地编译了它,但是当我运行它时,应该显示视频的窗口会打开,但它太小而无法实际查看视频是否正在播放。其他一切似乎都运行良好。宽度、高度和帧数按编码打印在命令行上。有谁知道问题是什么?一探究竟。

void info()
{
   cout << "This program will accept input video with fixed lengths and produce video textures" << endl;
}

int main(int argc, char *argv[])
{
  info();
  if(argc != 2)
  {
    cout << "Please enter more parameters" << endl;
    return -1;

  }

const string source = argv[1];

VideoCapture input_vid(source);
if(! input_vid.isOpened())
{
    cout << "Error: Could not find input video file" << source << endl;
    return -1;
}


Size S = Size((int) input_vid.get(CV_CAP_PROP_FRAME_WIDTH),    //Acquire size of input video
              (int) input_vid.get(CV_CAP_PROP_FRAME_HEIGHT));

cout << "Width: = " << S.width << " Height: = " << S.height << " Number of frames: " << input_vid.get(CV_CAP_PROP_FRAME_COUNT)<<endl;

const char* PLAY = "Video player";

namedWindow(PLAY, CV_WINDOW_AUTOSIZE);
//imshow(PLAY,100);
char c;
c = (char)cvWaitKey(27);
//if ( c == 27)break;
return 0;
}
4

2 回答 2

0

另一个简单的调整可能是使用 CV_WINDOW_NORMAL 而不是 CV_WINDOW_AUTOSIZE

namedWindow(PLAY, CV_WINDOW_AUTOSIZE);

它使您可以手动调整窗口大小

于 2013-02-17T18:17:28.083 回答
0

假设视频来自网络摄像头:

capture = CaptureFromCAM( 0 );
SetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT, 640);
SetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH, 480);

这将解决您的问题

于 2013-02-17T17:27:38.253 回答