1e41f4b71Sopenharmony_ci# Use Case<a name="EN-US_TOPIC_0000001055301733"></a>
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThis use case takes **camera\_sample** \(contained in the source code\) as an example for photographing, recording, and previewing on the development board.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci-   You can obtain source code of the sample from **applications/sample/camera/media/camera\_sample.cpp**.
6e41f4b71Sopenharmony_ci-   Before running the sample camera, you need to compile, burn, and run the image. For details, see  [Quick Start Overview](../quick-start/quickstart-overview.md).
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci    >![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
9e41f4b71Sopenharmony_ci    >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.
10e41f4b71Sopenharmony_ci    >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**.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci-   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**.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci    Modify the first **output\_dir** in the source code path **applications/sample/camera/media/BUILD.gn**.
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci    -   Before: **output\_dir = "$root\_out\_dir/dev\_ools"**
17e41f4b71Sopenharmony_ci    -   After: **output\_dir = "$root\_out\_dir/"**
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci    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.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci    >![](../public_sys-resources/icon-notice.gif) **NOTICE**<br/>
22e41f4b71Sopenharmony_ci    >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.
23e41f4b71Sopenharmony_ci    >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.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci-   Perform the following steps to run the sample:
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci1.  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.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci    **Figure 1** Starting camera\_sample<a name="fig380985885020"></a>  
30e41f4b71Sopenharmony_ci    ![](figures/starting-camera_sample.png "starting-camera_sample")
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci    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.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci2.  Press **1** to take a photo in JPG format. The photo is saved in the **/sdcard** directory and named **Capture\***.
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci    **Figure 2** Serial port logs displayed after the photographing command is executed<a name="fig17819185018384"></a>  
37e41f4b71Sopenharmony_ci    ![](figures/serial-port-logs-displayed-after-the-photographing-command-is-executed.png "serial-port-logs-displayed-after-the-photographing-command-is-executed")
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci    To view the saved file, exit the program and enter the file system. To start the program again, return to the previous step.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci    **Figure  3** Saved files<a name="fig166391743154619"></a>  
42e41f4b71Sopenharmony_ci    ![](figures/saved-files.png "saved-files")
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci3.  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.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci    **Figure 4** Serial port logs displayed after the recording command is executed<a name="fig6340814174317"></a>  
47e41f4b71Sopenharmony_ci    ![](figures/serial-port-logs-displayed-after-the-recording-command-is-executed.png "serial-port-logs-displayed-after-the-recording-command-is-executed")
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci4.  Press **3** to start preview. The preview is displayed on the screen. Press **S** to stop preview.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci    **Figure 5** Serial port logs displayed after the preview command is executed<a name="fig9658148124414"></a>  
52e41f4b71Sopenharmony_ci    ![](figures/serial-port-logs-displayed-after-the-preview-command-is-executed.png "serial-port-logs-displayed-after-the-preview-command-is-executed")
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci    The following figure shows the preview.
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci    **Figure 6** Preview effect<a name="fig24541759597"></a>  
57e41f4b71Sopenharmony_ci    ![](figures/preview-effect.jpg "preview-effect")
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci5.  Press **Q** to exit.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci    **Figure 7** Serial port logs displayed after the exit command is executed<a name="fig1755682174514"></a>  
62e41f4b71Sopenharmony_ci    ![](figures/serial-port-logs-displayed-after-the-exit-command-is-executed.png "serial-port-logs-displayed-after-the-exit-command-is-executed")
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci
65