Now you can Subscribe using RSS

Submit your Email

Wednesday

How to set Camera Resolution in Android with OpenCV

Vishal Shrestha
This post follows from the previous post on Creating a class that extends JavaCameraView. We can use this class to set up focus modes, flash and resolution using openCV for Android.

Changing camera resolution using openCV Android
OpenCV for Android

It's pretty simple to find out supported resolutions and set resolution in Android Camera using OpenCV. Just include these methods in the class that we created in the previous post and use it as you want.

Changing camera resolution using openCV Android
Resolution List using OpenCV
public List<Camera.Size> getResolutionList() {
        return mCamera.getParameters().getSupportedPreviewSizes();
 }

 public void setResolution(Camera.Size resolution) {
        disconnectCamera();
        connectCamera((int) resolution.width, (int) resolution.height);
 }

public Camera.Size getResolution() {
        Camera.Parameters params = mCamera.getParameters();
        Camera.Size s = params.getPreviewSize();
        return s;
 }


It's pretty simple as you can see. You can use the supported resolution that you get from getResolutionList any way you want. Try it out and do let me know if there are any problems or comment below your queries! Cheers.
Check out how to set Camera Flash in OpenCv for Android in the next post, coming soon.

Vishal Shrestha / Author & Founder

A developer by profession, a born Adventurer. I mainly do Android but like to get my hands dirty with web development and a little bit of Python. I would't rather go on a Trek than a party and you can find me having a few rounds with the heavy bag to let out the steam ;)

For Business info : My Portfolio Site.

0 comments:

Post a Comment

Coprights @ 2017 | The Code City by Vishal Shrestha Vishal Shrestha