0

I build OpenCV 3.4 with Gstreamer MSVC 1.16.1, using Cmake and Visual Studio 10. I have include bin directory to the system path variable, added all additional include and library to Visual Studio. Now when I am trying to read an Image to test if OpenCV is correctly installed it throws an error as: OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file .../opencv/modules/highgui/src/window.cpp The code was:

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;

Now I tried to play a video using demo code from openCV site:

// 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;
}

The program is building correctly but I am getting following error while running it:

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

Where can be the error as they both are simplest OpenCV program.

A.k.
  • 192
  • 1
  • 22
  • Its about reading image. Did you try the solutions in [here](https://stackoverflow.com/questions/21773850/error-opening-file-home-vaibhav-opencv-modules-highgui-src-cap-ffmpeg-impl-hpp) – Yunus Temurlenk Mar 07 '20 at 08:22

1 Answers1

0

So the error was, there was an invisible character ('\u202A') present just after " of the filename. Once I deleted it, everything runs fine. I found this from the warning C4566: character represented by universal-character-name '\u202A' cannot be represented in the current code page (1252)

A.k.
  • 192
  • 1
  • 22