harmony 鸿蒙Use Case

  • 2022-08-09
  • 浏览 (787)

Use Case

This use case takes camera_sample (contained in the source code) as an example for photographing, recording, and previewing on the development board.

  • You can obtain source code of the sample from applications/sample/camera/media/camera_sample.cpp.

  • Before running the sample camera, you need to compile, burn, and run the image. For details, see Quick Start Overview.

    NOTE
    After the development board is started, the home screen is loaded and displayed above the media layer by default. To prevent covering camera_sample, you should remove the home screen during compilation or packaging. How to Remove: In build/lite/components/applications.json, comment out or delete the //applications/sample/camera/launcher:launcher_hap line from the target field of camera_sample_app.

  • The compilation result of the sample code is stored in out/hi3516dv300/ipcamera_hi3516dv300_liteos/dev_tools/bin. To ensure that the code can be executed on the development board, you can copy the file to a TF card through a card reader, or modify the compilation script of camera_sample to copy the compilation result to rootfs.img.

    Modify the first output_dir in the source code path applications/sample/camera/media/BUILD.gn.

    • Before: output_dir = “$root_out_dir/dev_ools”
    • After: output_dir = “$root_out_dir/”

    Recompile the source code repository and burn the code into the development board. Then you can find the camera_sample file in the bin directory of the board.

    NOTICE
    You should insert a TF card (up to 128 GB supported) for photographing and video recording before system startup. This way, the TF card will be automatically mounted to the /sdcard directory. If you insert the TF card after the system is started, you have to manually mount the TF card. To view the photos and videos in the TF card, copy them to a computer. If you just want to preview photos and videos, you do not need to insert a TF card.

  • Perform the following steps to run the sample:

  • Run the cd command to go to the end path of the executable program and start camera_sample by running the command in the following figure.

    Figure 1 Starting camera_sample

    The control commands are displayed as shown in the preceding figure. Press S to stop the current operation (including video recording and preview), and press Q to exit the program.

  • Press 1 to take a photo in JPG format. The photo is saved in the /sdcard directory and named Capture*.

    Figure 2 Serial port logs displayed after the photographing command is executed

    To view the saved file, exit the program and enter the file system. To start the program again, return to the previous step.

    Figure 3 Saved files

  • Press 2 to start recording. The video file is in MP4 format and saved in the /sdcard directory with the name Record*. Press S to stop recording.

    Figure 4 Serial port logs displayed after the recording command is executed

  • Press 3 to start preview. The preview is displayed on the screen. Press S to stop preview.

    Figure 5 Serial port logs displayed after the preview command is executed

    The following figure shows the preview.

    Figure 6 Preview effect

  • Press Q to exit.

    Figure 7 Serial port logs displayed after the exit command is executed

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Development Examples

harmony 鸿蒙Photographing

harmony 鸿蒙Previewing

harmony 鸿蒙Video Recording

harmony 鸿蒙Screen and Camera Control Overview

harmony 鸿蒙Adding Pages

harmony 鸿蒙Debugging and Packaging

harmony 鸿蒙Building the Details Page

harmony 鸿蒙FAQs

harmony 鸿蒙Building the Home Page

0  赞