如题,OpenHarmony 3.2 Release如何采用Native API切换相机的前后摄像头,目前默认获取的摄像头个数为1(尽管设备存在两个摄像头), 代码片段如下:

 

```

    sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
    camManagerObj->SetCallback(std::make_shared<TestCameraMngerCallback>(testName));
    std::vector<sptr<CameraDevice>> cameraObjList = camManagerObj->GetSupportedCameras();

    LOGI("Camera ID count: %lu\n", cameraObjList.size());

    for (auto info : cameraObjList) {
        LOGI("Camera ID: %s, position: %d, camera type: %d, connection type: %d\n", info->GetID().c_str(),
            info->GetPosition(), info->GetCameraType(), info->GetConnectionType());

    }

```

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐