1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {BusinessError, ErrorCallback, AsyncCallback} from './basic'; 17import { Context } from './app/context'; 18 19/** 20 * @name camera 21 * @syscap SystemCapability.Multimedia.Camera.Core 22 * @since 9 23 * @systemapi 24 */ 25declare namespace camera { 26 27 /** 28 * Creates a CameraManager instance. 29 * @param context Current application context. 30 * @returns CameraManager instance. 31 * @since 9 32 * @syscap SystemCapability.Multimedia.Camera.Core 33 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 34 * @throws { BusinessError } 7400201 - Camera service fatal error. 35 */ 36 function getCameraManager(context: Context): CameraManager; 37 38 /** 39 * Enum for camera status. 40 * @since 9 41 * @syscap SystemCapability.Multimedia.Camera.Core 42 */ 43 enum CameraStatus { 44 /** 45 * Appear status. 46 * @since 9 47 * @syscap SystemCapability.Multimedia.Camera.Core 48 */ 49 CAMERA_STATUS_APPEAR = 0, 50 /** 51 * Disappear status. 52 * @since 9 53 * @syscap SystemCapability.Multimedia.Camera.Core 54 */ 55 CAMERA_STATUS_DISAPPEAR = 1, 56 /** 57 * Available status. 58 * @since 9 59 * @syscap SystemCapability.Multimedia.Camera.Core 60 */ 61 CAMERA_STATUS_AVAILABLE = 2, 62 /** 63 * Unavailable status. 64 * @since 9 65 * @syscap SystemCapability.Multimedia.Camera.Core 66 */ 67 CAMERA_STATUS_UNAVAILABLE = 3 68 } 69 70 /** 71 * Profile for camera streams. 72 * @since 9 73 * @syscap SystemCapability.Multimedia.Camera.Core 74 */ 75 interface Profile { 76 /** 77 * Camera format. 78 * @since 9 79 * @syscap SystemCapability.Multimedia.Camera.Core 80 */ 81 readonly format: CameraFormat; 82 /** 83 * Picture size. 84 * @since 9 85 * @syscap SystemCapability.Multimedia.Camera.Core 86 */ 87 readonly size: Size; 88 } 89 90 /** 91 * Frame rate range. 92 * @since 9 93 * @syscap SystemCapability.Multimedia.Camera.Core 94 */ 95 interface FrameRateRange { 96 /** 97 * Min frame rate. 98 * @since 9 99 * @syscap SystemCapability.Multimedia.Camera.Core 100 */ 101 readonly min: number; 102 /** 103 * Max frame rate. 104 * @since 9 105 * @syscap SystemCapability.Multimedia.Camera.Core 106 */ 107 readonly max: number; 108 } 109 110 /** 111 * Video profile. 112 * @since 9 113 * @syscap SystemCapability.Multimedia.Camera.Core 114 */ 115 interface VideoProfile extends Profile { 116 /** 117 * Frame rate in unit fps (frames per second). 118 * @since 9 119 * @syscap SystemCapability.Multimedia.Camera.Core 120 */ 121 readonly frameRateRange: FrameRateRange; 122 } 123 124 /** 125 * Camera output capability. 126 * @since 9 127 * @syscap SystemCapability.Multimedia.Camera.Core 128 */ 129 interface CameraOutputCapability { 130 /** 131 * Preview profiles. 132 * @since 9 133 * @syscap SystemCapability.Multimedia.Camera.Core 134 */ 135 readonly previewProfiles: Array<Profile>; 136 /** 137 * Photo profiles. 138 * @since 9 139 * @syscap SystemCapability.Multimedia.Camera.Core 140 */ 141 readonly photoProfiles: Array<Profile>; 142 /** 143 * Video profiles. 144 * @since 9 145 * @syscap SystemCapability.Multimedia.Camera.Core 146 */ 147 readonly videoProfiles: Array<VideoProfile>; 148 /** 149 * All the supported metadata Object Types. 150 * @since 9 151 * @syscap SystemCapability.Multimedia.Camera.Core 152 */ 153 readonly supportedMetadataObjectTypes: Array<MetadataObjectType>; 154 } 155 156 /** 157 * Enum for camera error code. 158 * @since 9 159 * @syscap SystemCapability.Multimedia.Camera.Core 160 */ 161 enum CameraErrorCode { 162 /** 163 * Parameter missing or parameter type incorrect 164 * @since 9 165 */ 166 INVALID_ARGUMENT = 7400101, 167 /** 168 * Operation not allow. 169 * @since 9 170 */ 171 OPERATION_NOT_ALLOWED = 7400102, 172 /** 173 * Session not config. 174 * @since 9 175 */ 176 SESSION_NOT_CONFIG = 7400103, 177 /** 178 * Session not running. 179 * @since 9 180 */ 181 SESSION_NOT_RUNNING = 7400104, 182 /** 183 * Session config locked. 184 * @since 9 185 */ 186 SESSION_CONFIG_LOCKED = 7400105, 187 /** 188 * Device setting locked. 189 * @since 9 190 */ 191 DEVICE_SETTING_LOCKED = 7400106, 192 /** 193 * Can not use camera cause of conflict. 194 * @since 9 195 */ 196 CONFILICT_CAMERA = 7400107, 197 /** 198 * Camera disabled cause of security reason. 199 * @since 9 200 */ 201 DEVICE_DISABLED = 7400108, 202 /** 203 * Camera service fatal error. 204 * @since 9 205 */ 206 SERVICE_FATAL_ERROR = 7400201 207 } 208 209 /** 210 * Camera manager object. 211 * @since 9 212 * @syscap SystemCapability.Multimedia.Camera.Core 213 */ 214 interface CameraManager { 215 /** 216 * Gets supported camera descriptions. 217 * @returns An array of supported cameras. 218 * @since 9 219 * @syscap SystemCapability.Multimedia.Camera.Core 220 */ 221 getSupportedCameras(): Array<CameraDevice>; 222 223 /** 224 * Gets supported output capability for specific camera. 225 * @param camera Camera device. 226 * @returns The camera output capability. 227 * @since 9 228 * @syscap SystemCapability.Multimedia.Camera.Core 229 */ 230 getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability; 231 232 /** 233 * Determine whether camera is muted. 234 * @returns Is camera muted. 235 * @since 9 236 * @syscap SystemCapability.Multimedia.Camera.Core 237 */ 238 isCameraMuted(): boolean; 239 240 /** 241 * Determine whether camera mute is supported. 242 * @returns Is camera mute supported. 243 * @since 9 244 * @syscap SystemCapability.Multimedia.Camera.Core 245 * @systemapi 246 */ 247 isCameraMuteSupported(): boolean; 248 249 /** 250 * Mute camera. 251 * @param mute Mute camera if TRUE, otherwise unmute camera. 252 * @since 9 253 * @syscap SystemCapability.Multimedia.Camera.Core 254 * @systemapi 255 */ 256 muteCamera(mute: boolean): void; 257 258 /** 259 * Creates a CameraInput instance by camera. 260 * @param camera Camera device used to create the instance. 261 * @returns The CameraInput instance. 262 * @since 9 263 * @syscap SystemCapability.Multimedia.Camera.Core 264 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 265 * @permission ohos.permission.CAMERA 266 */ 267 createCameraInput(camera: CameraDevice): CameraInput; 268 269 /** 270 * Creates a CameraInput instance by camera position and type. 271 * @param position Target camera position. 272 * @param type Target camera type. 273 * @returns The CameraInput instance. 274 * @since 9 275 * @syscap SystemCapability.Multimedia.Camera.Core 276 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 277 * @permission ohos.permission.CAMERA 278 */ 279 createCameraInput(position: CameraPosition, type: CameraType): CameraInput; 280 281 /** 282 * Creates a PreviewOutput instance. 283 * @param profile Preview output profile. 284 * @param surfaceId Surface object id used in camera photo output. 285 * @returns The PreviewOutput instance. 286 * @since 9 287 * @syscap SystemCapability.Multimedia.Camera.Core 288 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 289 */ 290 createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput; 291 292 /** 293 * Creates a PhotoOutput instance. 294 * @param profile Photo output profile. 295 * @param surfaceId Surface object id used in camera photo output. 296 * @returns The PhotoOutput instance. 297 * @since 9 298 * @syscap SystemCapability.Multimedia.Camera.Core 299 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 300 */ 301 createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput; 302 303 /** 304 * Creates a VideoOutput instance. 305 * @param profile Video profile. 306 * @param surfaceId Surface object id used in camera video output. 307 * @returns The VideoOutput instance. 308 * @since 9 309 * @syscap SystemCapability.Multimedia.Camera.Core 310 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 311 */ 312 createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput; 313 314 /** 315 * Creates a MetadataOutput instance. 316 * @param metadataObjectTypes Array of MetadataObjectType. 317 * @returns The MetadataOutput instance. 318 * @since 9 319 * @syscap SystemCapability.Multimedia.Camera.Core 320 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 321 */ 322 createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType>): MetadataOutput; 323 324 /** 325 * Gets a CaptureSession instance. 326 * @returns The CaptureSession instance. 327 * @since 9 328 * @syscap SystemCapability.Multimedia.Camera.Core 329 * @throws { BusinessError } 7400201 - Camera service fatal error. 330 */ 331 createCaptureSession(): CaptureSession; 332 333 /** 334 * Subscribes camera status change event callback. 335 * @param type Event type. 336 * @param callback Callback used to get the camera status change. 337 * @since 9 338 * @syscap SystemCapability.Multimedia.Camera.Core 339 */ 340 on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo>): void; 341 342 /** 343 * Subscribes camera mute change event callback. 344 * @param type Event type. 345 * @param callback Callback used to get the camera mute change. 346 * @since 9 347 * @syscap SystemCapability.Multimedia.Camera.Core 348 * @systemapi 349 */ 350 on(type: 'cameraMute', callback: AsyncCallback<boolean>): void; 351 } 352 353 /** 354 * Camera status info. 355 * @since 9 356 * @syscap SystemCapability.Multimedia.Camera.Core 357 */ 358 interface CameraStatusInfo { 359 /** 360 * Camera instance. 361 * @since 9 362 * @syscap SystemCapability.Multimedia.Camera.Core 363 */ 364 camera: CameraDevice; 365 /** 366 * Current camera status. 367 * @since 9 368 * @syscap SystemCapability.Multimedia.Camera.Core 369 */ 370 status: CameraStatus; 371 } 372 373 /** 374 * Enum for camera position. 375 * @since 9 376 * @syscap SystemCapability.Multimedia.Camera.Core 377 */ 378 enum CameraPosition { 379 /** 380 * Unspecified position. 381 * @since 9 382 * @syscap SystemCapability.Multimedia.Camera.Core 383 */ 384 CAMERA_POSITION_UNSPECIFIED = 0, 385 /** 386 * Back position. 387 * @since 9 388 * @syscap SystemCapability.Multimedia.Camera.Core 389 */ 390 CAMERA_POSITION_BACK = 1, 391 /** 392 * Front position. 393 * @since 9 394 * @syscap SystemCapability.Multimedia.Camera.Core 395 */ 396 CAMERA_POSITION_FRONT = 2 397 } 398 399 /** 400 * Enum for camera type. 401 * @since 9 402 * @syscap SystemCapability.Multimedia.Camera.Core 403 */ 404 enum CameraType { 405 /** 406 * Default camera type 407 * @since 9 408 * @syscap SystemCapability.Multimedia.Camera.Core 409 */ 410 CAMERA_TYPE_DEFAULT = 0, 411 412 /** 413 * Wide camera 414 * @since 9 415 * @syscap SystemCapability.Multimedia.Camera.Core 416 */ 417 CAMERA_TYPE_WIDE_ANGLE = 1, 418 419 /** 420 * Ultra wide camera 421 * @since 9 422 * @syscap SystemCapability.Multimedia.Camera.Core 423 */ 424 CAMERA_TYPE_ULTRA_WIDE = 2, 425 426 /** 427 * Telephoto camera 428 * @since 9 429 * @syscap SystemCapability.Multimedia.Camera.Core 430 */ 431 CAMERA_TYPE_TELEPHOTO = 3, 432 433 /** 434 * True depth camera 435 * @since 9 436 * @syscap SystemCapability.Multimedia.Camera.Core 437 */ 438 CAMERA_TYPE_TRUE_DEPTH = 4 439 } 440 441 /** 442 * Enum for camera connection type. 443 * @since 9 444 * @syscap SystemCapability.Multimedia.Camera.Core 445 */ 446 enum ConnectionType { 447 /** 448 * Built-in camera. 449 * @since 9 450 * @syscap SystemCapability.Multimedia.Camera.Core 451 */ 452 CAMERA_CONNECTION_BUILT_IN = 0, 453 454 /** 455 * Camera connected using USB 456 * @since 9 457 * @syscap SystemCapability.Multimedia.Camera.Core 458 */ 459 CAMERA_CONNECTION_USB_PLUGIN = 1, 460 461 /** 462 * Remote camera 463 * @since 9 464 * @syscap SystemCapability.Multimedia.Camera.Core 465 */ 466 CAMERA_CONNECTION_REMOTE = 2 467 } 468 469 /** 470 * Camera device object. 471 * @since 9 472 * @syscap SystemCapability.Multimedia.Camera.Core 473 */ 474 interface CameraDevice { 475 /** 476 * Camera id attribute. 477 * @since 9 478 * @syscap SystemCapability.Multimedia.Camera.Core 479 */ 480 readonly cameraId: string; 481 /** 482 * Camera position attribute. 483 * @since 9 484 * @syscap SystemCapability.Multimedia.Camera.Core 485 */ 486 readonly cameraPosition: CameraPosition; 487 /** 488 * Camera type attribute. 489 * @since 9 490 * @syscap SystemCapability.Multimedia.Camera.Core 491 */ 492 readonly cameraType: CameraType; 493 /** 494 * Camera connection type attribute. 495 * @since 9 496 * @syscap SystemCapability.Multimedia.Camera.Core 497 */ 498 readonly connectionType: ConnectionType; 499 } 500 501 /** 502 * Size parameter. 503 * @since 9 504 * @syscap SystemCapability.Multimedia.Camera.Core 505 */ 506 interface Size { 507 /** 508 * Height. 509 * @since 9 510 * @syscap SystemCapability.Multimedia.Camera.Core 511 */ 512 height: number; 513 /** 514 * Width. 515 * @since 9 516 * @syscap SystemCapability.Multimedia.Camera.Core 517 */ 518 width: number; 519 } 520 521 /** 522 * Point parameter. 523 * @since 9 524 * @syscap SystemCapability.Multimedia.Camera.Core 525 */ 526 interface Point { 527 /** 528 * x co-ordinate 529 * @since 9 530 * @syscap SystemCapability.Multimedia.Camera.Core 531 */ 532 x: number; 533 /** 534 * y co-ordinate 535 * @since 9 536 * @syscap SystemCapability.Multimedia.Camera.Core 537 */ 538 y: number; 539 } 540 541 /** 542 * Camera input object. 543 * @since 9 544 * @syscap SystemCapability.Multimedia.Camera.Core 545 */ 546 interface CameraInput { 547 /** 548 * Open camera. 549 * @param callback Callback used to return the result. 550 * @since 9 551 * @syscap SystemCapability.Multimedia.Camera.Core 552 * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. 553 * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. 554 * @throws { BusinessError } 7400201 - Camera service fatal error. 555 */ 556 open(callback: AsyncCallback<void>): void; 557 558 /** 559 * Open camera. 560 * @returns Promise used to return the result. 561 * @since 9 562 * @syscap SystemCapability.Multimedia.Camera.Core 563 * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. 564 * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. 565 * @throws { BusinessError } 7400201 - Camera service fatal error. 566 */ 567 open(): Promise<void>; 568 569 /** 570 * Close camera. 571 * @param callback Callback used to return the result. 572 * @since 9 573 * @syscap SystemCapability.Multimedia.Camera.Core 574 * @throws { BusinessError } 7400201 - Camera service fatal error. 575 */ 576 close(callback: AsyncCallback<void>): void; 577 578 /** 579 * Close camera. 580 * @returns Promise used to return the result. 581 * @since 9 582 * @syscap SystemCapability.Multimedia.Camera.Core 583 * @throws { BusinessError } 7400201 - Camera service fatal error. 584 */ 585 close(): Promise<void>; 586 587 /** 588 * Subscribes error event callback. 589 * @param type Event type. 590 * @param camera Camera device. 591 * @param callback Callback used to get the camera input errors. 592 * @since 9 593 * @syscap SystemCapability.Multimedia.Camera.Core 594 */ 595 on(type: 'error', camera: CameraDevice, callback: ErrorCallback<BusinessError>): void; 596 } 597 598 /** 599 * Enum for camera format type. 600 * @since 9 601 * @syscap SystemCapability.Multimedia.Camera.Core 602 */ 603 enum CameraFormat { 604 /** 605 * RGBA 8888 Format. 606 * @since 9 607 * @syscap SystemCapability.Multimedia.Camera.Core 608 */ 609 CAMERA_FORMAT_RGBA_8888 = 3, 610 611 /** 612 * YUV 420 Format. 613 * @since 9 614 * @syscap SystemCapability.Multimedia.Camera.Core 615 */ 616 CAMERA_FORMAT_YUV_420_SP = 1003, 617 618 /** 619 * JPEG Format. 620 * @since 9 621 * @syscap SystemCapability.Multimedia.Camera.Core 622 */ 623 CAMERA_FORMAT_JPEG = 2000 624 } 625 626 /** 627 * Enum for flash mode. 628 * @since 9 629 * @syscap SystemCapability.Multimedia.Camera.Core 630 */ 631 enum FlashMode { 632 /** 633 * Close mode. 634 * @since 9 635 * @syscap SystemCapability.Multimedia.Camera.Core 636 */ 637 FLASH_MODE_CLOSE = 0, 638 /** 639 * Open mode. 640 * @since 9 641 * @syscap SystemCapability.Multimedia.Camera.Core 642 */ 643 FLASH_MODE_OPEN = 1, 644 /** 645 * Auto mode. 646 * @since 9 647 * @syscap SystemCapability.Multimedia.Camera.Core 648 */ 649 FLASH_MODE_AUTO = 2, 650 /** 651 * Always open mode. 652 * @since 9 653 * @syscap SystemCapability.Multimedia.Camera.Core 654 */ 655 FLASH_MODE_ALWAYS_OPEN = 3 656 } 657 658 /** 659 * Enum for exposure mode. 660 * @since 9 661 */ 662 enum ExposureMode { 663 /** 664 * Lock exposure mode. 665 * @since 9 666 */ 667 EXPOSURE_MODE_LOCKED = 0, 668 /** 669 * Auto exposure mode. 670 * @since 9 671 */ 672 EXPOSURE_MODE_AUTO = 1, 673 /** 674 * Continuous automatic exposure. 675 * @since 9 676 */ 677 EXPOSURE_MODE_CONTINUOUS_AUTO = 2 678 } 679 680 /** 681 * Enum for focus mode. 682 * @since 9 683 * @syscap SystemCapability.Multimedia.Camera.Core 684 */ 685 enum FocusMode { 686 /** 687 * Manual mode. 688 * @since 9 689 * @syscap SystemCapability.Multimedia.Camera.Core 690 */ 691 FOCUS_MODE_MANUAL = 0, 692 /** 693 * Continuous auto mode. 694 * @since 9 695 * @syscap SystemCapability.Multimedia.Camera.Core 696 */ 697 FOCUS_MODE_CONTINUOUS_AUTO = 1, 698 /** 699 * Auto mode. 700 * @since 9 701 * @syscap SystemCapability.Multimedia.Camera.Core 702 */ 703 FOCUS_MODE_AUTO = 2, 704 /** 705 * Locked mode. 706 * @since 9 707 * @syscap SystemCapability.Multimedia.Camera.Core 708 */ 709 FOCUS_MODE_LOCKED = 3 710 } 711 712 /** 713 * Enum for focus state. 714 * @since 9 715 * @syscap SystemCapability.Multimedia.Camera.Core 716 */ 717 enum FocusState { 718 /** 719 * Scan state. 720 * @since 9 721 * @syscap SystemCapability.Multimedia.Camera.Core 722 */ 723 FOCUS_STATE_SCAN = 0, 724 /** 725 * Focused state. 726 * @since 9 727 * @syscap SystemCapability.Multimedia.Camera.Core 728 */ 729 FOCUS_STATE_FOCUSED = 1, 730 /** 731 * Unfocused state. 732 * @since 9 733 * @syscap SystemCapability.Multimedia.Camera.Core 734 */ 735 FOCUS_STATE_UNFOCUSED = 2 736 } 737 738 /** 739 * Enum for video stabilization mode. 740 * @since 9 741 * @syscap SystemCapability.Multimedia.Camera.Core 742 */ 743 enum VideoStabilizationMode { 744 /** 745 * Turn off video stablization. 746 * @since 9 747 * @syscap SystemCapability.Multimedia.Camera.Core 748 */ 749 OFF = 0, 750 /** 751 * LOW mode provides basic stabilization effect. 752 * @since 9 753 * @syscap SystemCapability.Multimedia.Camera.Core 754 */ 755 LOW = 1, 756 /** 757 * MIDDLE mode means algorithms can achieve better effects than LOW mode. 758 * @since 9 759 * @syscap SystemCapability.Multimedia.Camera.Core 760 */ 761 MIDDLE = 2, 762 /** 763 * HIGH mode means algorithms can achieve better effects than MIDDLE mode. 764 * @since 9 765 * @syscap SystemCapability.Multimedia.Camera.Core 766 */ 767 HIGH = 3, 768 /** 769 * Camera HDF can select mode automatically. 770 * @since 9 771 * @syscap SystemCapability.Multimedia.Camera.Core 772 */ 773 AUTO = 4 774 } 775 776 /** 777 * Capture session object. 778 * @since 9 779 * @syscap SystemCapability.Multimedia.Camera.Core 780 */ 781 interface CaptureSession { 782 /** 783 * Begin capture session config. 784 * @since 9 785 * @syscap SystemCapability.Multimedia.Camera.Core 786 * @throws { BusinessError } 7400105 - Session config locked. 787 */ 788 beginConfig(): void; 789 790 /** 791 * Commit capture session config. 792 * @param callback Callback used to return the result. 793 * @since 9 794 * @syscap SystemCapability.Multimedia.Camera.Core 795 * @throws { BusinessError } 7400102 - Operation not allow. 796 * @throws { BusinessError } 7400201 - Camera service fatal error. 797 */ 798 commitConfig(callback: AsyncCallback<void>): void; 799 800 /** 801 * Commit capture session config. 802 * @returns Promise used to return the result. 803 * @since 9 804 * @syscap SystemCapability.Multimedia.Camera.Core 805 * @throws { BusinessError } 7400102 - Operation not allow. 806 * @throws { BusinessError } 7400201 - Camera service fatal error. 807 */ 808 commitConfig(): Promise<void>; 809 810 /** 811 * Adds a camera input. 812 * @param cameraInput Target camera input to add. 813 * @since 9 814 * @syscap SystemCapability.Multimedia.Camera.Core 815 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 816 * @throws { BusinessError } 7400102 - Operation not allow. 817 */ 818 addInput(cameraInput: CameraInput): void; 819 820 /** 821 * Removes a camera input. 822 * @param cameraInput Target camera input to remove. 823 * @since 9 824 * @syscap SystemCapability.Multimedia.Camera.Core 825 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 826 * @throws { BusinessError } 7400102 - Operation not allow. 827 */ 828 removeInput(cameraInput: CameraInput): void; 829 830 /** 831 * Adds a camera output. 832 * @param cameraOutput Target camera output to add. 833 * @since 9 834 * @syscap SystemCapability.Multimedia.Camera.Core 835 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 836 * @throws { BusinessError } 7400102 - Operation not allow. 837 */ 838 addOutput(cameraOutput: CameraOutput): void; 839 840 /** 841 * Removes a camera output. 842 * @param previewOutput Target camera output to remove. 843 * @since 9 844 * @syscap SystemCapability.Multimedia.Camera.Core 845 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 846 * @throws { BusinessError } 7400102 - Operation not allow. 847 */ 848 removeOutput(cameraOutput: CameraOutput): void; 849 850 /** 851 * Starts capture session. 852 * @param callback Callback used to return the result. 853 * @since 9 854 * @syscap SystemCapability.Multimedia.Camera.Core 855 * @throws { BusinessError } 7400103 - Session not config. 856 * @throws { BusinessError } 7400201 - Camera service fatal error. 857 */ 858 start(callback: AsyncCallback<void>): void; 859 860 /** 861 * Starts capture session. 862 * @returns Promise used to return the result. 863 * @since 9 864 * @syscap SystemCapability.Multimedia.Camera.Core 865 * @throws { BusinessError } 7400103 - Session not config. 866 * @throws { BusinessError } 7400201 - Camera service fatal error. 867 */ 868 start(): Promise<void>; 869 870 /** 871 * Stops capture session. 872 * @param callback Callback used to return the result. 873 * @since 9 874 * @syscap SystemCapability.Multimedia.Camera.Core 875 * @throws { BusinessError } 7400201 - Camera service fatal error. 876 */ 877 stop(callback: AsyncCallback<void>): void; 878 879 /** 880 * Stops capture session. 881 * @returns Promise used to return the result. 882 * @since 9 883 * @syscap SystemCapability.Multimedia.Camera.Core 884 * @throws { BusinessError } 7400201 - Camera service fatal error. 885 */ 886 stop(): Promise<void>; 887 888 /** 889 * Release capture session instance. 890 * @param callback Callback used to return the result. 891 * @since 9 892 * @syscap SystemCapability.Multimedia.Camera.Core 893 * @throws { BusinessError } 7400201 - Camera service fatal error. 894 */ 895 release(callback: AsyncCallback<void>): void; 896 897 /** 898 * Release capture session instance. 899 * @returns Promise used to return the result. 900 * @since 9 901 * @syscap SystemCapability.Multimedia.Camera.Core 902 * @throws { BusinessError } 7400201 - Camera service fatal error. 903 */ 904 release(): Promise<void>; 905 906 /** 907 * Check if device has flash light. 908 * @returns The flash light support status. 909 * @since 9 910 * @syscap SystemCapability.Multimedia.Camera.Core 911 * @throws { BusinessError } 7400103 - Session not config. 912 */ 913 hasFlash(): boolean; 914 915 /** 916 * Checks whether a specified flash mode is supported. 917 * @param flashMode Flash mode 918 * @returns Is the flash mode supported. 919 * @since 9 920 * @syscap SystemCapability.Multimedia.Camera.Core 921 * @throws { BusinessError } 7400103 - Session not config. 922 */ 923 isFlashModeSupported(flashMode: FlashMode): boolean; 924 925 /** 926 * Gets current flash mode. 927 * @returns The current flash mode. 928 * @since 9 929 * @syscap SystemCapability.Multimedia.Camera.Core 930 * @throws { BusinessError } 7400103 - Session not config. 931 */ 932 getFlashMode(): FlashMode; 933 934 /** 935 * Sets flash mode. 936 * @param flashMode Target flash mode. 937 * @since 9 938 * @syscap SystemCapability.Multimedia.Camera.Core 939 * @throws { BusinessError } 7400103 - Session not config. 940 */ 941 setFlashMode(flashMode: FlashMode): void; 942 943 /** 944 * Checks whether a specified exposure mode is supported. 945 * @param aeMode Exposure mode 946 * @returns Is the exposure mode supported. 947 * @since 9 948 * @syscap SystemCapability.Multimedia.Camera.Core 949 * @throws { BusinessError } 7400103 - Session not config. 950 */ 951 isExposureModeSupported(aeMode: ExposureMode): boolean; 952 953 /** 954 * Gets current exposure mode. 955 * @returns The current exposure mode. 956 * @since 9 957 * @syscap SystemCapability.Multimedia.Camera.Core 958 * @throws { BusinessError } 7400103 - Session not config. 959 */ 960 getExposureMode(): ExposureMode; 961 962 /** 963 * Sets Exposure mode. 964 * @param aeMode Exposure mode 965 * @since 9 966 * @syscap SystemCapability.Multimedia.Camera.Core 967 * @throws { BusinessError } 7400103 - Session not config. 968 */ 969 setExposureMode(aeMode: ExposureMode): void; 970 971 /** 972 * Gets current metering point. 973 * @returns The current metering point. 974 * @since 9 975 * @syscap SystemCapability.Multimedia.Camera.Core 976 * @throws { BusinessError } 7400103 - Session not config. 977 */ 978 getMeteringPoint(): Point; 979 980 /** 981 * Set the center point of the metering area. 982 * @param point metering point 983 * @since 9 984 * @syscap SystemCapability.Multimedia.Camera.Core 985 * @throws { BusinessError } 7400103 - Session not config. 986 */ 987 setMeteringPoint(point: Point): void; 988 989 /** 990 * Query the exposure compensation range. 991 * @returns The array of compenstation range. 992 * @since 9 993 * @syscap SystemCapability.Multimedia.Camera.Core 994 * @throws { BusinessError } 7400103 - Session not config. 995 */ 996 getExposureBiasRange(): Array<number>; 997 998 /** 999 * Set exposure compensation. 1000 * @param exposureBias Exposure compensation 1001 * @since 9 1002 * @syscap SystemCapability.Multimedia.Camera.Core 1003 * @throws { BusinessError } 7400103 - Session not config. 1004 */ 1005 setExposureBias(exposureBias: number): void; 1006 1007 /** 1008 * Query the exposure value. 1009 * @returns The exposure value. 1010 * @since 9 1011 * @syscap SystemCapability.Multimedia.Camera.Core 1012 * @throws { BusinessError } 7400103 - Session not config. 1013 */ 1014 getExposureValue(): number; 1015 1016 /** 1017 * Checks whether a specified focus mode is supported. 1018 * @param afMode Focus mode. 1019 * @returns Is the focus mode supported. 1020 * @since 9 1021 * @syscap SystemCapability.Multimedia.Camera.Core 1022 * @throws { BusinessError } 7400103 - Session not config. 1023 */ 1024 isFocusModeSupported(afMode: FocusMode): boolean; 1025 1026 /** 1027 * Gets current focus mode. 1028 * @returns The current focus mode. 1029 * @since 9 1030 * @syscap SystemCapability.Multimedia.Camera.Core 1031 * @throws { BusinessError } 7400103 - Session not config. 1032 */ 1033 getFocusMode(): FocusMode; 1034 1035 /** 1036 * Sets focus mode. 1037 * @param afMode Target focus mode. 1038 * @since 9 1039 * @syscap SystemCapability.Multimedia.Camera.Core 1040 * @throws { BusinessError } 7400103 - Session not config. 1041 */ 1042 setFocusMode(afMode: FocusMode): void; 1043 1044 /** 1045 * Sets focus point. 1046 * @param afMode Target focus point. 1047 * @since 9 1048 * @syscap SystemCapability.Multimedia.Camera.Core 1049 * @throws { BusinessError } 7400103 - Session not config. 1050 */ 1051 setFocusPoint(point: Point): void; 1052 1053 /** 1054 * Gets current focus point. 1055 * @returns The current focus point. 1056 * @since 9 1057 * @syscap SystemCapability.Multimedia.Camera.Core 1058 * @throws { BusinessError } 7400103 - Session not config. 1059 */ 1060 getFocusPoint(): Point; 1061 1062 /** 1063 * Gets current focal length. 1064 * @returns The current focal point. 1065 * @since 9 1066 * @syscap SystemCapability.Multimedia.Camera.Core 1067 * @throws { BusinessError } 7400103 - Session not config. 1068 */ 1069 getFocalLength(): number; 1070 1071 /** 1072 * Gets all supported zoom ratio range. 1073 * @returns The zoom ratio range. 1074 * @since 9 1075 * @syscap SystemCapability.Multimedia.Camera.Core 1076 * @throws { BusinessError } 7400103 - Session not config. 1077 */ 1078 getZoomRatioRange(): Array<number>; 1079 1080 /** 1081 * Gets zoom ratio. 1082 * @returns The zoom ratio value. 1083 * @since 9 1084 * @syscap SystemCapability.Multimedia.Camera.Core 1085 * @throws { BusinessError } 7400103 - Session not config. 1086 */ 1087 getZoomRatio(): number; 1088 1089 /** 1090 * Sets zoom ratio. 1091 * @param zoomRatio Target zoom ratio. 1092 * @since 9 1093 * @syscap SystemCapability.Multimedia.Camera.Core 1094 * @throws { BusinessError } 7400103 - Session not config. 1095 */ 1096 setZoomRatio(zoomRatio: number): void; 1097 1098 /** 1099 * Check whether the specified video stabilization mode is supported. 1100 * @param vsMode Video Stabilization mode. 1101 * @returns Is flash mode supported. 1102 * @since 9 1103 * @syscap SystemCapability.Multimedia.Camera.Core 1104 * @throws { BusinessError } 7400103 - Session not config. 1105 */ 1106 isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean; 1107 1108 /** 1109 * Query the video stabilization mode currently in use. 1110 * @returns The current video stabilization mode. 1111 * @since 9 1112 * @syscap SystemCapability.Multimedia.Camera.Core 1113 * @throws { BusinessError } 7400103 - Session not config. 1114 */ 1115 getActiveVideoStabilizationMode(): VideoStabilizationMode; 1116 1117 /** 1118 * Set video stabilization mode. 1119 * @param mode video stabilization mode to set. 1120 * @since 9 1121 * @syscap SystemCapability.Multimedia.Camera.Core 1122 * @throws { BusinessError } 7400103 - Session not config. 1123 */ 1124 setVideoStabilizationMode(mode: VideoStabilizationMode): void; 1125 1126 /** 1127 * Subscribes focus status change event callback. 1128 * @param type Event type. 1129 * @param callback Callback used to get the focus state change. 1130 * @since 9 1131 * @syscap SystemCapability.Multimedia.Camera.Core 1132 */ 1133 on(type: 'focusStateChange', callback: AsyncCallback<FocusState>): void; 1134 1135 /** 1136 * Subscribes error event callback. 1137 * @param type Event type. 1138 * @param callback Callback used to get the capture session errors. 1139 * @since 9 1140 * @syscap SystemCapability.Multimedia.Camera.Core 1141 */ 1142 on(type: 'error', callback: ErrorCallback<BusinessError>): void; 1143 } 1144 1145 /** 1146 * Camera output object. 1147 * @since 9 1148 * @syscap SystemCapability.Multimedia.Camera.Core 1149 */ 1150 interface CameraOutput { 1151 /** 1152 * Release output instance. 1153 * @param callback Callback used to return the result. 1154 * @since 9 1155 * @syscap SystemCapability.Multimedia.Camera.Core 1156 * @throws { BusinessError } 7400201 - Camera service fatal error. 1157 */ 1158 release(callback: AsyncCallback<void>): void; 1159 1160 /** 1161 * Release output instance. 1162 * @returns Promise used to return the result. 1163 * @since 9 1164 * @syscap SystemCapability.Multimedia.Camera.Core 1165 * @throws { BusinessError } 7400201 - Camera service fatal error. 1166 */ 1167 release(): Promise<void>; 1168 } 1169 1170 /** 1171 * Preview output object. 1172 * @since 9 1173 * @syscap SystemCapability.Multimedia.Camera.Core 1174 */ 1175 interface PreviewOutput extends CameraOutput { 1176 /** 1177 * Start output instance. 1178 * @param callback Callback used to return the result. 1179 * @since 9 1180 * @syscap SystemCapability.Multimedia.Camera.Core 1181 * @throws { BusinessError } 7400103 - Session not config. 1182 */ 1183 start(callback: AsyncCallback<void>): void; 1184 1185 /** 1186 * Start output instance. 1187 * @returns Promise used to return the result. 1188 * @since 9 1189 * @syscap SystemCapability.Multimedia.Camera.Core 1190 * @throws { BusinessError } 7400103 - Session not config. 1191 */ 1192 start(): Promise<void>; 1193 1194 /** 1195 * Stop output instance. 1196 * @param callback Callback used to return the result. 1197 * @since 9 1198 * @syscap SystemCapability.Multimedia.Camera.Core 1199 */ 1200 stop(callback: AsyncCallback<void>): void; 1201 1202 /** 1203 * Stop output instance. 1204 * @returns Promise used to return the result. 1205 * @since 9 1206 * @syscap SystemCapability.Multimedia.Camera.Core 1207 */ 1208 stop(): Promise<void>; 1209 1210 /** 1211 * Subscribes frame start event callback. 1212 * @param type Event type. 1213 * @param callback Callback used to return the result. 1214 * @since 9 1215 * @syscap SystemCapability.Multimedia.Camera.Core 1216 */ 1217 on(type: 'frameStart', callback: AsyncCallback<void>): void; 1218 1219 /** 1220 * Subscribes frame end event callback. 1221 * @param type Event type. 1222 * @param callback Callback used to return the result. 1223 * @since 9 1224 * @syscap SystemCapability.Multimedia.Camera.Core 1225 */ 1226 on(type: 'frameEnd', callback: AsyncCallback<void>): void; 1227 1228 /** 1229 * Subscribes error event callback. 1230 * @param type Event type. 1231 * @param callback Callback used to get the preview output errors. 1232 * @since 9 1233 * @syscap SystemCapability.Multimedia.Camera.Core 1234 */ 1235 on(type: 'error', callback: ErrorCallback<BusinessError>): void; 1236 } 1237 1238 /** 1239 * Enumerates the image rotation angles. 1240 * @since 9 1241 * @syscap SystemCapability.Multimedia.Camera.Core 1242 */ 1243 enum ImageRotation { 1244 /** 1245 * The capture image rotates 0 degrees. 1246 * @since 9 1247 * @syscap SystemCapability.Multimedia.Camera.Core 1248 */ 1249 ROTATION_0 = 0, 1250 1251 /** 1252 * The capture image rotates 90 degrees. 1253 * @since 9 1254 * @syscap SystemCapability.Multimedia.Camera.Core 1255 */ 1256 ROTATION_90 = 90, 1257 1258 /** 1259 * The capture image rotates 180 degrees. 1260 * @since 9 1261 * @syscap SystemCapability.Multimedia.Camera.Core 1262 */ 1263 ROTATION_180 = 180, 1264 1265 /** 1266 * The capture image rotates 270 degrees. 1267 * @since 9 1268 * @syscap SystemCapability.Multimedia.Camera.Core 1269 */ 1270 ROTATION_270 = 270 1271 } 1272 1273 interface Location { 1274 /** 1275 * Latitude. 1276 * @since 9 1277 */ 1278 latitude: number; 1279 1280 /** 1281 * Longitude. 1282 * @since 9 1283 */ 1284 longitude: number; 1285 1286 /** 1287 * Altitude. 1288 * @since 9 1289 */ 1290 altitude: number; 1291 } 1292 1293 /** 1294 * Enumerates the image quality levels. 1295 * @since 9 1296 * @syscap SystemCapability.Multimedia.Camera.Core 1297 */ 1298 enum QualityLevel { 1299 /** 1300 * High image quality. 1301 * @since 9 1302 * @syscap SystemCapability.Multimedia.Camera.Core 1303 */ 1304 QUALITY_LEVEL_HIGH = 0, 1305 1306 /** 1307 * Medium image quality. 1308 * @since 9 1309 * @syscap SystemCapability.Multimedia.Camera.Core 1310 */ 1311 QUALITY_LEVEL_MEDIUM = 1, 1312 1313 /** 1314 * Low image quality. 1315 * @since 9 1316 * @syscap SystemCapability.Multimedia.Camera.Core 1317 */ 1318 QUALITY_LEVEL_LOW = 2 1319 } 1320 1321 /** 1322 * Photo capture options to set. 1323 * @since 9 1324 */ 1325 interface PhotoCaptureSetting { 1326 /** 1327 * Photo image quality. 1328 * @since 9 1329 * @syscap SystemCapability.Multimedia.Camera.Core 1330 */ 1331 quality?: QualityLevel; 1332 1333 /** 1334 * Photo rotation. 1335 * @since 9 1336 * @syscap SystemCapability.Multimedia.Camera.Core 1337 */ 1338 rotation?: ImageRotation; 1339 1340 /** 1341 * Photo location. 1342 * @since 9 1343 * @syscap SystemCapability.Multimedia.Camera.Core 1344 */ 1345 location?: Location; 1346 1347 /** 1348 * Set the mirror photo function switch, default to false. 1349 * @since 9 1350 * @syscap SystemCapability.Multimedia.Camera.Core 1351 */ 1352 mirror?: boolean; 1353 } 1354 1355 /** 1356 * Photo output object. 1357 * @since 9 1358 * @syscap SystemCapability.Multimedia.Camera.Core 1359 */ 1360 interface PhotoOutput extends CameraOutput { 1361 /** 1362 * Start capture output. 1363 * @param callback Callback used to return the result. 1364 * @since 9 1365 * @syscap SystemCapability.Multimedia.Camera.Core 1366 * @throws { BusinessError } 7400104 - Session not running. 1367 * @throws { BusinessError } 7400201 - Camera service fatal error. 1368 */ 1369 capture(callback: AsyncCallback<void>): void; 1370 1371 /** 1372 * Start capture output. 1373 * @returns Promise used to return the result. 1374 * @since 9 1375 * @syscap SystemCapability.Multimedia.Camera.Core 1376 * @throws { BusinessError } 7400104 - Session not running. 1377 * @throws { BusinessError } 7400201 - Camera service fatal error. 1378 */ 1379 capture(): Promise<void>; 1380 1381 /** 1382 * Start capture output. 1383 * @param setting Photo capture settings. 1384 * @param callback Callback used to return the result. 1385 * @since 9 1386 * @syscap SystemCapability.Multimedia.Camera.Core 1387 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 1388 * @throws { BusinessError } 7400104 - Session not running. 1389 * @throws { BusinessError } 7400201 - Camera service fatal error. 1390 */ 1391 capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void>): void; 1392 1393 /** 1394 * Start capture output. 1395 * @param setting Photo capture settings. 1396 * @returns Promise used to return the result. 1397 * @since 9 1398 * @syscap SystemCapability.Multimedia.Camera.Core 1399 * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect 1400 * @throws { BusinessError } 7400104 - Session not running. 1401 * @throws { BusinessError } 7400201 - Camera service fatal error. 1402 */ 1403 capture(setting?: PhotoCaptureSetting): Promise<void>; 1404 1405 /** 1406 * Check whether to support mirror photo. 1407 * @returns Is the mirror supported. 1408 * @since 9 1409 * @syscap SystemCapability.Multimedia.Camera.Core 1410 */ 1411 isMirrorSupported(): boolean; 1412 1413 /** 1414 * Subscribes capture start event callback. 1415 * @param type Event type. 1416 * @param callback Callback used to get the capture ID. 1417 * @since 9 1418 * @syscap SystemCapability.Multimedia.Camera.Core 1419 */ 1420 on(type: 'captureStart', callback: AsyncCallback<number>): void; 1421 1422 /** 1423 * Subscribes frame shutter event callback. 1424 * @param type Event type. 1425 * @param callback Callback used to get the frame shutter information. 1426 * @since 9 1427 * @syscap SystemCapability.Multimedia.Camera.Core 1428 */ 1429 on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo>): void; 1430 1431 /** 1432 * Subscribes capture end event callback. 1433 * @param type Event type. 1434 * @param callback Callback used to get the capture end information. 1435 * @since 9 1436 * @syscap SystemCapability.Multimedia.Camera.Core 1437 */ 1438 on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo>): void; 1439 1440 /** 1441 * Subscribes error event callback. 1442 * @param type Event type. 1443 * @param callback Callback used to get the photo output errors. 1444 * @since 9 1445 * @syscap SystemCapability.Multimedia.Camera.Core 1446 */ 1447 on(type: 'error', callback: ErrorCallback<BusinessError>): void; 1448 } 1449 1450 /** 1451 * Frame shutter callback info. 1452 * @since 9 1453 * @syscap SystemCapability.Multimedia.Camera.Core 1454 */ 1455 interface FrameShutterInfo { 1456 /** 1457 * Capture id. 1458 * @since 9 1459 * @syscap SystemCapability.Multimedia.Camera.Core 1460 */ 1461 captureId: number; 1462 /** 1463 * Timestamp for frame. 1464 * @since 9 1465 * @syscap SystemCapability.Multimedia.Camera.Core 1466 */ 1467 timestamp: number; 1468 } 1469 1470 /** 1471 * Capture end info. 1472 * @since 9 1473 * @syscap SystemCapability.Multimedia.Camera.Core 1474 */ 1475 interface CaptureEndInfo { 1476 /** 1477 * Capture id. 1478 * @since 9 1479 * @syscap SystemCapability.Multimedia.Camera.Core 1480 */ 1481 captureId: number; 1482 /** 1483 * Frame count. 1484 * @since 9 1485 * @syscap SystemCapability.Multimedia.Camera.Core 1486 */ 1487 frameCount: number; 1488 } 1489 1490 /** 1491 * Video output object. 1492 * @since 9 1493 * @syscap SystemCapability.Multimedia.Camera.Core 1494 */ 1495 interface VideoOutput extends CameraOutput { 1496 /** 1497 * Start video output. 1498 * @param callback Callback used to return the result. 1499 * @since 9 1500 * @syscap SystemCapability.Multimedia.Camera.Core 1501 * @throws { BusinessError } 7400103 - Session not config. 1502 * @throws { BusinessError } 7400201 - Camera service fatal error. 1503 */ 1504 start(callback: AsyncCallback<void>): void; 1505 1506 /** 1507 * Start video output. 1508 * @returns Promise used to return the result. 1509 * @since 9 1510 * @syscap SystemCapability.Multimedia.Camera.Core 1511 * @throws { BusinessError } 7400103 - Session not config. 1512 * @throws { BusinessError } 7400201 - Camera service fatal error. 1513 */ 1514 start(): Promise<void>; 1515 1516 /** 1517 * Stop video output. 1518 * @param callback Callback used to return the result. 1519 * @since 9 1520 * @syscap SystemCapability.Multimedia.Camera.Core 1521 */ 1522 stop(callback: AsyncCallback<void>): void; 1523 1524 /** 1525 * Stop video output. 1526 * @returns Promise used to return the result. 1527 * @since 9 1528 * @syscap SystemCapability.Multimedia.Camera.Core 1529 */ 1530 stop(): Promise<void>; 1531 1532 /** 1533 * Subscribes frame start event callback. 1534 * @param type Event type. 1535 * @param callback Callback used to return the result. 1536 * @since 9 1537 * @syscap SystemCapability.Multimedia.Camera.Core 1538 */ 1539 on(type: 'frameStart', callback: AsyncCallback<void>): void; 1540 1541 /** 1542 * Subscribes frame end event callback. 1543 * @param type Event type. 1544 * @param callback Callback used to return the result. 1545 * @since 9 1546 * @syscap SystemCapability.Multimedia.Camera.Core 1547 */ 1548 on(type: 'frameEnd', callback: AsyncCallback<void>): void; 1549 1550 /** 1551 * Subscribes error event callback. 1552 * @param type Event type. 1553 * @param callback Callback used to get the video output errors. 1554 * @since 9 1555 * @syscap SystemCapability.Multimedia.Camera.Core 1556 */ 1557 on(type: 'error', callback: ErrorCallback<BusinessError>): void; 1558 } 1559 1560 /** 1561 * Metadata object type. 1562 * @since 9 1563 * @syscap SystemCapability.Multimedia.Camera.Core 1564 */ 1565 enum MetadataObjectType { 1566 FACE_DETECTION = 0 1567 } 1568 1569 /** 1570 * Rectangle definition. 1571 * @since 9 1572 * @syscap SystemCapability.Multimedia.Camera.Core 1573 */ 1574 interface Rect { 1575 /** 1576 * X coordinator of top left point. 1577 * @param Promise used to return the result. 1578 * @since 9 1579 * @syscap SystemCapability.Multimedia.Camera.Core 1580 */ 1581 topLeftX: number; 1582 /** 1583 * Y coordinator of top left point. 1584 * @param Promise used to return the result. 1585 * @since 9 1586 * @syscap SystemCapability.Multimedia.Camera.Core 1587 */ 1588 topLeftY: number; 1589 /** 1590 * Width of this rectangle. 1591 * @since 9 1592 * @syscap SystemCapability.Multimedia.Camera.Core 1593 */ 1594 width: number; 1595 /** 1596 * Height of this rectangle. 1597 * @since 9 1598 * @syscap SystemCapability.Multimedia.Camera.Core 1599 */ 1600 height: number; 1601 } 1602 1603 /** 1604 * Metadata object basis. 1605 * @since 9 1606 * @syscap SystemCapability.Multimedia.Camera.Core 1607 */ 1608 interface MetadataObject { 1609 /** 1610 * Metadata object type. 1611 * @since 9 1612 * @syscap SystemCapability.Multimedia.Camera.Core 1613 */ 1614 readonly type: MetadataObjectType; 1615 /** 1616 * Metadata object timestamp in milliseconds. 1617 * @since 9 1618 * @syscap SystemCapability.Multimedia.Camera.Core 1619 */ 1620 readonly timestamp: number; 1621 /** 1622 * The axis-aligned bounding box of detected metadata object. 1623 * @since 9 1624 * @syscap SystemCapability.Multimedia.Camera.Core 1625 */ 1626 readonly boundingBox: Rect; 1627 } 1628 1629 /** 1630 * Metadata Output object 1631 * @since 9 1632 * @syscap SystemCapability.Multimedia.Camera.Core 1633 */ 1634 interface MetadataOutput extends CameraOutput { 1635 /** 1636 * Start output metadata 1637 * @param callback Callback used to return the result. 1638 * @since 9 1639 * @syscap SystemCapability.Multimedia.Camera.Core 1640 * @throws { BusinessError } 7400103 - Session not config. 1641 * @throws { BusinessError } 7400201 - Camera service fatal error. 1642 */ 1643 start(callback: AsyncCallback<void>): void; 1644 1645 /** 1646 * Start output metadata 1647 * @returns Promise used to return the result. 1648 * @since 9 1649 * @syscap SystemCapability.Multimedia.Camera.Core 1650 * @throws { BusinessError } 7400103 - Session not config. 1651 * @throws { BusinessError } 7400201 - Camera service fatal error. 1652 */ 1653 start(): Promise<void>; 1654 1655 /** 1656 * Stop output metadata 1657 * @param callback Callback used to return the result. 1658 * @since 9 1659 * @syscap SystemCapability.Multimedia.Camera.Core 1660 */ 1661 stop(callback: AsyncCallback<void>): void; 1662 1663 /** 1664 * Stop output metadata 1665 * @returns Promise used to return the result. 1666 * @since 9 1667 * @syscap SystemCapability.Multimedia.Camera.Core 1668 */ 1669 stop(): Promise<void>; 1670 1671 /** 1672 * Subscribes to metadata objects available event callback. 1673 * @param type Event type. 1674 * @param callback Callback used to get the available metadata objects. 1675 * @since 9 1676 * @syscap SystemCapability.Multimedia.Camera.Core 1677 */ 1678 on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject>>): void; 1679 1680 /** 1681 * Subscribes error event callback. 1682 * @param type Event type. 1683 * @param callback Callback used to get the video output errors. 1684 * @since 9 1685 * @syscap SystemCapability.Multimedia.Camera.Core 1686 */ 1687 on(type: 'error', callback: ErrorCallback<BusinessError>): void; 1688 } 1689} 1690 1691export default camera; 1692