语言

Menu
Sites
Language
Get rear or back camera

I just get front camera, could some one tell me, how to get the rear or back camera, please ?

响应

11 回复
Jean Yang

Hello, 

when you create camera, please use the CAMERA_DEVICE_CAMERA0 = 0, /**< Primary camera */

 

typedef enum
{
    CAMERA_DEVICE_CAMERA0 = 0, /**< Primary camera */
    CAMERA_DEVICE_CAMERA1      /**< Secondary camera */

} camera_device_e;

 

static void _create_camera(camera_capture_view *view)
{
    if(view->camera)
    {
        _destroy_camera(view);
    }

    if(camera_create(CAMERA_DEVICE_CAMERA0, &view->camera) == CAMERA_ERROR_NONE)
    {
        camera_set_capture_format(view->camera, CAMERA_PIXEL_FORMAT_JPEG);
        camera_set_display(view->camera, CAMERA_DISPLAY_TYPE_EVAS, GET_DISPLAY(view->camera_rect));
        camera_set_display_mode(view->camera, CAMERA_DISPLAY_MODE_FULL);
        camera_set_display_rotation(view->camera, CAMERA_ROTATION_180);
        camera_set_display_flip(view->camera, CAMERA_FLIP_VERTICAL);
    }
    else
    {
        view->camera = NULL;
    }
}

Jingbiao Nan

Hi Yang !

The rear camera can be got. However, the view displays 90º contrarotate. No matter the camera_attr_set_scene_mode(xxx, CAMERA_ATTR_SCENE_MODE_PORTRAIT) is called, besides, it always return error value.

And the camera_attr_set_stream_rotation() has the same situation above.

And my device is Samsung Z1.

 

If it is convenient, could you please send me a simple demo?

jingbiao.nan@samsung.com.

Thanks very much.

Jeongmo Yang

In general, camera lens in mobile is rotated.

so you need to set proper display rotation in case of CAMERA_DISPLAY_TYPE_OVERLAY type.

please check below APIs.

 

int camera_attr_get_lens_orientation(camera_h camera, int *angle);
int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation);

 

and you can rotate preview image by rotating evas image object in case of CAMERA_DISPLAY_TYPE_OVERLAY type.

 

"camera_attr_set_scene_mode" API is for program mode.(preset setting mode)

so it does not affect the rotation of preview image.

Jean Yang

Hello, 

 

The sample code is in the IDE sample, just create the media sample , and find the camera_capture_view.c file, you can find related code.

Palitsyna

Hello,

you can find Camera tutorial here:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.tutorials/html/native/multimedia/camera_tutorial_n.htm#attributes

Hope this will help you.

 

Regards,

Svetlana Palitsyna

Alexandros Chronopoulos

Hi Nan,

It seems I have the same problem with z1 device. I use back camera but the image is rotated by 270 degrees. I have tried all the following but the rotation of the image does not change:

camera_set_display_rotation

camera_attr_set_stream_flip

camera_attr_set_tag_orientation

camera_set_display_flip

Also camera_attr_set_scene_mode and camera_attr_set_stream_flip return -1073741822 (feature not supported).

Did you manged to find a solution on this? Just to mention I use CAMERA_DISPLAY_TYPE_EVAS as display type.

Alex Dem

Hi,
just fyi:
https://developer.tizen.org/forums/native-application-development/camera-capture-always-landscape-0
Also did you add privilege: http://tizen.org/privilege/camera ?
Alexey.

Alexandros Chronopoulos

Hi Alexey, Thanks for the response. If I do not miss something the problem is also not solved on the provided thread. I have added the corresponding privilege and try almost every method of the API but it seems that they do not affect the orientation of the image.

Do you know if display type affect the orientation?

Alex Dem

Hi,
For self camera native sample is used CAMERA_DISPLAY_TYPE_EVAS . I did not check with CAMERA_DISPLAY_TYPE_OVERLAY. I 'll try to check with Z1/Z3 devices and provide results.
Alexey.

Alexandros Chronopoulos

I solved the issue by using OpenGL library. The solution found in the guide (pdf file) in the following page:

https://developer.tizen.org/community/tip-tech/guide-developing-tizen-native-application

In page 516: "To display the camera preview, you must use the OpenGL library. You can do this by simply passing ‘opengl’ to the elm_config_accel_preference_set() function."

Note that the elm_config_accel_preference_set("opengl") must be called before the creation of the window.

Now I wonder how I can use this in my application. In this case camera viewer is part of the application which does not use OpenGL. Is it safe to change it globally or it will cause other problem. Is there any way not to change it globally?

Alex Dem

Hi,
fyi: Native sample 'self camera' uses this  apt (see window.c file). Afaik it is necessary to use.
I think only this call should be added before window creation: elm_config_accel_preference_set("opengl");
Alexey.