我用 Gstreamer MSVC 1.16.1 构建 opencv 3.4,现在 imread 和 VideoCapture 不工作

I build opencv 3.4 with Gstreamer MSVC 1.16.1, and now imread and VideoCapture not working

我使用 Cmake 和 Visual Studio10 使用 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 程序。

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

中找到了这个