From 7d8315285fb260524a95713ce157bbfbed5e321b Mon Sep 17 00:00:00 2001 From: Yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Fri, 1 Aug 2025 06:55:41 +0000 Subject: [PATCH 1/2] =?UTF-8?q?readme=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yxk2026 <10178404+yxk2026@user.noreply.gitee.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9d196d..205e7aa 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ ### 具体实现 * 相机功能接口实现在CameraManager.cpp中,源码参考:[camera_manager.cpp](entry/src/main/cpp/camera_manager.cpp) - * 在NDKCamera构造函数里完成一个相机生命周期初始化的过程,包括调用OH_Camera_GetCameraMananger获取CameraMananger,调用OH_CameraManager_CreateCaptureSession创建CaptureSession,调用CaptureSessionRegisterCallback创建CaptureSession注册回调,调用GetSupportedCameras获取支持的camera设备,调用GetSupportedOutputCapability获取支持的camera设备能力集,调用CreatePreviewOutput创建预览输出,调用CreateCameraInput创建相机输入,调用CameraInputOpen打开相机输入,调用CameraManagerRegisterCallback创建CameraManager注册回调,最后调用SessionFlowFn开启Session。 + * 在NDKCamera构造函数里完成一个相机生命周期初始化的过程,包括调用OH_Camera_GetCameraManager获取CameraManager,调用OH_CameraManager_CreateCaptureSession创建CaptureSession,调用CaptureSessionRegisterCallback创建CaptureSession注册回调,调用GetSupportedCameras获取支持的camera设备,调用GetSupportedOutputCapability获取支持的camera设备能力集,调用CreatePreviewOutput创建预览输出,调用CreateCameraInput创建相机输入,调用CameraInputOpen打开相机输入,调用CameraManagerRegisterCallback创建CameraManager注册回调,最后调用SessionFlowFn开启Session。 * 其中SessionFlowFn是一个开启预览的动作,主要流程包括:调用OH_CaptureSession_BeginConfig开始配置会话,调用OH_CaptureSession_AddInput把CameraInput加入到会话,调用OH_CaptureSession_AddPreviewOutput把previewOutput加入到会话,调用OH_CaptureSession_CommitConfig提交配置信息,调用OH_CaptureSession_Start开始会话工作,还有一步是在开启预览的同时调用IsFocusMode启动对焦功能,这边后面会涉及到。 * 在NDKCamera析构函数里完成对相机生命周期释放的过程,调用OH_CameraManager_DeleteSupportedCameras删除支持的camera设备,调用OH_CameraManager_DeleteSupportedCameraOutputCapability删除支持的camera设备能力集,调用OH_Camera_DeleteCameraManager删除camera manager。 * 拍照功能相关接口封装在StartPhoto接口中,主要包含以下流程:调用SessionStop关闭session,调用SessionBegin做session的一个预置动作,调用CreatePhotoOutput创建相机输出,调用OH_CaptureSession_AddPhotoOutput将hotoOutput添加至session中,调用SessionCommitConfig提交session,在调用SessionStart开启session,最后调用TakePicture接口开启拍照动作。 -- Gitee From 36dcb383884e9e90bbbaba1bec513f7f05484f24 Mon Sep 17 00:00:00 2001 From: Yxk2026 <10178404+yxk2026@user.noreply.gitee.com> Date: Fri, 1 Aug 2025 06:56:16 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8B=B1=E6=96=87readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yxk2026 <10178404+yxk2026@user.noreply.gitee.com> --- README.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.en.md b/README.en.md index 886cba1..9dda370 100644 --- a/README.en.md +++ b/README.en.md @@ -56,7 +56,7 @@ This sample shows how to use the libohcamera.so interface to implement a series ### How to Implement * Camera interfaces are implemented in **CameraManager.cpp**. For details about the source code, see [camera_manager.cpp](entry/src/main/cpp/camera_manager.cpp). - * Camera initialization is implemented in the **NDKCamera** constructor. The process is as follows: Call **OH_Camera_GetCameraMananger** to obtain CameraMananger, call **OH_CameraManager_CreateCaptureSession** to create CaptureSession, call **CaptureSessionRegisterCallback** to register a callback for CaptureSession, call **GetSupportedCameras** to obtain supported cameras, call **GetSupportedOutputCapability** to obtain supported camera capabilities, call **CreatePreviewOutput** to create a preview output, call **CreateCameraInput** to create a camera input, call **CameraInputOpen** to open the camera input, call **CameraManagerRegisterCallback** to register a callback for CameraManager, and call **SessionFlowFn** to enable the session. + * Camera initialization is implemented in the **NDKCamera** constructor. The process is as follows: Call **OH_Camera_GetCameraManager** to obtain CameraManager, call **OH_CameraManager_CreateCaptureSession** to create CaptureSession, call **CaptureSessionRegisterCallback** to register a callback for CaptureSession, call **GetSupportedCameras** to obtain supported cameras, call **GetSupportedOutputCapability** to obtain supported camera capabilities, call **CreatePreviewOutput** to create a preview output, call **CreateCameraInput** to create a camera input, call **CameraInputOpen** to open the camera input, call **CameraManagerRegisterCallback** to register a callback for CameraManager, and call **SessionFlowFn** to enable the session. * SessionFlowFn is an action for enabling preview. The process is as follows: Call **OH_CaptureSession_BeginConfig** to start configuration for a session, call **OH_CaptureSession_AddInput** to add a camera input to the session, call **OH_CaptureSession_AddPreviewOutput** to add a preview output to the session, call **OH_CaptureSession_CommitConfig** to commit the configuration, call **OH_CaptureSession_Start** to start the session, and call **IsFocusMode** to enable the focus mode when preview is enabled. * Camera release is initialized in the **NDKCamera** destructor. The process is as follows: Call **OH_CameraManager_DeleteSupportedCameras** to delete supported cameras, call **OH_CameraManager_DeleteSupportedCameraOutputCapability** to delete supported camera capabilities, and call **OH_Camera_DeleteCameraManager** to delete CameraManager. * Photographing interfaces are encapsulated in the **StartPhoto** interface. The process is as follows: Call **SessionStop** to close the session, call **SessionBegin** to perform a preset action for the session, call **CreatePhotoOutput** to create a camera output, call **OH_CaptureSession_AddPhotoOutput** to add a photo output to the session, call **SessionCommitConfig** to commit the session configuration, call **SessionStart** to start the session, and then call **TakePicture** to take a photo. -- Gitee