My camera video has its frame upside down. How can i rotate all frame of my video? thank you.
1 | initial version |
My camera video has its frame upside down. How can i rotate all frame of my video? thank you.
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:
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
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
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