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