Skip to content

Commit

Permalink
Merge pull request #21 from HyperInspire/feature/sub
Browse files Browse the repository at this point in the history
Feature/sub
  • Loading branch information
tunmx authored May 5, 2024
2 parents 9ff8850 + 147ae6a commit 43de275
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 22 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test_ubuntu_x86_Pikachu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This GitHub Actions workflow is designed for a CMake project running on a single platform (Ubuntu-x86).
# For multi-platform testing, see the link provided.
# Refer to: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Run Ubuntu-x86 Test Pikachu

# Trigger this workflow on push or pull request to the "feature/sub" branch
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

# Define environment variables shared across jobs
env:
# Set the CMake build type (e.g., Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

# Jobs section defines all individual tasks for the CI workflow
jobs:
build:
# Specify that this job should run on the latest Ubuntu environment provided by GitHub
runs-on: ubuntu-latest

# Define steps for this job
steps:
# Step 1: Check out the code from the repository
- uses: actions/checkout@v4

# Step 2: Update Git submodules recursively
- name: Update submodules
run: |
git submodule sync --recursive # Ensure submodule paths are up-to-date
git submodule update --init --recursive # Initialize and update all submodules
# Step 3: Install necessary dependencies for building the CMake project
- name: Install dependencies
run: |
sudo apt-get update # Update package lists
# Install build tools and required libraries for video processing
sudo apt-get install -y build-essential libgtk-3-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev
# Step 4: Run a separate script for CMake configuration and building
- name: Download Dataset And Configure CMake
# Execute a pre-existing script to handle CMake configuration and building
# The script is assumed to be located at `ci/ci_linux_x86_usual.sh`
run: bash ci/ci_linux_x86_usual.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ test_zip_*
test_res/*
resource/*
pack/*
*.zip
2 changes: 1 addition & 1 deletion 3rdparty/inspireface-precompile
Empty file added ci/README.md
Empty file.
69 changes: 69 additions & 0 deletions ci/ci_linux_x86_usual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# Exit immediately if any command exits with a non-zero status
set -e

TARGET_DIR="test_res"
DOWNLOAD_URL="https://github.com/tunmx/inspireface-store/raw/main/resource/test_res-lite.zip"
ZIP_FILE="test_res-lite.zip"
BUILD_DIRNAME="ci_ubuntu18"
TEST_DIR="./build/${BUILD_DIRNAME}/test"
TEST_EXECUTABLE="./test/Test"

# Check if the target directory already exists
if [ ! -d "$TARGET_DIR" ]; then
echo "Directory '$TARGET_DIR' does not exist. Downloading..."

# Download the dataset zip file
wget -q "$DOWNLOAD_URL" -O "$ZIP_FILE"

echo "Extracting '$ZIP_FILE' to '$TARGET_DIR'..."
# Unzip the downloaded file
unzip "$ZIP_FILE"

# Remove the downloaded zip file and unnecessary folders
rm "$ZIP_FILE"
rm -rf "__MACOSX"

echo "Download and extraction complete."
else
echo "Directory '$TARGET_DIR' already exists. Skipping download."
fi

# Get the absolute path of the target directory
FULL_TEST_DIR="$(realpath ${TARGET_DIR})"

# Create the build directory if it doesn't exist
mkdir -p build/${BUILD_DIRNAME}/

# Change directory to the build directory
# Disable the shellcheck warning for potential directory changes
# shellcheck disable=SC2164
cd build/${BUILD_DIRNAME}/

# Configure the CMake build system
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=ON \
-DISF_ENABLE_BENCHMARK=ON \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 \
-DISF_BUILD_SHARED_LIBS=OFF ../../

# Compile the project using 4 parallel jobs
make -j4

# Create a symbolic link to the extracted test data directory
ln -s ${FULL_TEST_DIR} .

# Check if the test executable file exists
if [ ! -f "$TEST_EXECUTABLE" ]; then
# If not, print an error message and exit with a non-zero status code
echo "Error: Test executable '$TEST_EXECUTABLE' not found. Please ensure it is built correctly."
exit 1
else
# If it exists, print a message and run the test executable
echo "Test executable found. Running tests..."
"$TEST_EXECUTABLE"
fi
15 changes: 15 additions & 0 deletions command/build_linux_ubuntu18_opencv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
mkdir -p build/linux_x86_ubuntu18_opencv/
# shellcheck disable=SC2164
cd build/linux_x86_ubuntu18_opencv
# export cross_compile_toolchain=/home/s4129/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 \
-DISF_BUILD_SHARED_LIBS=ON ../../

make -j4
make install
9 changes: 1 addition & 8 deletions cpp/inspireface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ option(ISF_BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON)
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
set(SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/c_api/inspireface.cc) # Add C_API file


if(NOT APPLE)
find_package(OpenCV REQUIRED)
endif()


if (ISF_ENABLE_RKNN)
set(ISF_RKNN_API_INCLUDE_DIRS ${ISF_THIRD_PARTY_DIR}/inspireface-precompile/rknn/${ISF_RKNPU_MAJOR}/runtime/${ISF_RK_DEVICE_TYPE}/Linux/librknn_api/include)
set(ISF_RKNN_API_LIB ${ISF_THIRD_PARTY_DIR}/inspireface-precompile/rknn/${ISF_RKNPU_MAJOR}/runtime/${ISF_RK_DEVICE_TYPE}/Linux/librknn_api/${CPU_ARCH}/)
Expand All @@ -43,7 +37,6 @@ set(LINK_THIRD_LIBS ${OpenCV_LIBS} ${MNN_LIBS})
# sqlite3
set(SOURCE_FILES ${SOURCE_FILES} ${ISF_THIRD_PARTY_DIR}/inspireface-precompile/sqlite/sqlite3.c) # Add C_API file
set(SQLITE_INCLUDE ${ISF_THIRD_PARTY_DIR}/inspireface-precompile/sqlite/)
include_directories(${SQLITE_INCLUDE})

if (ISF_ENABLE_RKNN)
set(LINK_THIRD_LIBS ${LINK_THIRD_LIBS} rknn_api dl)
Expand Down Expand Up @@ -82,7 +75,7 @@ if (ISF_BUILD_LINUX_ARM7)
endif ()

# add cpp yaml header
set(NEED_INCLUDE ${NEED_INCLUDE} ${CPP_YAML_INCLUDE})
set(NEED_INCLUDE ${NEED_INCLUDE} ${CPP_YAML_INCLUDE} ${SQLITE_INCLUDE})

if(PLAT STREQUAL "linux")
find_package(Threads REQUIRED)
Expand Down
6 changes: 0 additions & 6 deletions cpp/sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ project(InspireFaceSample)

option(ISF_BUILD_SAMPLE_CLUTTERED "Whether to compile the cluttered sample program (debug code during development)" OFF)

# OpenCV Configuration
if(NOT APPLE)
# message(STATUS OpenCV_DIR=${OpenCV_DIR})
find_package(OpenCV REQUIRED)
endif()

include_directories(${SRC_DIR})

if (ISF_ENABLE_RKNN)
Expand Down
7 changes: 0 additions & 7 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ if (ISF_ENABLE_TEST_EVALUATION)
add_definitions("-DISF_ENABLE_TEST_EVALUATION")
endif ()

# OpenCV Configuration
if(NOT APPLE)
# message(STATUS OpenCV_DIR=${OpenCV_DIR})
find_package(OpenCV REQUIRED)
endif()


if (ISF_ENABLE_RKNN)
set(DEPEND rknn_api dl)
set(ISF_RKNN_API_LIB ${ISF_THIRD_PARTY_DIR}/${ISF_RKNPU_MAJOR}/runtime/${ISF_RK_DEVICE_TYPE}/Linux/librknn_api/${CPU_ARCH}/)
Expand Down

0 comments on commit 43de275

Please sign in to comment.