Skip to content

Public CI OpenCV Shell Scripts #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Runner/suites/Multimedia/OpenCV/README_OpenCV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# OpenCV Test Script for Qualcomm Linux based platform (Yocto)

## Overview

OpenCV Test Scripts automates the validation of one of the OpenCV APIs functionality on the Qualcomm Linux based platform running a Yocto-based Linux system.

## Features

- OpenCV core module - ARITHM API
- accuracy test from ARITHM API

## Prerequisites

Ensure the following components are present in the target Yocto build:

- Compiling the OpenCV Binaries.
- set up the build from Qualcomm Linux buid guide
- To enable the tests package, include tests in PACKAGECONFIG in the
<workspace>/layers/meta-qcom-hwe/recipes-support/opencv/opencv_4.11.0.qcom.bb recipe file as follows.

PACKAGECONFIG ??= "gapi python3 eigen jpeg png tiff v4l libv4l
samples tbb gphoto2 tests \
${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \

- To retain test bins, include the following code in the
<workspace>/layers/meta-qcom-hwe/recipes-support/opencv/opencv_4.11.0.qcom.bb recipe file:

RM_WORK_EXCLUDE += "opencv"

- To Clean OpenCV, run the below command :

bitbake -fc cleanall opencv

- To compile OpenCV, run the following command:

bitbake opencv

- The path to OpenCV bins will be below :

tmp-glibc\work\armv8-2a-qcom-linux\opencv\4.11.0.qcom\build\bin

- Use the scp command to push the required test bin to /usr/bin. ( Test bin should be pushed to /usr/bin/ )

For example: scp -r opencv_test_core root@[IP-ADDR]:/usr/bin/


## Directory Structure

```bash
Runner/
├── suites/
│ ├── Multimedia/
│ │ ├── OpenCV/
│ │ │ ├── run.sh

```

## Usage


Instructions

1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.

2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.

3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.

Run a specific test using:
---
Quick Example
```
git clone <this-repo>
cd <this-repo>
scp -r common Runner user@target_device_ip:/<Path in device>
ssh user@target_device_ip
cd <Path in device>Runner && ./run-test.sh
```
Sample output:
```
sh-5.2# cd <Path in device>/Runner && ./run-test.sh OpenCV
[Executing test case: /<Path in device>/Runner/suites/Multimedia/OpenCV/] 1980-01-09 01:31:15 -
[INFO] 1980-01-09 01:31:15 - -----------------------------------------------------------------------------------------
[INFO] 1980-01-09 01:31:15 - -------------------Starting Opencv_core Testcase----------------------------
[INFO] 1980-01-09 01:31:15 - Checking if dependency binary is available
[PASS] 1980-01-08 01:31:15 - Test related dependencies are present.
...
[PASS] 1980-01-09 22:31:16 - Opencv_core : Test Passed
[INFO] 1980-01-09 22:31:16 - -------------------Completed Opencv_core Testcase----------------------------
```

## Notes

- The script does not take any arguments.
- It validates the presence of required libraries before executing tests.
- If any critical tool is missing, the script exits with an error message.

## License

SPDX-License-Identifier: BSD-3-Clause-Clear
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright is missing

58 changes: 58 additions & 0 deletions Runner/suites/Multimedia/OpenCV/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# --------- Robustly source init_env and functestlib.sh ----------
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

if [ -z "$__INIT_ENV_LOADED" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"
# ---------------------------------------------------------------

TESTNAME="Opencv_core"
test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1

log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"


log_info "Checking if dependency binary is available"
check_dependencies opencv_test_core grep chmod

# Navigate to the directory where the fastrpc_test application is located
chmod 755 /usr/bin/opencv_test_core
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preinstalled bins have necessary execute permissions under the $PATH env dirs. Is it still required to give these permissions?


# Execute the command and capture the output
export OPENCV_OPENCL_RUNTIME=disabled && /usr/bin/opencv_test_core --gtest_filter=Core_AddMixed/ArithmMixedTest.accuracy/0 > opencv_core_result.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolute path is required here.


# Check the log file for the string "SUCCESS" to determine if the test passed
if grep -q "PASSED" opencv_core_result.txt; then
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
else
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
fi

# Print the completion of the test case
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Loading