【问题标题】:I build opencv 3.4 with Gstreamer MSVC 1.16.1, and now imread and VideoCapture not working我用 Gstreamer MSVC 1.16.1 构建 opencv 3.4,现在 imread 和 VideoCapture 不起作用
【发布时间】:2020-06-19 19:45:54
【问题描述】:

我使用 Cmake 和 Visual Studio 10 使用 Gstreamer MSVC 1.16.1 构建 OpenCV 3.4。 我已将 bin 目录包含到系统路径变量中,将所有其他包含和库添加到 Visual Studio。 现在,当我尝试读取图像以测试 OpenCV 是否正确安装时,它会引发错误: OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file .../opencv/modules/highgui/src/window.cpp 代码是:

Mat image1;
image1 = imread("‪D:\\Capture2.JPG");
if(! image1.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
    }
imshow("Image",image1);
cvWaitKey(0);
return 0;

现在我尝试使用来自 openCV 站点的演示代码播放视频:

// opencv_3.4_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
     // Create a VideoCapture object and open the input file
  // If the input is the web camera, pass 0 instead of the video file name
  VideoCapture cap("‪Wildlife.mp4"); 

  // Check if camera opened successfully
  if(!cap.isOpened()){
    cout << "Error opening video stream or file" << endl;
    return -1;
  }

  while(1){

    Mat frame;
    // Capture frame-by-frame
    cap >> frame;

    // If the frame is empty, break immediately
    if (frame.empty())
      break;

    // Display the resulting frame
    imshow( "Frame", frame );

    // Press  ESC on keyboard to exit
    char c=(char)waitKey(25);
    if(c==27)
      break;
  }

  // When everything done, release the video capture object
  cap.release();

  // Closes all the frames
  destroyAllWindows();

  return 0;
}

程序正在正确构建,但运行时出现以下错误:

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808)
warning: ?Wildlife.mp4 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809)
GStreamer: error opening bin syntax error

错误在哪里,因为它们都是最简单的 OpenCV 程序。

【问题讨论】:

  • 它是关于阅读图像的。你试过here中的解决方案吗

标签: c++ opencv visual-studio-2010 ffmpeg gstreamer


【解决方案1】:

所以错误是,文件名的 " 之后出现了一个不可见字符 ('\u202A')。一旦我删除它,一切运行正常。 我从warning C4566: character represented by universal-character-name '\u202A' cannot be represented in the current code page (1252)找到这个

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-17
    • 2021-03-08
    • 2012-07-11
    • 2018-08-23
    • 2014-11-20
    • 2012-07-26
    相关资源
    最近更新 更多