optimize ci for maixcam2

This commit is contained in:
Neucrack
2025-09-30 16:15:22 +08:00
parent 889190b7fb
commit 07edcd0603
8 changed files with 72 additions and 283 deletions

View File

@@ -58,7 +58,7 @@ jobs:
echo "------------------------------------"
cd ../../projects
chmod +x build_all.sh
./build_all.sh
./build_all.sh maixcam
- name: Build doc
run: |

71
.github/workflows/build_maixcam2.yml vendored Executable file
View File

@@ -0,0 +1,71 @@
# This is a basic workflow to help you get started with Actions
name: Build test for MaixCAM2
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# permissions: write-all
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# Only run job for specific repository
if: github.repository == 'sipeed/MaixCDK'
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"] # MaixCAM2 use 3.13
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build MaixCDK Examples
run: |
echo "-- Check python version must python 3.13 --"
python3 -c 'import sys;print(sys.version);assert sys.version_info >= (3, 13);assert sys.version_info < (3, 14)'
python -c 'import sys;print(sys.version);assert sys.version_info >= (3, 13);assert sys.version_info < (3, 14)'
whereis python
whereis python3
# export PATH=~/.local/bin/:$PATH
echo "--------------------------------"
echo "-- Install requirements first --"
echo "--------------------------------"
python -m pip install -r requirements.txt
sudo apt update -y
sudo apt install -y cmake autoconf automake libtool git build-essential
echo "--------------------------------"
echo "-- Build Test for MaixCAM2 now --"
echo "--------------------------------"
cd test/test_examples
chmod +x test_cases.sh
./test_cases.sh maixcam2 0
echo "------------------------------------"
echo "-- Build Projects for MaixCAM2 now --"
echo "------------------------------------"
cd ../../projects
chmod +x build_all.sh
./build_all.sh maixcam2
- name: Build doc
run: |
pip3 install teedoc
cd docs
echo "== install plugins =="
teedoc install
echo "== start build =="
teedoc build
echo "== build complete =="

View File

@@ -1,9 +0,0 @@
build
dist
.config.mk
.flash.conf.json
data
/CMakeLists.txt
__pycache__

View File

@@ -1,2 +0,0 @@
## Introduction can be seen
[Introduction](https://maixhub.com/share/34)

View File

@@ -1,82 +0,0 @@
############### Add include ###################
list(APPEND ADD_INCLUDE "include"
)
list(APPEND ADD_PRIVATE_INCLUDE "focus-stack/src")
###############################################
############ Add source files #################
# list(APPEND ADD_SRCS "src/main.c"
# "src/test.c"
# )
append_srcs_dir(ADD_SRCS "src"
"focus-stack/src") # append source file in src dir to var ADD_SRCS
list(REMOVE_ITEM ADD_SRCS "focus-stack/src/main.cc"
"focus-stack/src/gtest_main.cc"
"focus-stack/src/radialfilter_tests.cc"
"focus-stack/src/task_wavelet_tests.cc"
"focus-stack/src/task_wavelet_opencl_tests.cc"
"focus-stack/src/task_grayscale_tests.cc"
)
# FILE(GLOB_RECURSE EXTRA_SRC "src/*.c")
# FILE(GLOB EXTRA_SRC "src/*.c")
# list(APPEND ADD_SRCS ${EXTRA_SRC})
# aux_source_directory(src ADD_SRCS) # collect all source file in src dir, will set var ADD_SRCS
# append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD_SRCS
# list(REMOVE_ITEM COMPONENT_SRCS "src/test.c")
# set(ADD_ASM_SRCS "src/asm.S")
# list(APPEND ADD_SRCS ${ADD_ASM_SRCS})
# SET_PROPERTY(SOURCE ${ADD_ASM_SRCS} PROPERTY LANGUAGE C) # set .S ASM file as C language
# SET_SOURCE_FILES_PROPERTIES(${ADD_ASM_SRCS} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D BBBBB")
###############################################
###### Add required/dependent components ######
list(APPEND ADD_REQUIREMENTS basic opencv)
###############################################
###### Add link search path for requirements/libs ######
# list(APPEND ADD_LINK_SEARCH_PATH "${CONFIG_TOOLCHAIN_PATH}/lib")
# list(APPEND ADD_REQUIREMENTS pthread m) # add system libs, pthread and math lib for example here
# set (OpenCV_DIR opencv/lib/cmake/opencv4)
# find_package(OpenCV REQUIRED)
###############################################
############ Add static libs ##################
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
###############################################
#### Add compile option for this component ####
#### Just for this component, won't affect other
#### modules, including component that depend
#### on this component
# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1)
#### Add compile option for this component
#### and components depend on this component
# list(APPEND ADD_DEFINITIONS -DAAAAA222=1
# -DAAAAA333=1)
###############################################
############ Add static libs ##################
#### Update parent's variables like CMAKE_C_LINK_FLAGS
# set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE)
###############################################
######### Add files need to download #########
# list(APPEND ADD_FILE_DOWNLOADS "{
# 'url': 'https://*****/abcde.tar.xz',
# 'urls': [], # backup urls, if url failed, will try urls
# 'sites': [], # download site, user can manually download file and put it into dl_path
# 'sha256sum': '',
# 'filename': 'abcde.tar.xz',
# 'path': 'toolchains/xxxxx',
# 'check_files': []
# }"
# )
#
# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx,
# you can directly use then, for example use it in add_custom_command
##############################################
# register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib
register_component()

View File

@@ -1,3 +0,0 @@
#pragma once

View File

@@ -1,186 +0,0 @@
#include <iostream>
#include "options.hh"
#include "focusstack.hh"
#include <opencv2/core.hpp>
#ifndef GIT_VERSION
#define GIT_VERSION "unknown"
#endif
using namespace focusstack;
int main(int argc, const char *argv[])
{
Options options(argc, argv);
FocusStack stack;
if (options.has_flag("--version"))
{
std::cerr << "focus-stack " GIT_VERSION ", built " __DATE__ " " __TIME__ "\n"
"Compiled with OpenCV version " CV_VERSION "\n"
"Copyright (c) 2019 Petteri Aimonen\n\n"
"Permission is hereby granted, free of charge, to any person obtaining a copy\n"
"of this software and associated documentation files (the \"Software\"), to\n"
"deal in the Software without restriction, including without limitation the\n"
"rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n"
"sell copies of the Software, and to permit persons to whom the Software is\n"
"furnished to do so, subject to the following conditions:\n\n"
"The above copyright notice and this permission notice shall be included in all\n"
"copies or substantial portions of the Software.\n\n"
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n"
"SOFTWARE."
<< std::endl;
return 0;
}
if (options.has_flag("--opencv-version"))
{
std::cerr << cv::getBuildInformation().c_str() << std::endl;
return 0;
}
if (options.has_flag("--help") || options.get_filenames().size() < 2)
{
std::cerr << "Usage: " << argv[0] << " [options] file1.jpg file2.jpg ...\n";
std::cerr << "\n";
std::cerr << "Output file options:\n"
" --output=output.jpg Set output filename\n"
" --depthmap=depthmap.png Write a depth map image (default disabled)\n"
" --3dview=3dview.png Write a 3D preview image (default disabled)\n"
" --save-steps Save intermediate images from processing steps\n"
" --jpgquality=95 Quality for saving in JPG format (0-100, default 95)\n"
" --nocrop Save full image, including extrapolated border data\n";
std::cerr << "\n";
std::cerr << "Image alignment options:\n"
" --reference=0 Set index of image used as alignment reference (default middle one)\n"
" --global-align Align directly against reference (default with neighbour image)\n"
" --full-resolution-align Use full resolution images in alignment (default max 2048 px)\n"
" --no-whitebalance Don't attempt to correct white balance differences\n"
" --no-contrast Don't attempt to correct contrast and exposure differences\n"
" --align-only Only align the input image stack and exit\n"
" --align-keep-size Keep original image size by not cropping alignment borders\n";
std::cerr << "\n";
std::cerr << "Image merge options:\n"
" --consistency=2 Neighbour pixel consistency filter level 0..2 (default 2)\n"
" --denoise=1.0 Merged image denoise level (default 1.0)\n";
std::cerr << "\n";
std::cerr << "Depth map generation options:\n"
" --depthmap-threshold=10 Threshold to accept depth points (0-255, default 10)\n"
" --depthmap-smooth-xy=20 Smoothing of depthmap in X and Y directions (default 20)\n"
" --depthmap-smooth-z=40 Smoothing of depthmap in Z direction (default 40)\n"
" --remove-bg=0 Positive value removes black background, negative white\n"
" --halo-radius=20 Radius of halo effects to remove from depthmap\n"
" --3dviewpoint=x:y:z:zscale Viewpoint for 3D view (default 1:1:1:2)\n";
std::cerr << "\n";
std::cerr << "Performance options:\n"
" --threads=2 Select number of threads to use (default number of CPUs + 1)\n"
" --batchsize=8 Images per merge batch (default 8)\n"
" --no-opencl Disable OpenCL GPU acceleration (default enabled)\n"
" --wait-images=0.0 Wait for image files to appear (allows simultaneous capture and processing)\n";
std::cerr << "\n";
std::cerr << "Information options:\n"
" --verbose Verbose output from steps\n"
" --version Show application version number\n"
" --opencv-version Show OpenCV library version and build info\n";
return 1;
}
// Output file options
stack.set_inputs(options.get_filenames());
stack.set_output(options.get_arg("--output", "output.jpg"));
stack.set_depthmap(options.get_arg("--depthmap", ""));
stack.set_3dview(options.get_arg("--3dview", ""));
stack.set_jpgquality(std::stoi(options.get_arg("--jpgquality", "95")));
stack.set_save_steps(options.has_flag("--save-steps"));
stack.set_nocrop(options.has_flag("--nocrop"));
// Image alignment options
int flags = FocusStack::ALIGN_DEFAULT;
if (options.has_flag("--global-align")) flags |= FocusStack::ALIGN_GLOBAL;
if (options.has_flag("--full-resolution-align")) flags |= FocusStack::ALIGN_FULL_RESOLUTION;
if (options.has_flag("--no-whitebalance")) flags |= FocusStack::ALIGN_NO_WHITEBALANCE;
if (options.has_flag("--no-contrast")) flags |= FocusStack::ALIGN_NO_CONTRAST;
if (options.has_flag("--align-keep-size")) flags |= FocusStack::ALIGN_KEEP_SIZE;
stack.set_align_flags(flags);
if (options.has_flag("--reference"))
{
stack.set_reference(std::stoi(options.get_arg("--reference")));
}
if (options.has_flag("--align-only"))
{
stack.set_align_only(true);
stack.set_output(options.get_arg("--output", "aligned_"));
}
// Image merge options
stack.set_consistency(std::stoi(options.get_arg("--consistency", "2")));
stack.set_denoise(std::stof(options.get_arg("--denoise", "1.0")));
// Depth map generation options
stack.set_depthmap_smooth_xy(std::stof(options.get_arg("--depthmap-smooth-xy", "20")));
stack.set_depthmap_smooth_z(std::stof(options.get_arg("--depthmap-smooth-z", "40")));
stack.set_depthmap_threshold(std::stoi(options.get_arg("--depthmap-threshold", "10")));
stack.set_halo_radius(std::stof(options.get_arg("--halo-radius", "20")));
stack.set_remove_bg(std::stoi(options.get_arg("--remove-bg", "0")));
stack.set_3dviewpoint(options.get_arg("--3dviewpoint", "1:1:1:2"));
// Performance options
if (options.has_flag("--threads"))
{
stack.set_threads(std::stoi(options.get_arg("--threads")));
}
if (options.has_flag("--batchsize"))
{
stack.set_batchsize(std::stoi(options.get_arg("--batchsize")));
}
stack.set_disable_opencl(options.has_flag("--no-opencl"));
stack.set_wait_images(std::stof(options.get_arg("--wait-images", "0.0")));
// Information options (some are handled at beginning of this function)
stack.set_verbose(options.has_flag("--verbose"));
// Check for any unhandled options
std::vector<std::string> unparsed = options.get_unparsed();
if (unparsed.size())
{
std::cerr << "Warning: unknown options: ";
for (std::string arg: unparsed)
{
std::cerr << arg << " ";
}
std::cerr << std::endl;
}
if (!stack.run())
{
std::printf("\nError exit due to failed steps\n");
return 1;
}
std::printf("\rSaved to %-40s\n", stack.get_output().c_str());
if (stack.get_depthmap() != "")
{
std::printf("\rSaved depthmap to %s\n", stack.get_depthmap().c_str());
}
if (stack.get_3dview() != "")
{
std::printf("\rSaved 3D preview to %s\n", stack.get_3dview().c_str());
}
return 0;
}