1*** Variables ***
2${URI}                              @https://dl.antmicro.com/projects/renode
3
4*** Keywords ***
5Should Run Detection
6    Wait For Line On Uart           Attempting to start Arducam
7    Wait For Line On Uart           Starting capture
8    Wait For Line On Uart           Image captured
9    Wait For Line On Uart           Reading \\d+ bytes from Arducam                   treatAsRegex=true
10    Wait For Line On Uart           Finished reading
11    Wait For Line On Uart           Decoding JPEG and converting to greyscale
12    Wait For Line On Uart           Image decoded and processed
13    ${l}=  Wait For Line On Uart    Person score: (\\d+) No person score: (\\d+)      treatAsRegex=true
14    ${s}=  Evaluate                 int(${l.groups[0]}) - int(${l.groups[1]})
15
16    RETURN                          ${s}
17
18Run Test
19    [Arguments]                     ${image}
20
21    Execute Command                 Clear
22    Execute Command                 mach create
23    Execute Command                 machine LoadPlatformDescription @platforms/boards/arduino_nano_33_ble.repl
24    Execute Command                 sysbus LoadELF ${URI}/nrf52840--tf_person_detection.elf-s_7574264-cf1fccf46719c4a60e0df957a1304f17c5647011
25
26    Create Terminal Tester          sysbus.uart0
27    Execute Command                 sysbus.spi2.camera ImageSource @${image}
28    Start Emulation
29
30Detect Template
31    [Arguments]         ${image}
32
33    Run Test            ${image}
34    ${r}=  Should Run Detection
35    Should Be True                  ${r} > 100
36
37No Detect Template
38    [Arguments]         ${image}
39
40    Run Test            ${image}
41    ${r}=  Should Run Detection
42    Should Be True                  ${r} < -100
43
44*** Test Cases ***
45Should Detect Person
46    [Template]                      Detect Template
47
48    ${URI}/images/person_image_0.jpg-s_3853-7f2125e28423fa117a1079d84785b17c9b70f62d
49    ${URI}/images/person_image_1.jpg-s_3836-25216268e08894d0dda13107ad1ad5f537ad19c2
50
51Should Not Detect Person
52    [Template]                      No Detect Template
53
54    ${URI}/images/no_person_image_0.jpg-s_3787-3bed5184fbf005cbb0b6bf18e8885874ca7273bd
55    ${URI}/images/no_person_image_1.jpg-s_3910-81edff305382b42f3b98e3764921574e1b9142fe
56
57