• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 拍照实践(C/C++)
2<!--Kit: Camera Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @qano-->
5<!--Designer: @leo_ysl-->
6<!--Tester: @xchaosioda-->
7<!--Adviser: @zengyawen-->
8
9在开发相机应用时,需要先[申请相关权限](camera-preparation.md)。
10
11当前示例提供完整的拍照流程及其接口调用顺序的介绍。对于单个流程(如设备输入、会话管理、拍照)的介绍请参考[相机开发指导(Native)](native-camera-device-management.md)的具体章节。
12
13## 开发流程
14
15在获取到相机支持的输出流能力后,开始创建拍照流,开发流程如下。
16
17![Photographing Development Process](figures/photographing-ndk-development-process.png)
18
19## 完整示例
20
211. 在CMake脚本中链接相关动态库。
22    ```txt
23    target_link_libraries(entry PUBLIC
24        libace_napi.z.so
25        libhilog_ndk.z.so
26        libnative_buffer.so
27        libohcamera.so
28        libohimage.so
29        libohfileuri.so
30    )
31    ```
322. 创建头文件ndk_camera.h33   ```c++
34   #include "ohcamera/camera.h"
35   #include "ohcamera/camera_input.h"
36   #include "ohcamera/capture_session.h"
37   #include "ohcamera/photo_output.h"
38   #include "ohcamera/preview_output.h"
39   #include "ohcamera/video_output.h"
40   #include "ohcamera/camera_manager.h"
41
42   class NDKCamera {
43   public:
44       ~NDKCamera();
45       NDKCamera(char* previewId);
46       Camera_ErrorCode RegisterBufferCb(void* cb);
47   };
48   ```
49
503. cpp侧导入NDK接口,并根据传入的SurfaceId进行拍照。
51    ```c++
52    #include "hilog/log.h"
53    #include "ndk_camera.h"
54
55    void CaptureSessionOnFocusStateChange(Camera_CaptureSession* session, Camera_FocusState focusState)
56    {
57        OH_LOG_INFO(LOG_APP, "CaptureSessionOnFocusStateChange");
58    }
59
60    void CaptureSessionOnError(Camera_CaptureSession* session, Camera_ErrorCode errorCode)
61    {
62        OH_LOG_INFO(LOG_APP, "CaptureSessionOnError = %{public}d", errorCode);
63    }
64
65    CaptureSession_Callbacks* GetCaptureSessionRegister(void)
66    {
67        static CaptureSession_Callbacks captureSessionCallbacks = {
68            .onFocusStateChange = CaptureSessionOnFocusStateChange,
69            .onError = CaptureSessionOnError
70        };
71        return &captureSessionCallbacks;
72    }
73
74    void PreviewOutputOnFrameStart(Camera_PreviewOutput* previewOutput)
75    {
76        OH_LOG_INFO(LOG_APP, "PreviewOutputOnFrameStart");
77    }
78
79    void PreviewOutputOnFrameEnd(Camera_PreviewOutput* previewOutput, int32_t frameCount)
80    {
81        OH_LOG_INFO(LOG_APP, "PreviewOutputOnFrameEnd = %{public}d", frameCount);
82    }
83
84    void PreviewOutputOnError(Camera_PreviewOutput* previewOutput, Camera_ErrorCode errorCode)
85    {
86        OH_LOG_INFO(LOG_APP, "PreviewOutputOnError = %{public}d", errorCode);
87    }
88
89    PreviewOutput_Callbacks* GetPreviewOutputListener(void)
90    {
91        static PreviewOutput_Callbacks previewOutputListener = {
92            .onFrameStart = PreviewOutputOnFrameStart,
93            .onFrameEnd = PreviewOutputOnFrameEnd,
94            .onError = PreviewOutputOnError
95        };
96        return &previewOutputListener;
97    }
98
99    void OnCameraInputError(const Camera_Input* cameraInput, Camera_ErrorCode errorCode)
100    {
101        OH_LOG_INFO(LOG_APP, "OnCameraInput errorCode = %{public}d", errorCode);
102    }
103
104    CameraInput_Callbacks* GetCameraInputListener(void)
105    {
106        static CameraInput_Callbacks cameraInputCallbacks = {
107            .onError = OnCameraInputError
108        };
109        return &cameraInputCallbacks;
110    }
111
112    void CameraManagerStatusCallback(Camera_Manager* cameraManager, Camera_StatusInfo* status)
113    {
114        OH_LOG_INFO(LOG_APP, "CameraManagerStatusCallback is called");
115    }
116
117    CameraManager_Callbacks* GetCameraManagerListener()
118    {
119        static CameraManager_Callbacks cameraManagerListener = {
120            .onCameraStatus = CameraManagerStatusCallback
121        };
122        return &cameraManagerListener;
123    }
124
125    static void* bufferCb = nullptr;
126    Camera_ErrorCode NDKCamera::RegisterBufferCb(void* cb) {
127        OH_LOG_INFO(LOG_APP, " RegisterBufferCb start");
128        if (cb == nullptr) {
129            OH_LOG_INFO(LOG_APP, " RegisterBufferCb invalid error");
130            return CAMERA_INVALID_ARGUMENT;
131        }
132        bufferCb = cb;
133
134        return CAMERA_OK;
135    }
136    void OnPhotoAvailable(Camera_PhotoOutput* photoOutput, OH_PhotoNative* photo) {
137        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable start!");
138        OH_ImageNative* imageNative;
139        Camera_ErrorCode errCode = OH_PhotoNative_GetMainImage(photo, &imageNative);
140        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable errCode:%{public}d imageNative:%{public}p", errCode, imageNative);
141        // 读取 OH_ImageNative 的 size 属性。
142        Image_Size size;
143        Image_ErrorCode imageErr = OH_ImageNative_GetImageSize(imageNative, &size);
144        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable imageErr:%{public}d width:%{public}d height:%{public}d", imageErr,
145            size.width, size.height);
146        // 读取 OH_ImageNative 的组件列表的元素个数。
147        size_t componentTypeSize = 0;
148        imageErr = OH_ImageNative_GetComponentTypes(imageNative, nullptr, &componentTypeSize);
149        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable imageErr:%{public}d componentTypeSize:%{public}zu", imageErr,
150            componentTypeSize);
151        // 读取 OH_ImageNative 的组件列表。
152        uint32_t* components = new uint32_t[componentTypeSize];
153        imageErr = OH_ImageNative_GetComponentTypes(imageNative, &components, &componentTypeSize);
154        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable OH_ImageNative_GetComponentTypes imageErr:%{public}d", imageErr);
155        // 读取 OH_ImageNative 的第一个组件所对应的缓冲区对象。
156        OH_NativeBuffer* nativeBuffer = nullptr;
157        imageErr = OH_ImageNative_GetByteBuffer(imageNative, components[0], &nativeBuffer);
158        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable OH_ImageNative_GetByteBuffer imageErr:%{public}d", imageErr);
159        // 读取 OH_ImageNative 的第一个组件所对应的缓冲区大小。
160        size_t nativeBufferSize = 0;
161        imageErr = OH_ImageNative_GetBufferSize(imageNative, components[0], &nativeBufferSize);
162        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable imageErr:%{public}d nativeBufferSize:%{public}zu", imageErr,
163             nativeBufferSize);
164        // 读取 OH_ImageNative 的第一个组件所对应的像素行宽。
165        int32_t rowStride = 0;
166        imageErr = OH_ImageNative_GetRowStride(imageNative, components[0], &rowStride);
167        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable imageErr:%{public}d rowStride:%{public}d", imageErr, rowStride);
168        // 读取 OH_ImageNative 的第一个组件所对应的像素大小。
169        int32_t pixelStride = 0;
170        imageErr = OH_ImageNative_GetPixelStride(imageNative, components[0], &pixelStride);
171        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable imageErr:%{public}d pixelStride:%{public}d", imageErr, pixelStride);
172        // 将ION内存映射到进程空间。
173        void* virAddr = nullptr; // 指向映射内存的虚拟地址,解除映射后这个指针将不再有效。
174        int32_t ret = OH_NativeBuffer_Map(nativeBuffer, &virAddr); // 映射后通过第二个参数virAddr返回内存的首地址。
175        OH_LOG_INFO(LOG_APP, "OnPhotoAvailable OH_NativeBuffer_Map err:%{public}d", ret);
176        // 通过回调函数,将处理完的buffer传给ArkTS侧做显示或通过安全控件写文件保存,参考拍照(C/C++)开发指导。
177        auto cb = (void (*)(void *, size_t))(bufferCb);
178        cb(virAddr, nativeBufferSize);
179        // 在处理完之后,解除映射并释放缓冲区。
180        ret = OH_NativeBuffer_Unmap(nativeBuffer);
181        if (ret != 0) {
182            OH_LOG_ERROR(LOG_APP, "OnPhotoAvailable OH_NativeBuffer_Unmap error:%{public}d", ret);
183        }
184    }
185
186    NDKCamera::NDKCamera(char* previewId)
187    {
188        Camera_Manager* cameraManager = nullptr;
189        Camera_Device* cameras = nullptr;
190        Camera_CaptureSession* captureSession = nullptr;
191        Camera_OutputCapability* cameraOutputCapability = nullptr;
192        const Camera_Profile* previewProfile = nullptr;
193        const Camera_Profile* photoProfile = nullptr;
194        Camera_PreviewOutput* previewOutput = nullptr;
195        Camera_PhotoOutput* photoOutput = nullptr;
196        Camera_Input* cameraInput = nullptr;
197        uint32_t size = 0;
198        uint32_t cameraDeviceIndex = 0;
199        char* previewSurfaceId = previewId;
200        // 创建CameraManager对象。
201        Camera_ErrorCode ret = OH_Camera_GetCameraManager(&cameraManager);
202        if (cameraManager == nullptr || ret != CAMERA_OK) {
203            OH_LOG_ERROR(LOG_APP, "OH_Camera_GetCameraMananger failed.");
204            return;
205        }
206        // 监听相机状态变化。
207        ret = OH_CameraManager_RegisterCallback(cameraManager, GetCameraManagerListener());
208        if (ret != CAMERA_OK) {
209            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_RegisterCallback failed.");
210        }
211
212        // 获取相机列表。
213        ret = OH_CameraManager_GetSupportedCameras(cameraManager, &cameras, &size);
214        if (cameras == nullptr || size <= 0 || ret != CAMERA_OK) {
215            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_GetSupportedCameras failed.");
216            return;
217        }
218
219        if (size < cameraDeviceIndex + 1) {
220            OH_LOG_ERROR(LOG_APP, "cameraDeviceIndex is invalid.");
221            return;
222        }
223
224        // 创建相机输入流。
225        ret = OH_CameraManager_CreateCameraInput(cameraManager, &cameras[cameraDeviceIndex], &cameraInput);
226        if (cameraInput == nullptr || ret != CAMERA_OK) {
227            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreateCameraInput failed.");
228            return;
229        }
230
231        // 监听cameraInput错误信息。
232        ret = OH_CameraInput_RegisterCallback(cameraInput, GetCameraInputListener());
233        if (ret != CAMERA_OK) {
234            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_RegisterCallback failed.");
235            return;
236        }
237
238        // 打开相机。
239        ret = OH_CameraInput_Open(cameraInput);
240        if (ret != CAMERA_OK) {
241            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_Open failed.");
242            return;
243        }
244
245        // 获取相机设备支持的输出流能力。
246        ret = OH_CameraManager_GetSupportedCameraOutputCapability(cameraManager, &cameras[cameraDeviceIndex],
247                                                                  &cameraOutputCapability);
248        if (cameraOutputCapability == nullptr || ret != CAMERA_OK) {
249            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_GetSupportedCameraOutputCapability failed.");
250            return;
251        }
252
253        if (cameraOutputCapability->previewProfiles == nullptr) {
254            OH_LOG_ERROR(LOG_APP, "previewProfiles == null");
255            return;
256        }
257        // 根据所需从cameraOutputCapability->previewProfiles中选择合适的预览分辨率
258        previewProfile = cameraOutputCapability->previewProfiles[0];
259
260        if (cameraOutputCapability->photoProfiles == nullptr) {
261            OH_LOG_ERROR(LOG_APP, "photoProfiles == null");
262            return;
263        }
264        // 根据所需从cameraOutputCapability->photoProfiles中选择合适的拍照分辨率
265        photoProfile = cameraOutputCapability->photoProfiles[0];
266
267        // 创建预览输出流,其中参数 previewSurfaceId 参考上文 XComponent 组件,预览流为XComponent组件提供的surface。
268        ret = OH_CameraManager_CreatePreviewOutput(cameraManager, previewProfile, previewSurfaceId, &previewOutput);
269        if (previewProfile == nullptr || previewOutput == nullptr || ret != CAMERA_OK) {
270            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreatePreviewOutput failed.");
271            return;
272        }
273
274        // 监听预览输出错误信息。
275        ret = OH_PreviewOutput_RegisterCallback(previewOutput, GetPreviewOutputListener());
276        if (ret != CAMERA_OK) {
277            OH_LOG_ERROR(LOG_APP, "OH_PreviewOutput_RegisterCallback failed.");
278        }
279
280        // 创建拍照输出流。
281        ret = OH_CameraManager_CreatePhotoOutputWithoutSurface(cameraManager, photoProfile, &photoOutput);
282
283        // 监听单端式拍照回调。
284        ret = OH_PhotoOutput_RegisterPhotoAvailableCallback(photoOutput, OnPhotoAvailable);
285
286        //创建会话。
287        ret = OH_CameraManager_CreateCaptureSession(cameraManager, &captureSession);
288        if (captureSession == nullptr || ret != CAMERA_OK) {
289            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreateCaptureSession failed.");
290            return;
291        }
292
293        // 监听session错误信息。
294        ret = OH_CaptureSession_RegisterCallback(captureSession, GetCaptureSessionRegister());
295        if (ret != CAMERA_OK) {
296            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_RegisterCallback failed.");
297        }
298
299        // 开始配置会话。
300        ret = OH_CaptureSession_BeginConfig(captureSession);
301        if (ret != CAMERA_OK) {
302            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_BeginConfig failed.");
303            return;
304        }
305
306        // 向会话中添加相机输入流。
307        ret = OH_CaptureSession_AddInput(captureSession, cameraInput);
308        if (ret != CAMERA_OK) {
309            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddInput failed.");
310            return;
311        }
312
313        // 向会话中添加预览输出流。
314        ret = OH_CaptureSession_AddPreviewOutput(captureSession, previewOutput);
315        if (ret != CAMERA_OK) {
316            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddPreviewOutput failed.");
317            return;
318        }
319
320        // 向会话中添加拍照输出流。
321        ret = OH_CaptureSession_AddPhotoOutput(captureSession, photoOutput);
322        if (ret != CAMERA_OK) {
323            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddPhotoOutput failed.");
324            return;
325        }
326
327        // 提交会话配置。
328        ret = OH_CaptureSession_CommitConfig(captureSession);
329        if (ret != CAMERA_OK) {
330            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_CommitConfig failed.");
331            return;
332        }
333
334        // 启动会话。
335        ret = OH_CaptureSession_Start(captureSession);
336        if (ret != CAMERA_OK) {
337            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Start failed.");
338            return;
339        }
340
341        // 判断设备是否支持闪光灯。
342        Camera_FlashMode flashMode = FLASH_MODE_AUTO;
343        bool hasFlash = false;
344        ret = OH_CaptureSession_HasFlash(captureSession, &hasFlash);
345        if (ret != CAMERA_OK) {
346            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_HasFlash failed.");
347        }
348        if (hasFlash) {
349            OH_LOG_INFO(LOG_APP, "hasFlash success");
350        } else {
351            OH_LOG_ERROR(LOG_APP, "hasFlash fail");
352        }
353
354        // 检测闪光灯模式是否支持。
355        bool isSupported = false;
356        ret = OH_CaptureSession_IsFlashModeSupported(captureSession, flashMode, &isSupported);
357        if (ret != CAMERA_OK) {
358            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_IsFlashModeSupported failed.");
359        }
360        if (isSupported) {
361            OH_LOG_INFO(LOG_APP, "isFlashModeSupported success");
362
363            // 设置闪光灯模式。
364            ret = OH_CaptureSession_SetFlashMode(captureSession, flashMode);
365            if (ret == CAMERA_OK) {
366                OH_LOG_INFO(LOG_APP, "OH_CaptureSession_SetFlashMode success.");
367            } else {
368                OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_SetFlashMode failed. %{public}d ", ret);
369            }
370
371            // 获取当前设备的闪光灯模式。
372            ret = OH_CaptureSession_GetFlashMode(captureSession, &flashMode);
373            if (ret == CAMERA_OK) {
374                OH_LOG_INFO(LOG_APP, "OH_CaptureSession_GetFlashMode success. flashMode:%{public}d ", flashMode);
375            } else {
376                OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_GetFlashMode failed. %d ", ret);
377            }
378        } else {
379            OH_LOG_ERROR(LOG_APP, "isFlashModeSupported fail");
380        }
381
382        // 判断是否支持连续自动变焦模式。
383        Camera_FocusMode focusMode = FOCUS_MODE_CONTINUOUS_AUTO;
384        bool isFocusModeSupported = false;
385        ret = OH_CaptureSession_IsFocusModeSupported(captureSession, focusMode, &isFocusModeSupported);
386        if (ret != CAMERA_OK) {
387            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_IsFocusModeSupported failed.");
388        }
389        if (isFocusModeSupported) {
390            OH_LOG_INFO(LOG_APP, "isFocusModeSupported success");
391            ret = OH_CaptureSession_SetFocusMode(captureSession, focusMode);
392            if (ret != CAMERA_OK) {
393                OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_SetFocusMode failed. %{public}d ", ret);
394            }
395            ret = OH_CaptureSession_GetFocusMode(captureSession, &focusMode);
396            if (ret == CAMERA_OK) {
397                OH_LOG_INFO(LOG_APP, "OH_CaptureSession_GetFocusMode success. focusMode%{public}d ", focusMode);
398            } else {
399                OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_GetFocusMode failed. %d ", ret);
400            }
401        } else {
402            OH_LOG_ERROR(LOG_APP, "isFocusModeSupported fail");
403        }
404
405        // 获取相机支持的可变焦距比范围。
406        float minZoom;
407        float maxZoom;
408        ret = OH_CaptureSession_GetZoomRatioRange(captureSession, &minZoom, &maxZoom);
409        if (ret != CAMERA_OK) {
410            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_GetZoomRatioRange failed.");
411        } else {
412            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_GetZoomRatioRange success. minZoom: %{public}f, maxZoom:%{public}f",
413                minZoom, maxZoom);
414        }
415
416        // 设置变焦。
417        ret = OH_CaptureSession_SetZoomRatio(captureSession, maxZoom);
418        if (ret == CAMERA_OK) {
419            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_SetZoomRatio success.");
420        } else {
421            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_SetZoomRatio failed. %{public}d ", ret);
422        }
423
424        // 获取当前设备的变焦值。
425        ret = OH_CaptureSession_GetZoomRatio(captureSession, &maxZoom);
426        if (ret == CAMERA_OK) {
427            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_GetZoomRatio success. zoom:%{public}f ", maxZoom);
428        } else {
429            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_GetZoomRatio failed. %{public}d ", ret);
430        }
431
432        // 无拍照设置进行拍照。
433        ret = OH_PhotoOutput_Capture(photoOutput);
434        if (ret == CAMERA_OK) {
435            OH_LOG_INFO(LOG_APP, "OH_PhotoOutput_Capture success ");
436        } else {
437            OH_LOG_ERROR(LOG_APP, "OH_PhotoOutput_Capture failed. %d ", ret);
438        }
439
440        // 停止当前会话。
441        ret = OH_CaptureSession_Stop(captureSession);
442        if (ret == CAMERA_OK) {
443            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_Stop success ");
444        } else {
445            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Stop failed. %d ", ret);
446        }
447
448        // 释放相机输入流。
449        ret = OH_CameraInput_Close(cameraInput);
450        if (ret == CAMERA_OK) {
451            OH_LOG_INFO(LOG_APP, "OH_CameraInput_Close success ");
452        } else {
453            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_Close failed. %d ", ret);
454        }
455
456        // 释放预览输出流。
457        ret = OH_PreviewOutput_Release(previewOutput);
458        if (ret == CAMERA_OK) {
459            OH_LOG_INFO(LOG_APP, "OH_PreviewOutput_Release success ");
460        } else {
461            OH_LOG_ERROR(LOG_APP, "OH_PreviewOutput_Release failed. %d ", ret);
462        }
463
464        // 释放拍照输出流。
465        ret = OH_PhotoOutput_Release(photoOutput);
466        if (ret == CAMERA_OK) {
467          OH_LOG_INFO(LOG_APP, "OH_PhotoOutput_Release success ");
468        } else {
469          OH_LOG_ERROR(LOG_APP, "OH_PhotoOutput_Release failed. %d ", ret);
470        }
471
472        // 释放会话。
473        ret = OH_CaptureSession_Release(captureSession);
474        if (ret == CAMERA_OK) {
475            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_Release success ");
476        } else {
477            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Release failed. %d ", ret);
478        }
479
480        // 资源释放。
481        ret = OH_CameraManager_DeleteSupportedCameras(cameraManager, cameras, size);
482        if (ret != CAMERA_OK) {
483            OH_LOG_ERROR(LOG_APP, "Delete Cameras failed.");
484        } else {
485            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_DeleteSupportedCameras. ok");
486        }
487        ret = OH_CameraManager_DeleteSupportedCameraOutputCapability(cameraManager, cameraOutputCapability);
488        if (ret != CAMERA_OK) {
489            OH_LOG_ERROR(LOG_APP, "Delete Cameras failed.");
490        } else {
491            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_DeleteSupportedCameraOutputCapability. ok");
492        }
493        ret = OH_Camera_DeleteCameraManager(cameraManager);
494        if (ret != CAMERA_OK) {
495            OH_LOG_ERROR(LOG_APP, "Delete Cameras failed.");
496        } else {
497            OH_LOG_ERROR(LOG_APP, "OH_Camera_DeleteCameraManager. ok");
498        }
499    }
500    ```