2

I was following the example given in the OpenCV for video displaying, just took out some transformations unnecessary for me. The code I have right now loads the video file and then displays it, the problem is that reproduced video have wrong colours.

Here's the code:

using namespace std;
using namespace cv;

// The main function

int main (int argc, char *argv[])
{

VideoCapture cap ("ETMI 002.mpg");  // Open the file

if (!cap.isOpened ())               // Check if opening was successful
    cerr << "I have failed!" << endl;

else
{
    Mat edges;
    Mat frame;
    namedWindow("edges",1);
    while (cap.read (frame))
    {
      cvtColor(frame, edges, CV_BGR2RGB);  
      imshow("edges", edges);
      if(waitKey(30) >= 0) break;
    }
}

return 0;

}

4

1 に答える 1

0

再生されたビデオの変換を回避するには、
imshow("edges", edges)
imshow("edges", frame)に変更します

while (cap.read (frame))
{
  cvtColor(frame, edges, CV_BGR2RGB); 

  // here is the change you are showing the converted image 
  // just simply add the original read frame

  imshow("edges", frame);   // here 
  if(waitKey(30) >= 0) break;
}
于 2012-06-27T11:29:50.743 に答える