Ask Your Question
0

Fail to set camera resolution higher then 640x480 using Tutorial 5

asked 2013-02-09 13:08:08 -0600

umyangxd gravatar image

updated 2013-02-09 13:12:06 -0600

Hi, I am new to Opencv and Android, and I am learning the samples provided by the opencv4android sdk. I have a question regarding the Tutorial 5.

The program shows a menu of a list of the resolutions supported by the cameras of my Acer Iconia A100 (up to 1280x720). However, I am not able to use any resolution that is higher than 640x480. Whenever, I set a resolution that is higher than 640x480, the program ignores it, and use only 640x480 to capture the image frames. Downwards works fine, meaning that I can change to any resolutions lower than 640x480.

I have tried the same Tutorial 5 on my Galaxy Nexus, and found the same problem. The only difference is now the program does not allow me to use resolutions higher than 960x620. According to the menu, the cameras on Galaxy Nexus support way higher resolutions.

Thanks for your help!

-umyangxd

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
4

answered 2013-02-10 12:14:14 -0600

Tutorial-5 sets camera resolution if it fits to screen. In case, when resolution is higher then View size it fails back to the maximum possible resolution. It is default Android camera behavior.

edit flag offensive delete link more

Comments

Thanks for the answer! Is there anyway to get around this? I need to capture and process higher resolution video frames in the background, meaning that I do not need to display them on the screen. I tried to hide JavaCameraView by using android:visibility="invisible" but the sdk stops streaming the frames.

Any suggestions on what I should do? I really appreciate your help.

Thanks!

umyangxd gravatar imageumyangxd ( 2013-02-10 12:44:56 -0600 )edit
3

answered 2013-02-10 23:54:03 -0600

Iwas wrong in previous answer. Resolution selection is a part of OpenCV4Android SDK logic. I review Android SDK source code and find issue. In current implementation of JavaCameraView and NativeCameraView resolution is always constrained by View size. I prepare pull request to fix the issue.

edit flag offensive delete link more

Comments

Thanks a lot!

umyangxd gravatar imageumyangxd ( 2013-02-11 12:01:15 -0600 )edit
0

answered 2019-07-15 04:38:25 -0600

biinui gravatar image

Open JavaCameraView.java, then manually set the width and height inside InitializeCamera():

...

/* Now set camera parameters */
try {
    Camera.Parameters params = mCamera.getParameters();
    Log.d(TAG, "getSupportedPreviewSizes()");
    List<android.hardware.Camera.Size> sizes = params.getSupportedPreviewSizes();

    if (sizes != null) {
        /* Select the size that fits surface considering maximum size allowed */
        width = 1080;
        height = 1920;
        Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);

...

In my case, it's portrait. So switch it up if you want landscape. Unfortunately this is hardcoded, so please someone chime in for a dynamic solution.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-09 13:08:08 -0600

Seen: 3,713 times

Last updated: Jul 15 '19