0

I have OpenCV project using C language. I wish to rotate the captured video from camera, how I can do that? What is the rotate function in OpenCV? My code as below

static CvCapture * cap;

cap = cvCaptureFromCAM(cam_index);

Flip(cap, 0);

But it got error. How I can rotate my video? Please help

Bubble Bub
  • 651
  • 4
  • 12
  • 32

1 Answers1

0

You would rotate the video frame by frame. First, using getRotationMatrix2D() you get the rotation matrix, then using warpAffine() rotate each frame.

Mat image = imread("test.jpg");
Mat rot = getRotationMatrix2D(Point2f(image.cols/2.0, image.rows/2.0), angle, 1.0);
Mat rotated;
warpAffine(image, rotated, rot, image.size());
fireant
  • 14,080
  • 4
  • 39
  • 48