Ask Your Question

Issue with Camera Orientation

asked 2016-08-19 05:25:59 -0500

Ale gravatar image

updated 2016-08-19 05:43:54 -0500

berak gravatar image


I'm new on OpenCV and I want to change the camera orientation from landscape to portrait. I found some solutions that involve pixel manipulation in onCameraFrame method (rotate and flip the mat), but all these decrease significantly the fps.

Is there a way to fix this bug remaining on 30fps?

edit retag flag offensive close merge delete


if resolution is not main concern u can resize the every frame to small and do rotate-flip then resize back the frame to its desired size..This rotate-flip on small image may saves time.we can use affine transform also for orientations

Venky009 gravatar imageVenky009 ( 2016-08-19 06:16:09 -0500 )edit

I think transpose and flip is quicker than the one affine transform you would need.

Tetragramm gravatar imageTetragramm ( 2016-08-19 07:41:37 -0500 )edit

If I use transpose and flip the fps decrease to 15, instead of 30, that is a significantly loss.

Ale gravatar imageAle ( 2016-08-19 07:56:11 -0500 )edit

Well, then stick with the affine transform. You should be able to do it in one transformation. I'll take a look at it over the weekend and find the fastest way and make a function for it. People need the 90 degree rotations way too often for it not to be built in.

Tetragramm gravatar imageTetragramm ( 2016-08-19 14:22:16 -0500 )edit

To be clear, that's the whole rotation and any flips you need, all as one transformation. Flips can be gotten by adding a negative to the appropriate parameters in the affine.

Tetragramm gravatar imageTetragramm ( 2016-08-19 14:23:00 -0500 )edit

Is it necessary to use opencv here .Because loading of mats ,,calling libs may slags the time.. cant we do these operations on frames without opencv..?

Venky009 gravatar imageVenky009 ( 2016-08-20 00:45:06 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-19 15:05:11 -0500

Tetragramm gravatar image

I did some testing, and the flips are significantly faster than the affine for my computer, and they use less CPU (only one thread) while running.

Here are the codes, not as a function, which I'll put together and submit later. Clockwise is positive.

Rotate 90 (2.66 seconds/1000 iterations for flip vs 5.59/1000 for affine)

 flip(input.t(), output, 1);

Rotate 180 (If the matrix is continuous, it may be better to do std::reverse, but I have yet to test this)

(1.18/1000 for flip, 2.53/1000 for affine)

flip(input, output, 1);
flip(output, output, 0);

Rotate 270 (2.19/1000 for flip, 5.90/1000 for affine)

flip(input.t(), output, 0);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-08-19 05:25:59 -0500

Seen: 480 times

Last updated: Aug 19 '16