Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to rotate image in my camera's video?

My camera video has its frame upside down. How can i rotate all frame of my video? thank you.

How to rotate image in my camera's video?

I want to capture video frm my camera and rotate it at the same times and i've writing the program. But it has 1 error My written program is as below:

include "opencv2/opencv.hpp"

include "iostream"

include "opencv2/imgproc/imgproc.hpp"

using namespace cv; using namespace std;

int main(int argc, char* argv) { VideoCapture camera(0);

if (!camera.isOpened())
    return -1;
int iAngle = 180;
const char* OriginalWindowName = "Original Video";
namedWindow(OriginalWindowName,1 );
const char* RotatingWindowName = "Rotated Video";
namedWindow(RotatingWindowName, 1);
createTrackbar("Angle", RotatingWindowName, &iAngle, 360);

while (1) { Mat3b frame; camera >> frame; imshow("video", frame); if (waitKey(30) == 's') { break; } Mat matOriginalFrame; bool bSuccess = cap.read(matOriginalFrame); if (!bSuccess) { cout << "Cannot read the frame from video has its frame upside down. file" << endl; break;

    }
    imshow(OriginalWindowName, matOriginalFrame);
    Mat matRotation = getRotationMatrix2D(Point(matOriginalFrame.cols / 2, matOriginalFrame.rows / 2), (iAngle - 180), 1);
    Mat matRotatedFrame;
    warpAffine(matOriginalFrame, matRotatedFrame, matRotation, matOriginalFrame.size());
    imshow(RotatingWindowName, matRotatedFrame);
    if (waitKey(30) == 27)
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }

}

return 0; }

The error is at the line bool bSuccess = cap.read(matOriginalFrame); it said The identifier "cap" is not defined How can i rotate all frame of my video? fix this problem? thank you.you

click to hide/show revision 3
None

updated 2019-10-25 00:56:42 -0600

berak gravatar image

How to rotate image in my camera's video?

I want to capture video frm my camera and rotate it at the same times and i've writing the program. But it has 1 error My written program is as below:

include "opencv2/opencv.hpp"

include "iostream"

include "opencv2/imgproc/imgproc.hpp"

#include "opencv2/opencv.hpp"
#include "iostream"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;

std; int main(int argc, char* argv) { VideoCapture camera(0);

camera(0);

    if (!camera.isOpened())
     return -1;
 int iAngle = 180;
 const char* OriginalWindowName = "Original Video";
 namedWindow(OriginalWindowName,1 );
 const char* RotatingWindowName = "Rotated Video";
 namedWindow(RotatingWindowName, 1);
 createTrackbar("Angle", RotatingWindowName, &iAngle, 360);

while (1) { Mat3b frame; camera >> frame; imshow("video", frame); if (waitKey(30) == 's') { break; } Mat matOriginalFrame; bool bSuccess = cap.read(matOriginalFrame); if (!bSuccess) { cout << "Cannot read the frame from video file" << endl; break;

break;

        }
     imshow(OriginalWindowName, matOriginalFrame);
     Mat matRotation = getRotationMatrix2D(Point(matOriginalFrame.cols / 2, matOriginalFrame.rows / 2), (iAngle - 180), 1);
     Mat matRotatedFrame;
     warpAffine(matOriginalFrame, matRotatedFrame, matRotation, matOriginalFrame.size());
     imshow(RotatingWindowName, matRotatedFrame);
     if (waitKey(30) == 27)
     {
         cout << "esc key is pressed by user" << endl;
         break;
     }

    }
  return 0;
}

return 0; }

The error is at the line bool bSuccess = cap.read(matOriginalFrame); it said The identifier "cap" is not defined How can i fix this problem? thank you