├── src ├── modules │ ├── filter │ │ ├── canny.cpp │ │ ├── canny.hpp │ │ ├── skin_detect.hpp │ │ ├── filter.hpp │ │ ├── benchmark │ │ │ ├── CMakeLists.txt │ │ │ ├── threshold_benchmark.cpp │ │ │ └── sobel_benchmark.cpp │ │ ├── integral_image.hpp │ │ ├── blend.hpp │ │ ├── CMakeLists.txt │ │ ├── box_filter.hpp │ │ ├── sobel.hpp │ │ ├── gaussian_filter.hpp │ │ ├── median_filter.hpp │ │ ├── threshold.hpp │ │ ├── skin_detect.cpp │ │ └── blend.cpp │ ├── blob_detection │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── src │ │ │ ├── blob_detection.cpp │ │ │ └── blob_detection_impl.cpp │ │ └── include │ │ │ └── blob_detection │ │ │ ├── blob_detection.hpp │ │ │ └── blob_detection_impl.hpp │ ├── caliper │ │ ├── README.md │ │ ├── test │ │ │ ├── CMakeLists.txt │ │ │ └── test_caliper.cpp │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── caliper │ │ │ │ ├── caliper.hpp │ │ │ │ ├── caliper_impl.hpp │ │ │ │ └── caliper_defines.hpp │ │ └── src │ │ │ └── caliper.cpp │ ├── common │ │ ├── README.md │ │ ├── include │ │ │ ├── algorithms │ │ │ │ ├── gemm │ │ │ │ │ ├── gemm.hpp │ │ │ │ │ ├── gemm_1.hpp │ │ │ │ │ ├── gemm_3.hpp │ │ │ │ │ └── gemm_2.hpp │ │ │ │ └── im2col.hpp │ │ │ └── common │ │ │ │ ├── polygon.hpp │ │ │ │ ├── common_defines.hpp │ │ │ │ ├── algorithms.hpp │ │ │ │ ├── circle.hpp │ │ │ │ ├── line.hpp │ │ │ │ └── rotate_rectangle.hpp │ │ ├── benchmark │ │ │ └── CMakeLists.txt │ │ ├── src │ │ │ ├── point.cpp │ │ │ ├── line.cpp │ │ │ ├── polygon.cpp │ │ │ ├── mat.cpp │ │ │ ├── algorithms │ │ │ │ ├── convex_hull.cpp │ │ │ │ └── im2col.cpp │ │ │ ├── rotate_rectangle.cpp │ │ │ ├── rectangle.cpp │ │ │ └── circle.cpp │ │ ├── test │ │ │ ├── CMakeLists.txt │ │ │ ├── test_point.cpp │ │ │ └── test_algorithms_gemm1.cpp │ │ └── CMakeLists.txt │ ├── lines_detection │ │ ├── test │ │ │ └── CMakeLists.txt │ │ ├── include │ │ │ └── lines_detection │ │ │ │ ├── lines_fit.h │ │ │ │ ├── lines_fit_impl.h │ │ │ │ ├── lines_defines.hpp │ │ │ │ ├── lines_detection.hpp │ │ │ │ └── lines_detection_impl.hpp │ │ ├── src │ │ │ ├── drop_implement.hpp │ │ │ ├── gauss_implement.hpp │ │ │ ├── huber_implement.hpp │ │ │ ├── tukey_implement.hpp │ │ │ ├── racsac_implement.hpp │ │ │ ├── lines_detection_impl.cpp │ │ │ ├── lines_detection.cpp │ │ │ └── regression_implement.hpp │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── image │ │ ├── README.md │ │ ├── .DS_Store │ │ ├── test │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── image │ │ │ │ └── image_defines.hpp │ │ └── 3rdparty │ │ │ └── stb │ │ │ └── LICENSE │ ├── .DS_Store │ ├── core │ │ ├── .DS_Store │ │ ├── CMakeLists.txt │ │ ├── common_util.hpp │ │ ├── data_source.hpp │ │ ├── image_manager.hpp │ │ ├── common_data.hpp │ │ ├── image_manager.cpp │ │ └── data_source.cpp │ ├── effect_buildin_task │ │ ├── .DS_Store │ │ ├── 3rdparty │ │ │ └── .DS_Store │ │ ├── face_task.cpp │ │ ├── CMakeLists.txt │ │ ├── face_task.hpp │ │ ├── gaussian_filter_task.hpp │ │ ├── beauty_smooth.hpp │ │ ├── gaussian_filter_task.cpp │ │ └── beauty_smooth.cpp │ └── CMakeLists.txt ├── CMakeLists.txt ├── .DS_Store └── remove │ ├── test │ └── CMakeLists.txt │ ├── .DS_Store │ ├── debugtool │ ├── debugtool_test.cpp │ ├── plot.h │ ├── CMakeLists.txt │ └── plot.cpp │ ├── libinfo │ ├── libinfo_test.cpp │ ├── opencvinfo.cpp │ ├── CMakeLists.txt │ └── opencvinfo.h │ ├── base │ ├── base.cpp │ ├── base.h │ └── CMakeLists.txt │ ├── caliper │ ├── CMakeLists.txt │ └── caliper_test.cpp │ ├── objectcounter │ ├── CMakeLists.txt │ ├── objectcounter.cpp │ └── objectcounter.h │ ├── blobdetect │ ├── CMakeLists.txt │ ├── blobdetect_test.cpp │ └── blobdetect.h │ ├── linefit │ ├── CMakeLists.txt │ ├── linefit.cpp │ └── linefit_test.cpp │ └── ransac │ └── ransac.hpp ├── .DS_Store ├── data ├── .DS_Store └── images │ ├── .DS_Store │ ├── mvk_blob │ └── blob.jpg │ ├── mvk_image │ ├── rgb_mat.png │ ├── img_border.png │ ├── mat_100x100.png │ ├── rgb_border.png │ ├── 256X256_lena_mono.bmp │ ├── 256X256_lena_mono.jpg │ ├── 256X256_lena_mono.png │ ├── 512X512_lena_rgb.png │ ├── 256X256_lena_mono_save.png │ ├── img_border_constant_3.png │ ├── img_border_constant_5.png │ ├── img_border_default_3.png │ ├── img_border_default_5.png │ ├── img_border_default_7.png │ ├── img_border_replicate_3.png │ ├── img_border_replicate_5.png │ ├── rgb_border_constant_3.png │ ├── rgb_border_constant_5.png │ ├── rgb_border_default_3.png │ ├── rgb_border_default_5.png │ ├── rgb_border_default_7.png │ ├── rgb_border_replicate_3.png │ └── rgb_border_replicate_5.png │ └── mvk_filter │ ├── Doraemon.png │ ├── pengyuyan.jpeg │ ├── rgb_nosie_5x5.png │ ├── 512X512_lena_rgb.png │ ├── 256X256_lena_mono.jpg │ └── median_filter_src.png ├── test ├── .DS_Store ├── core │ ├── .DS_Store │ ├── CMakeLists.txt │ └── test_image_loader_and_writer.cpp ├── CMakeLists.txt ├── 3rdparty │ ├── CMakeLists.txt │ └── openmp_version.cpp ├── test_helper.hpp └── filter │ ├── test_skin_detect.cpp │ ├── test_threshold.cpp │ ├── test_sobel.cpp │ ├── test_box_filter.cpp │ ├── CMakeLists.txt │ ├── test_integral_image.cpp │ └── test_median_filter.cpp ├── 3rdparty ├── .DS_Store ├── stb_image │ ├── .DS_Store │ └── LICENSE ├── cmake_optimize_architecture │ ├── Tests │ │ ├── CMakeCompilerMachineOption │ │ │ ├── cross │ │ │ │ ├── example.c │ │ │ │ └── CMakeLists.txt │ │ │ ├── self │ │ │ │ ├── example.c │ │ │ │ └── CMakeLists.txt │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ └── CMakeHostSystemInformationExtra │ │ │ ├── CMakeLists.txt │ │ │ └── x86_64 │ │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ ├── Modules │ │ ├── CMakeHostSystemInformationExtra │ │ │ ├── winonarm_cpufeatures.c │ │ │ ├── gcc_cpufeatures.c │ │ │ └── gcc_cpuinfo.c │ │ ├── CMakeCompilerMachineOption.cmake │ │ └── GetCPUSIMDFeatures.cmake │ ├── azure-pipelines.yml │ ├── appveyor.yml │ ├── .travis.yml │ ├── Copyright.txt │ ├── README.md │ └── patches │ │ └── CheckCCompilerFlag.cmake.diff └── cv_simd │ └── opencv2 │ └── core │ ├── utils │ ├── logtag.hpp │ ├── allocator_stats.hpp │ ├── configuration.private.hpp │ ├── logger.defines.hpp │ └── filesystem.private.hpp │ ├── ovx.hpp │ ├── version.hpp │ ├── bufferpool.hpp │ ├── private │ └── cv_cpu_include_simd_declarations.hpp │ ├── detail │ ├── exception_ptr.hpp │ ├── dispatch_helper.impl.hpp │ └── async_promise.hpp │ ├── opencl │ └── runtime │ │ ├── opencl_svm_definitions.hpp │ │ ├── opencl_core_wrappers.hpp │ │ ├── opencl_gl_wrappers.hpp │ │ ├── opencl_clfft.hpp │ │ └── opencl_clblas.hpp │ ├── openvx │ └── ovx_defs.hpp │ ├── parallel │ └── backend │ │ └── parallel_for.openmp.hpp │ └── core.hpp ├── MVkitConfig.cmake.in ├── doc ├── threshold-benchmark.png ├── median-filter3x3-benchmark.png └── benchmark │ ├── mvk-median-filter-benchmark-on-m1-mackbook-air.png │ ├── median-filter.md │ └── benchmarkd.md ├── opencv-benchmark ├── threshold │ ├── CMakeLists.txt │ └── main.cpp ├── median-filter │ ├── CMakeLists.txt │ └── main.cpp └── CMakeLists.txt ├── vcpkg.json └── CMakeLists.txt /src/modules/filter/canny.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/modules/filter/canny.hpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/modules/blob_detection/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/modules/caliper/README.md: -------------------------------------------------------------------------------- 1 | # mvk_calipers -------------------------------------------------------------------------------- /src/modules/common/README.md: -------------------------------------------------------------------------------- 1 | # mvk_common -------------------------------------------------------------------------------- /src/modules/lines_detection/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/modules/common/include/algorithms/gemm/gemm.hpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory(modules) 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/modules/blob_detection/README.md: -------------------------------------------------------------------------------- 1 | # mvk_blob_detection 2 | -------------------------------------------------------------------------------- /src/modules/image/README.md: -------------------------------------------------------------------------------- 1 | # mvk_image 2 | image module of mvk 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/.DS_Store -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/.DS_Store -------------------------------------------------------------------------------- /src/remove/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | 4 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/.DS_Store -------------------------------------------------------------------------------- /test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/test/.DS_Store -------------------------------------------------------------------------------- /3rdparty/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/3rdparty/.DS_Store -------------------------------------------------------------------------------- /src/remove/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/remove/.DS_Store -------------------------------------------------------------------------------- /test/core/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/test/core/.DS_Store -------------------------------------------------------------------------------- /data/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/.DS_Store -------------------------------------------------------------------------------- /src/modules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/modules/.DS_Store -------------------------------------------------------------------------------- /MVkitConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/Mvkit-targets.cmake") 4 | -------------------------------------------------------------------------------- /3rdparty/stb_image/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/3rdparty/stb_image/.DS_Store -------------------------------------------------------------------------------- /doc/threshold-benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/doc/threshold-benchmark.png -------------------------------------------------------------------------------- /src/modules/core/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/modules/core/.DS_Store -------------------------------------------------------------------------------- /src/modules/image/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/modules/image/.DS_Store -------------------------------------------------------------------------------- /data/images/mvk_blob/blob.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_blob/blob.jpg -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_mat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_mat.png -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeCompilerMachineOption/cross/example.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | return 0; 3 | } 4 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeCompilerMachineOption/self/example.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | return 0; 3 | } 4 | -------------------------------------------------------------------------------- /data/images/mvk_filter/Doraemon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/Doraemon.png -------------------------------------------------------------------------------- /doc/median-filter3x3-benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/doc/median-filter3x3-benchmark.png -------------------------------------------------------------------------------- /data/images/mvk_filter/pengyuyan.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/pengyuyan.jpeg -------------------------------------------------------------------------------- /data/images/mvk_image/img_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border.png -------------------------------------------------------------------------------- /data/images/mvk_image/mat_100x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/mat_100x100.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border.png -------------------------------------------------------------------------------- /data/images/mvk_filter/rgb_nosie_5x5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/rgb_nosie_5x5.png -------------------------------------------------------------------------------- /data/images/mvk_filter/512X512_lena_rgb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/512X512_lena_rgb.png -------------------------------------------------------------------------------- /data/images/mvk_image/256X256_lena_mono.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/256X256_lena_mono.bmp -------------------------------------------------------------------------------- /data/images/mvk_image/256X256_lena_mono.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/256X256_lena_mono.jpg -------------------------------------------------------------------------------- /data/images/mvk_image/256X256_lena_mono.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/256X256_lena_mono.png -------------------------------------------------------------------------------- /data/images/mvk_image/512X512_lena_rgb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/512X512_lena_rgb.png -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/modules/effect_buildin_task/.DS_Store -------------------------------------------------------------------------------- /data/images/mvk_filter/256X256_lena_mono.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/256X256_lena_mono.jpg -------------------------------------------------------------------------------- /data/images/mvk_filter/median_filter_src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_filter/median_filter_src.png -------------------------------------------------------------------------------- /src/modules/common/benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(benchmark_common_gemm) 2 | 3 | add_executable(benchmark_common_gemm benchmark_common_gemm.cpp) -------------------------------------------------------------------------------- /data/images/mvk_image/256X256_lena_mono_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/256X256_lena_mono_save.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_constant_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_constant_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_constant_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_constant_5.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_default_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_default_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_default_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_default_5.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_default_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_default_7.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_replicate_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_replicate_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/img_border_replicate_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/img_border_replicate_5.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_constant_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_constant_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_constant_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_constant_5.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_default_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_default_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_default_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_default_5.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_default_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_default_7.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_replicate_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_replicate_3.png -------------------------------------------------------------------------------- /data/images/mvk_image/rgb_border_replicate_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/data/images/mvk_image/rgb_border_replicate_5.png -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/3rdparty/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/src/modules/effect_buildin_task/3rdparty/.DS_Store -------------------------------------------------------------------------------- /opencv-benchmark/threshold/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(threshold) 2 | add_executable(${PROJECT_NAME} main.cpp) 3 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mv-kit", 3 | "version": "0.0.1", 4 | "dependencies": [ 5 | { 6 | "name": "catch2" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /opencv-benchmark/median-filter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(median-filter) 2 | add_executable(${PROJECT_NAME} main.cpp) 3 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test) 2 | 3 | include_directories(./../src/modules) 4 | 5 | add_subdirectory(3rdparty) 6 | add_subdirectory(core) 7 | add_subdirectory(filter) -------------------------------------------------------------------------------- /doc/benchmark/mvk-median-filter-benchmark-on-m1-mackbook-air.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mangoeffect/mvk-nodes/HEAD/doc/benchmark/mvk-median-filter-benchmark-on-m1-mackbook-air.png -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CTestTest_CONFIG Debug) 2 | 3 | add_subdirectory(CMakeHostSystemInformationExtra) 4 | add_subdirectory(CMakeCompilerMachineOption) 5 | -------------------------------------------------------------------------------- /src/modules/image/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_image) 2 | 3 | add_executable(${PROJECT_NAME} test_image.cpp) 4 | target_link_libraries(${PROJECT_NAME} mvk_image Catch2::Catch2WithMain) 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/modules/caliper/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_caliper) 2 | 3 | add_executable(test_caliper test_caliper.cpp) 4 | target_link_libraries(test_caliper mvk_caliper mvk_filter Python3::Python Python3::NumPy) 5 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(CMakeOptimizeForArchitecture) 3 | 4 | enable_testing() 5 | add_subdirectory(Tests) 6 | 7 | # vim: ts=2 sw=2 sts=2 et 8 | -------------------------------------------------------------------------------- /src/remove/debugtool/debugtool_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 3/20/2020. 3 | // 4 | 5 | #include "matplotlibcpp.h" 6 | namespace plt = matplotlibcpp; 7 | 8 | int main() 9 | { 10 | plt::plot({ 1,3,2,4 }); 11 | plt::show(); 12 | } -------------------------------------------------------------------------------- /src/modules/blob_detection/src/blob_detection.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blob_detection.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-12-02 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ -------------------------------------------------------------------------------- /src/modules/lines_detection/include/lines_detection/lines_fit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_fit.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ -------------------------------------------------------------------------------- /src/modules/blob_detection/src/blob_detection_impl.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blob_detection_impl.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-12-02 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ -------------------------------------------------------------------------------- /src/modules/lines_detection/include/lines_detection/lines_fit_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_fit_impl.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ -------------------------------------------------------------------------------- /test/3rdparty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(test_simd test_simd.cpp) 2 | target_compile_options(test_simd PRIVATE ${ARCHITECTURE_FLAG}) 3 | 4 | add_executable(print_openmp_versioin openmp_version.cpp) 5 | target_link_libraries(print_openmp_versioin OpenMP::OpenMP_CXX) 6 | 7 | -------------------------------------------------------------------------------- /src/modules/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(./) 2 | 3 | file(GLOB SOURCE "./*.cpp") 4 | 5 | add_library(mango_core ${SOURCE}) 6 | target_compile_options(mango_core PRIVATE ${ARCHITECTURE_FLAG}) 7 | target_link_libraries(mango_core mvk_common mvk_image OpenMP::OpenMP_CXX) 8 | -------------------------------------------------------------------------------- /src/remove/libinfo/libinfo_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 3/20/2020. 3 | // 4 | 5 | #include "opencvinfo.h" 6 | 7 | 8 | int main() 9 | { 10 | mv::OpenCVInfo op; 11 | op.Print(); 12 | 13 | cv::Mat img = cv::Mat(100, 100, CV_8UC1); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /src/modules/filter/skin_detect.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/3/7. 3 | // 4 | 5 | #ifndef MANGO_SKIN_DETECT_HPP 6 | #define MANGO_SKIN_DETECT_HPP 7 | 8 | #include "core/image.hpp" 9 | 10 | int SkinDetectByColorSpace(Image src, Image& dst); 11 | 12 | #endif //MANGO_SKIN_DETECT_HPP 13 | -------------------------------------------------------------------------------- /src/remove/base/base.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 5/08/2020. 3 | // 4 | 5 | /** 6 | * @file base.cpp 7 | * @brief 求解多元函数最小值源代码文件 8 | * @details 根据梯度下降法迭代逼近的方法求解多元函数局部最小值 9 | * @author 芒果 10 | * @date 2020-5-8 11 | * @version 1.0.0 12 | */ 13 | 14 | #include"base.h" 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/modules/common/src/point.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file points.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-21 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/point.hpp" 13 | 14 | namespace mvk 15 | { 16 | 17 | } // namespace mvk 18 | 19 | -------------------------------------------------------------------------------- /src/modules/common/src/line.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file line.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-07 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/line.hpp" 13 | 14 | 15 | namespace mvk 16 | { 17 | 18 | } // namespace mvk 19 | 20 | -------------------------------------------------------------------------------- /src/modules/common/src/polygon.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file polygon.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-08 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/polygon.hpp" 13 | 14 | namespace mvk 15 | { 16 | 17 | } // namespace mvk 18 | -------------------------------------------------------------------------------- /src/modules/common/src/mat.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file mat.cpp 4 | * @author mango (2321544362@qq.com) 5 | * @brief 6 | * @version 0.1 7 | * @date 2021-09-07 8 | * 9 | * @copyright Copyright (c) 2021 10 | * 11 | */ 12 | 13 | #include "common/mat.hpp" 14 | #include 15 | 16 | namespace mvk 17 | { 18 | 19 | } // namespace mvk -------------------------------------------------------------------------------- /src/remove/base/base.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file base.h 4 | * @brief 求解多元函数最小值头文件 5 | * @details 根据梯度下降法迭代逼近的方法求解多元函数局部最小值 6 | * @author 芒果 7 | * @date 2020-5-8 8 | * @version 1.0.0 9 | */ 10 | 11 | #ifndef MACHINE_VISION_LIBRARY_BASE_H 12 | #define MACHINE_VISION_LIBRARY_BASE_H 13 | 14 | #include "multimin.h" 15 | 16 | #endif //MACHINE_VISION_LIBRARY_BASE_H 17 | -------------------------------------------------------------------------------- /src/modules/common/src/algorithms/convex_hull.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file convex_hull.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-08 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/algorithms.hpp" 13 | 14 | namespace mvk 15 | { 16 | 17 | } // namespace mvk 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/modules/common/src/rotate_rectangle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rotate_rectangle.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/rotate_rectangle.hpp" 13 | namespace mvk 14 | { 15 | 16 | } // namespace mvk 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/modules/core/common_util.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common_util.hpp 3 | * @author your name (you@domain.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2023-11-16 7 | * 8 | * @copyright Copyright (c) 2023 9 | * 10 | */ 11 | 12 | #ifndef MANGO_EFFECT_COMMON_UTIL_HPP 13 | #define MANGO_EFFECT_COMMON_UTIL_HPP 14 | 15 | #endif //MANGO_EFFECT_COMMON_UTIL_HPP -------------------------------------------------------------------------------- /src/modules/filter/filter.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file filter.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-08 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_HPP 13 | 14 | #include "box_filter.hpp" 15 | #include "gaussian_filter.hpp" 16 | 17 | #endif //MVK_FILTER_HPP 18 | -------------------------------------------------------------------------------- /test/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project(mango_core_test) 3 | include_directories(./) 4 | 5 | add_executable(test_core_graph test_graph.cpp) 6 | target_link_libraries(test_core_graph mango_core Catch2::Catch2WithMain) 7 | 8 | add_executable(test_core_image test_image_loader_and_writer.cpp) 9 | target_link_libraries(test_core_image mango_core Catch2::Catch2WithMain) 10 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Modules/CMakeHostSystemInformationExtra/winonarm_cpufeatures.c: -------------------------------------------------------------------------------- 1 | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | file Copyright.txt for details. */ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | 11 | printf("\n"); 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /opencv-benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | #set(CMAKE_TOOLCHAIN_FILE /home/mango/vcpkg/scripts/buildsystems/vcpkg.cmake) 4 | 5 | project(opencv-benchmark) 6 | 7 | set(CMAKE_CXX_STANDARD 17) 8 | 9 | find_package(OpenCV REQUIRED) 10 | include_directories(${OpenCV_INCLUDE_DIRS}) 11 | 12 | add_subdirectory(median-filter) 13 | add_subdirectory(threshold) -------------------------------------------------------------------------------- /src/modules/common/src/rectangle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rectangle.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-21 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/rectangle.hpp" 13 | #include 14 | 15 | namespace mvk 16 | { 17 | 18 | 19 | 20 | 21 | } // namespace mvk 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/modules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(./) 2 | #include_directories(./common/include) 3 | #include_directories(./image/include) 4 | #include_directories(./filter/include) 5 | #add_subdirectory(caliper) 6 | #add_subdirectory(common) 7 | add_subdirectory(core) 8 | #add_subdirectory(image) 9 | #add_subdirectory(lines_detection) 10 | add_subdirectory(filter) 11 | add_subdirectory(effect_buildin_task) 12 | -------------------------------------------------------------------------------- /src/remove/debugtool/plot.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by $mango on 4/1/2020. 3 | // 4 | 5 | #ifndef MACHINE_VISION_LIBRARY_PLOT_H 6 | #define MACHINE_VISION_LIBRARY_PLOT_H 7 | 8 | #include "opencv2/opencv.hpp" 9 | 10 | namespace mvp 11 | { 12 | // y = f(x), (x,y) 13 | void Plot(const std::vector& x, const std::vector& y, const std::string& title = "Figure1"); 14 | };//namespace mvp 15 | #endif //MACHINE_VISION_LIBRARY_PLOT_H 16 | -------------------------------------------------------------------------------- /src/modules/blob_detection/include/blob_detection/blob_detection.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blob_detection.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-12-02 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | 13 | #ifndef MVK_BLOB_DETECTION_HPP_ 14 | #define MVK_BLOB_DETECTION_HPP_ 15 | 16 | namespace mvk 17 | { 18 | 19 | } // namespace mvk 20 | 21 | 22 | #endif //MVK_BLOB_DETECTION_HPP_ 23 | -------------------------------------------------------------------------------- /test/test_helper.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/26. 3 | // 4 | 5 | #ifndef MANGO_TEST_HELPER_H 6 | #define MANGO_TEST_HELPER_H 7 | 8 | #include 9 | #include 10 | 11 | bool IsFileExists(std::string& name) 12 | { 13 | std::ifstream f(name.c_str()); 14 | return f.good(); 15 | } 16 | 17 | bool IsFileExists(const char* name) 18 | { 19 | std::ifstream f(name); 20 | return f.good(); 21 | } 22 | 23 | #endif //MANGO_TEST_HELPER_H 24 | -------------------------------------------------------------------------------- /src/modules/blob_detection/include/blob_detection/blob_detection_impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file blob_detection_impl.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-12-02 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_BLOB_DETECTION_IMPL_HPP_ 13 | #define MVK_BLOB_DETECTION_IMPL_HPP_ 14 | 15 | namespace mvk 16 | { 17 | 18 | } // namespace mvk 19 | 20 | 21 | #endif //MVK_BLOB_DETECTION_IMPL_HPP_ 22 | -------------------------------------------------------------------------------- /src/modules/filter/benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(benchmark_filter) 2 | 3 | add_executable(${PROJECT_NAME}_median_filter median_filter_benchmark.cpp) 4 | target_link_libraries(${PROJECT_NAME}_median_filter mvk_filter) 5 | 6 | add_executable(${PROJECT_NAME}_threshold threshold_benchmark.cpp) 7 | target_link_libraries(${PROJECT_NAME}_threshold mvk_filter) 8 | 9 | add_executable(${PROJECT_NAME}_sobel_benchmark sobel_benchmark.cpp) 10 | target_link_libraries(${PROJECT_NAME}_sobel_benchmark mvk_filter) -------------------------------------------------------------------------------- /src/modules/common/src/circle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file circle.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-21 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "common/circle.hpp" 13 | #include "common/common_defines.hpp" 14 | 15 | namespace mvk 16 | { 17 | double GetCircleArea(const Circle& circle) 18 | { 19 | return MVK_PI * circle.radius * circle.radius; 20 | } 21 | } // namespace mvk 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/drop_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drop_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于drop权重方法直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef DROP_IMPLEMENT_HPP_ 13 | #define DROP_IMPLEMENT_HPP_ 14 | 15 | namespace mvk 16 | { 17 | namespace line_fit 18 | { 19 | 20 | }//namespace line_fit 21 | }//namespace mvk 22 | 23 | 24 | #endif //DROP_IMPLEMENT_HPP_ 25 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/gauss_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gauss_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于gauss权重方法直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef GAUSS_IMPLEMENT_HPP_ 13 | #define GAUSS_IMPLEMENT_HPP_ 14 | 15 | namespace mvk 16 | { 17 | namespace line_fit 18 | { 19 | 20 | }//namespace line_fit 21 | }//namespace mvk 22 | 23 | #endif //GAUSS_IMPLEMENT_HPP_ 24 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/huber_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file huber_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于huber权重方法直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef GAUSS_IMPLEMENT_HPP_ 13 | #define GAUSS_IMPLEMENT_HPP_ 14 | 15 | namespace mvk 16 | { 17 | namespace line_fit 18 | { 19 | 20 | }//namespace line_fit 21 | }//namespace mvk 22 | 23 | #endif //GAUSS_IMPLEMENT_HPP_ 24 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/tukey_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tukey_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于tukey权重方法直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef TUKEY_IMPLEMENT_HPP_ 13 | #define TUKEY_IMPLEMENT_HPP_ 14 | 15 | namespace mvk 16 | { 17 | namespace line_fit 18 | { 19 | 20 | }//namespace line_fit 21 | }//namespace mvk 22 | 23 | #endif //TUKEY_IMPLEMENT_HPP_ 24 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/racsac_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file racsac_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于ransac的直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef RANSAC_IMPLEMENT_HPP_ 13 | #define RANSAC_IMPLEMENT_HPP_ 14 | 15 | namespace mvk 16 | { 17 | namespace line_fit 18 | { 19 | 20 | }//namespace line_fit 21 | }//namespace mvk 22 | 23 | #endif //RANSAC_IMPLEMENT_HPP_ 24 | 25 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeCompilerMachineOption/self/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(CMakeCompilerMachineOption VERSION 1.0 LANGUAGES C) 3 | include(CMakeHostSystemInformationExtra) 4 | include(CMakeCompilerMachineOption) 5 | cmake_host_system_information_extra(RESULT MARCH QUERY PROCESSOR_MICRO_ARCHITECTURE) 6 | cmake_compiler_machine_option(op "${MARCH}") 7 | add_executable(example example.c) 8 | target_compile_options(example PRIVATE ${op}) 9 | 10 | # vim: ts=2 sw=2 sts=2 et 11 | -------------------------------------------------------------------------------- /src/modules/common/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_common) 2 | 3 | 4 | add_executable(${PROJECT_NAME}_mat test_mat.cpp) 5 | target_link_libraries(${PROJECT_NAME}_mat mvk_common Catch2::Catch2WithMain) 6 | 7 | 8 | add_executable(${PROJECT_NAME}_point test_point.cpp) 9 | target_link_libraries(${PROJECT_NAME}_point mvk_common Catch2::Catch2WithMain) 10 | 11 | add_executable(${PROJECT_NAME}_algorithms_gemm1 test_algorithms_gemm1.cpp) 12 | target_link_libraries(${PROJECT_NAME}_algorithms_gemm1 mvk_common Catch2::Catch2WithMain) 13 | 14 | -------------------------------------------------------------------------------- /src/modules/filter/integral_image.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file integral_image.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 积分图 5 | * @version 0.1 6 | * @date 2022-03-09 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_INTEGRAL_IMAGE_HPP_ 13 | #define MVK_FILTER_INTEGRAL_IMAGE_HPP_ 14 | 15 | #include "core/mat.hpp" 16 | #include "core/image.hpp" 17 | 18 | 19 | namespace mvk 20 | { 21 | int ComputeIntegral(Image& src, Matrix& integral); 22 | }//namespace mvk 23 | 24 | #endif //MVK_FILTER_INTEGRAL_IMAGE_HPP_ 25 | 26 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: 'Ubuntu-16.04' 11 | 12 | steps: 13 | - script: echo Hello, world! 14 | displayName: 'Run a one-line script' 15 | 16 | - script: | 17 | echo Add other tasks to build, test, and deploy your project. 18 | echo See https://aka.ms/yaml 19 | displayName: 'Run a multi-line script' 20 | -------------------------------------------------------------------------------- /test/3rdparty/openmp_version.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file openmp_version.cpp 4 | * @author mango (2321544362@qq.com) 5 | * @brief 输出openmp版本 6 | * @version 0.1 7 | * @date 2022-04-21 8 | * 9 | * @copyright Copyright (c) 2022 10 | * 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | std::unordered_map map{ {200505,"2.5"},{200805,"3.0"},{201107,"3.1"},{201307,"4.0"},{201511,"4.5"},{201811,"5.0"},{202011,"5.1"} }; 20 | std::cout << "We have OpenMP " << map.at(_OPENMP) << ".\n"; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /src/remove/libinfo/opencvinfo.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file opencvinfo.cpp 4 | * @brief OpenCV信息相关 5 | * @details - 6 | * @author 芒果 7 | * @date 2020-3-20 8 | * @version 1.0.0 9 | */ 10 | 11 | #include "opencvinfo.h" 12 | 13 | 14 | void mv::OpenCVInfo::Print() 15 | { 16 | std::cout<<"OpenCV Information:"< mv::MVLInfo::CreateInstance() 21 | { 22 | return cv::makePtr(); 23 | } 24 | 25 | std::string mv::MVLInfo::GetMVLInfo() const 26 | { 27 | std::string res; 28 | 29 | return res; 30 | } 31 | -------------------------------------------------------------------------------- /src/modules/common/include/common/polygon.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file polygon.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-08 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_POLYGON_H_ 13 | #define MVK_POLYGON_H_ 14 | 15 | #include "common/point.hpp" 16 | #include 17 | 18 | namespace mvk 19 | { 20 | /** 21 | * @brief 多边形 22 | * 23 | */ 24 | template 25 | struct Polygon 26 | { 27 | std::vector> points; 28 | }; 29 | 30 | } // namespace mvk 31 | 32 | 33 | #endif //MVK_POLYGON_H_ 34 | -------------------------------------------------------------------------------- /test/filter/test_skin_detect.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/3/7. 3 | // 4 | #define CATCH_CONFIG_MAIN 5 | #include "catch2/catch_test_macros.hpp" 6 | #include "filter/skin_detect.hpp" 7 | #include "../test_helper.hpp" 8 | 9 | 10 | TEST_CASE("test mvk-filter skin detect", "[mvk-filter]") 11 | { 12 | std::string rgb_path = std::string(DATA) + "/images/mvk_filter/pengyuyan.jpeg"; 13 | Image rgb_img = LoadImage(rgb_path.c_str()); 14 | REQUIRE(!rgb_img.IsEmpty()); 15 | 16 | Image dst; 17 | REQUIRE(SkinDetectByColorSpace(rgb_img,dst) == 0); 18 | REQUIRE(!dst.IsEmpty()); 19 | REQUIRE(WriteImage(dst, "test_filter_skin_detect.png") != -1); 20 | } -------------------------------------------------------------------------------- /src/modules/filter/blend.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/28. 3 | // 4 | 5 | #ifndef MANGO_BLEND_H 6 | #define MANGO_BLEND_H 7 | 8 | #include "core/image.hpp" 9 | 10 | /** 11 | * dst = src1 * alpha + src2 * beta + gamma 12 | * @param src1 13 | * @param alpha 14 | * @param src2 15 | * @param beta 16 | * @param dst 17 | * @param gamma 18 | * @return 19 | */ 20 | int AddWeighted(Image src1, const float alpha, Image src2, const float beta, Image dst ,const float gamma = 0); 21 | 22 | 23 | /** 24 | * 25 | * @param src 26 | * @param blend 27 | * @param dst 28 | * @return 29 | */ 30 | int NormalBlend(Image src, Image blend, Image& dst); 31 | 32 | #endif //MANGO_BLEND_H 33 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/utils/logtag.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_LOGTAG_HPP 6 | #define OPENCV_CORE_LOGTAG_HPP 7 | 8 | #include "opencv2/core/cvstd.hpp" 9 | #include "logger.defines.hpp" 10 | 11 | namespace cv { 12 | namespace utils { 13 | namespace logging { 14 | 15 | struct LogTag 16 | { 17 | const char* name; 18 | LogLevel level; 19 | 20 | inline LogTag(const char* _name, LogLevel _level) 21 | : name(_name) 22 | , level(_level) 23 | {} 24 | }; 25 | 26 | }}} 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/modules/lines_detection/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(./include) 2 | include_directories(./src) 3 | 4 | set(Headers 5 | ./include/lines_detection/lines_detection.hpp 6 | ./include/lines_detection/lines_detection_impl.hpp 7 | ) 8 | 9 | set(Cpps 10 | ./src/lines_detection.cpp 11 | ./src/lines_detection_impl.cpp 12 | ) 13 | 14 | if(BUILD_STATIC_LIB) 15 | add_definitions(-DMVK_LINES_STATIC_DEFINE -DMVK_LINES_STATIC_DEFINE_) 16 | add_library(mvk_lines_detection ${Headers} ${Cpps}) 17 | else() 18 | add_definitions(-DMVK_LINES_EXPORTS -DMVK_LINES_EXPORTS) 19 | add_library(mvk_lines_detection SHARED ${Headers} ${Cpps}) 20 | endif() 21 | 22 | target_link_libraries(mvk_lines_detection mvk_common mvk_common) -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/face_task.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/26. 3 | // 4 | 5 | 6 | #include "face_task.hpp" 7 | #include "vnn_face.h" 8 | 9 | FaceTask::FaceTask(const std::string& name): Task(name) 10 | { 11 | 12 | } 13 | 14 | int FaceTask::InitTask() 15 | { 16 | return 0; 17 | } 18 | 19 | int FaceTask::UpdateParams(const std::string& name, const std::any value) 20 | { 21 | 22 | } 23 | 24 | int FaceTask::RunTask() 25 | { 26 | 27 | } 28 | 29 | std::vector> FaceTask::GetInputDefines() const 30 | { 31 | return input_defines_; 32 | } 33 | 34 | std::vector> FaceTask::GetOutputDefines() const 35 | { 36 | return output_defines_; 37 | } -------------------------------------------------------------------------------- /src/modules/filter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Headers 2 | filter.hpp 3 | box_filter.hpp 4 | integral_image.hpp 5 | gaussian_filter.hpp 6 | median_filter.hpp 7 | threshold.hpp 8 | blend.hpp 9 | skin_detect.hpp 10 | sobel.hpp) 11 | 12 | set(Cpps 13 | box_filter.cpp 14 | integral_image.cpp 15 | gaussian_filter.cpp 16 | median_filter.cpp 17 | threshold.cpp 18 | blend.cpp 19 | skin_detect.cpp 20 | sobel.cpp) 21 | 22 | add_library(mango_filter ${Headers} ${Cpps}) 23 | 24 | 25 | target_compile_options(mango_filter PRIVATE ${ARCHITECTURE_FLAG}) 26 | target_link_libraries(mango_filter mango_core OpenMP::OpenMP_CXX) 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project(effect_buildin_task) 3 | 4 | include(3rdparty/VNN/VNN.cmake) 5 | 6 | add_library(effect_buildin_task 7 | face_task.hpp 8 | face_task.cpp 9 | gaussian_filter_task.hpp 10 | gaussian_filter_task.cpp 11 | beauty_smooth.hpp 12 | beauty_smooth.cpp 13 | ) 14 | 15 | set_target_properties(effect_buildin_task PROPERTIES 16 | LINK_FLAGS "-Wl,-F${VNN_LIB_DIR}/macOS/x86_64_arm64/vnn_core_osx.framework,-F${VNN_LIB_DIR}/macOS/x86_64_arm64/vnn_face_osx.framework" 17 | FRAMEWORK_SEARCH_PATHS ${VNN_LIB_DIR}/macOS/x86_64_arm64 18 | ) 19 | 20 | target_link_libraries(effect_buildin_task 21 | mango_filter "-framework vnn_core_osx" "-framework vnn_face_osx" 22 | ) -------------------------------------------------------------------------------- /src/modules/filter/box_filter.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file box_filter.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-08 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_BOX_FILTER_HPP_ 13 | #define MVK_FILTER_BOX_FILTER_HPP_ 14 | 15 | #include "core/image.hpp" 16 | 17 | namespace mvk 18 | { 19 | /** 20 | * @brief 方框滤波 21 | * 22 | * @param src(in) 输入图像 23 | * @param dst(out) 滤波输出图像 24 | * @param kernel_size(in) 滤波核尺寸大小推荐奇数(1, 3, 5) 25 | * @param border_type(in) 边缘填充类型 26 | * @return int 27 | */ 28 | int BoxFilter(Image& src, Image& dst, const size_t kernel_size, const BORDER_TYPE& border_type = BORDER_TYPE::MIRROR); 29 | }// 30 | 31 | #endif //MVK_FILTER_BOX_FILTER_HPP_ 32 | -------------------------------------------------------------------------------- /src/remove/caliper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(caliper) 4 | 5 | aux_source_directory(. CURRENT_DIR_SRCS) 6 | 7 | if(BUILD_DYNAMIC_LIB) 8 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 9 | else() 10 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 11 | endif() 12 | 13 | 14 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) 15 | 16 | 17 | # 安装 include 文件 18 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 19 | FILES_MATCHING PATTERN "*.h") 20 | 21 | 22 | # 将库文件,可执行文件,头文件安装到指定目录 23 | install(TARGETS ${PROJECT_NAME} 24 | EXPORT GoodScan3D 25 | LIBRARY DESTINATION lib 26 | ARCHIVE DESTINATION lib 27 | RUNTIME DESTINATION bin 28 | PUBLIC_HEADER DESTINATION include 29 | ) -------------------------------------------------------------------------------- /src/modules/filter/sobel.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sobel.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 索贝尔算子实现 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_SOBEL_HPP_ 13 | #define MVK_FILTER_SOBEL_HPP_ 14 | 15 | #include "core/image.hpp" 16 | #include "core/mat.hpp" 17 | 18 | namespace mvk 19 | { 20 | /** 21 | * @brief 3x3索贝尔算子实现 22 | * 23 | * @param src(in) 输入图像 24 | * @param dst(out) 输出图像, dst = sqrt(Gx*Gx + Gy*Gy) 25 | * @param Gx(out) x方向模板卷积结果,数据类型为float 26 | * @param Gy(out) y方向模板卷积结果,数据类型为float 27 | * @return int 28 | */ 29 | int Sobel(Image src, Image& dst, Matrix& Gx, Matrix& Gy); 30 | }//namespace mvk 31 | 32 | #endif //MVK_FILTER_SOBEL_HPP_ 33 | -------------------------------------------------------------------------------- /src/remove/objectcounter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(objectcounter) 4 | 5 | aux_source_directory(. CURRENT_DIR_SRCS) 6 | 7 | if(BUILD_DYNAMIC_LIB) 8 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 9 | else() 10 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 11 | endif() 12 | 13 | 14 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) 15 | 16 | 17 | # 安装 include 文件 18 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 19 | FILES_MATCHING PATTERN "*.h") 20 | 21 | 22 | # 将库文件,可执行文件,头文件安装到指定目录 23 | install(TARGETS ${PROJECT_NAME} 24 | EXPORT GoodScan3D 25 | LIBRARY DESTINATION lib 26 | ARCHIVE DESTINATION lib 27 | RUNTIME DESTINATION bin 28 | PUBLIC_HEADER DESTINATION include 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /src/modules/caliper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(./include) 2 | include_directories(./src) 3 | 4 | set(Headers 5 | ./include/caliper/caliper.hpp 6 | ./include/caliper/caliper_impl.hpp) 7 | 8 | set(Cpps 9 | ./src/caliper.cpp 10 | ./src/caliper_impl.cpp) 11 | 12 | if(BUILD_STATIC_LIB) 13 | add_library(mvk_caliper ${Headers} ${Cpps}) 14 | add_definitions(-DMVK_CALIPER_EXPORT "") 15 | else() 16 | add_library(mvk_caliper SHARED ${Headers} ${Cpps}) 17 | target_include_directories(mvk_caliper PUBLIC ${PROJECT_BINARY_DIR}/exports/) 18 | include(GenerateExportHeader) 19 | generate_export_header(mvk_caliper EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/mvk_caliper_export.hpp) 20 | endif() 21 | 22 | target_link_libraries(mvk_caliper mvk_common mvk_image) 23 | 24 | if(BUILD_TEST) 25 | add_subdirectory(test) 26 | endif() -------------------------------------------------------------------------------- /src/modules/core/data_source.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef FILTER_DATASOURCE_H 4 | #define FILTER_DATASOURCE_H 5 | 6 | #include "task.hpp" 7 | 8 | 9 | class DataSource: public Task 10 | { 11 | std::vector data_; 12 | std::vector> GetDefines() const; 13 | public: 14 | DataSource(const std::string& name); 15 | void SetData(const std::vector& data, std::shared_ptr& graph_context); 16 | int InitTask() final; 17 | int UpdateParams(const std::string& name, const std::any value) final; 18 | int RunTask() final; 19 | int Release() final; 20 | 21 | std::vector> GetInputDefines() const final; 22 | std::vector> GetOutputDefines() const final; 23 | }; 24 | 25 | 26 | #endif //FILTER_DATASOURCE_H 27 | -------------------------------------------------------------------------------- /src/remove/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(base ) 3 | 4 | aux_source_directory(. CURRENT_DIR_SRCS) 5 | 6 | if(BUILD_DYNAMIC_LIB) 7 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 8 | else() 9 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 10 | endif() 11 | 12 | 13 | target_link_libraries(${PROJECT_NAME} 14 | ${OpenCV_LIBS} 15 | ${PCL_LIBRARIES} 16 | ${OPENMESH_LIBRARIES}) 17 | 18 | 19 | # 安装 include 文件 20 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 21 | FILES_MATCHING PATTERN "*.h") 22 | 23 | 24 | # 将库文件,可执行文件,头文件安装到指定目录 25 | install(TARGETS ${PROJECT_NAME} 26 | EXPORT GoodScan3D 27 | LIBRARY DESTINATION lib 28 | ARCHIVE DESTINATION lib 29 | RUNTIME DESTINATION bin 30 | PUBLIC_HEADER DESTINATION include 31 | ) 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/remove/libinfo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(libinfo) 3 | 4 | aux_source_directory(. CURRENT_DIR_SRCS) 5 | 6 | if(BUILD_DYNAMIC_LIB) 7 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 8 | else() 9 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 10 | endif() 11 | 12 | 13 | target_link_libraries(${PROJECT_NAME} 14 | ${OpenCV_LIBS} 15 | ${PCL_LIBRARIES} 16 | ${OPENMESH_LIBRARIES}) 17 | 18 | 19 | # 安装 include 文件 20 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 21 | FILES_MATCHING PATTERN "*.h") 22 | 23 | 24 | # 将库文件,可执行文件,头文件安装到指定目录 25 | install(TARGETS ${PROJECT_NAME} 26 | EXPORT GoodScan3D 27 | LIBRARY DESTINATION lib 28 | ARCHIVE DESTINATION lib 29 | RUNTIME DESTINATION bin 30 | PUBLIC_HEADER DESTINATION include 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /src/remove/blobdetect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(blobdetect) 4 | 5 | aux_source_directory(. CURRENT_DIR_SRCS) 6 | 7 | if(BUILD_DYNAMIC_LIB) 8 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 9 | else() 10 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 11 | endif() 12 | 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | ${OpenCV_LIBS} 16 | ${PCL_LIBRARIES} 17 | ${OPENMESH_LIBRARIES}) 18 | 19 | 20 | # 安装 include 文件 21 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 22 | FILES_MATCHING PATTERN "*.h") 23 | 24 | 25 | # 将库文件,可执行文件,头文件安装到指定目录 26 | install(TARGETS ${PROJECT_NAME} 27 | EXPORT GoodScan3D 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | RUNTIME DESTINATION bin 31 | PUBLIC_HEADER DESTINATION include 32 | ) 33 | -------------------------------------------------------------------------------- /src/remove/linefit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(linefit) 4 | 5 | aux_source_directory(. CURRENT_DIR_SRCS) 6 | 7 | if(BUILD_DYNAMIC_LIB) 8 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 9 | else() 10 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 11 | endif() 12 | 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | ${OpenCV_LIBS} 16 | ${PCL_LIBRARIES} 17 | ${OPENMESH_LIBRARIES}) 18 | 19 | 20 | # 安装 include 文件 21 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 22 | FILES_MATCHING PATTERN "*.h") 23 | 24 | 25 | # 将库文件,可执行文件,头文件安装到指定目录 26 | install(TARGETS ${PROJECT_NAME} 27 | EXPORT GoodScan3D 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | RUNTIME DESTINATION bin 31 | PUBLIC_HEADER DESTINATION include 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /src/modules/common/include/common/common_defines.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file common_defines.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_COMMON_DEFINES_HPP_ 13 | #define MVK_COMMON_DEFINES_HPP_ 14 | 15 | #ifndef BUILD_STATIC_LIB 16 | #include "mvk_common_export.hpp" 17 | #endif 18 | #if __cplusplus >= 202003L 19 | #include 20 | #endif 21 | 22 | namespace mvk 23 | { 24 | #if __cplusplus >= 202003L 25 | #define MVK_PI std::numbers::pi 26 | #else 27 | #define MVK_PI 3.1415926 28 | #endif 29 | 30 | /** 31 | * @brief 分解矩阵方法 32 | * 33 | */ 34 | enum class MATRIX_SOLVE_METHOD 35 | { 36 | LU = 0, 37 | SVD = 1 38 | }; 39 | }//namespace mvk 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/remove/debugtool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(debugtool) 4 | 5 | aux_source_directory(. CURRENT_DIR_SRCS) 6 | 7 | if(BUILD_DYNAMIC_LIB) 8 | add_library(${PROJECT_NAME} SHARED ${CURRENT_DIR_SRCS}) 9 | else() 10 | add_library(${PROJECT_NAME} STATIC ${CURRENT_DIR_SRCS}) 11 | endif() 12 | 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | ${OpenCV_LIBS} 16 | ${PCL_LIBRARIES} 17 | ${OPENMESH_LIBRARIES}) 18 | 19 | 20 | # 安装 include 文件 21 | install(DIRECTORY ./ DESTINATION include/mvp/${PROJECT_NAME} 22 | FILES_MATCHING PATTERN "*.h") 23 | 24 | 25 | # 将库文件,可执行文件,头文件安装到指定目录 26 | install(TARGETS ${PROJECT_NAME} 27 | EXPORT GoodScan3D 28 | LIBRARY DESTINATION lib 29 | ARCHIVE DESTINATION lib 30 | RUNTIME DESTINATION bin 31 | PUBLIC_HEADER DESTINATION include 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/ovx.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | // Copyright (C) 2016, Intel Corporation, all rights reserved. 6 | // Third party copyrights are property of their respective owners. 7 | 8 | // OpenVX related definitions and declarations 9 | 10 | #pragma once 11 | #ifndef OPENCV_OVX_HPP 12 | #define OPENCV_OVX_HPP 13 | 14 | #include "cvdef.h" 15 | 16 | namespace cv 17 | { 18 | /// Check if use of OpenVX is possible 19 | CV_EXPORTS_W bool haveOpenVX(); 20 | 21 | /// Check if use of OpenVX is enabled 22 | CV_EXPORTS_W bool useOpenVX(); 23 | 24 | /// Enable/disable use of OpenVX 25 | CV_EXPORTS_W void setUseOpenVX(bool flag); 26 | } // namespace cv 27 | 28 | #endif // OPENCV_OVX_HPP 29 | -------------------------------------------------------------------------------- /src/modules/core/image_manager.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef FILTER_IMAGE_MANAGER_H 4 | #define FILTER_IMAGE_MANAGER_H 5 | 6 | #include "image.hpp" 7 | #include 8 | 9 | enum ShareStatus 10 | { 11 | RELEASED = -1, 12 | NO_SHARE = 0, 13 | REUSE_USING = 1, 14 | REUSE_ENABLE = 2 15 | }; 16 | 17 | 18 | 19 | class ImageManager 20 | { 21 | private: 22 | std::vector> image_list_; 23 | public: 24 | ~ImageManager(); 25 | int ClearAllImages(); 26 | Image CreateImage(const std::uint32_t width, const std::uint32_t height, const std::uint32_t channel, const bool no_share = false); 27 | Image CreateImage(void* data, const std::uint32_t width, const std::uint32_t height, const std::uint32_t channel, const bool no_share = false); 28 | void UpdateImageMemoryStatus(Image img, const ShareStatus status); 29 | }; 30 | 31 | #endif //FILTER_IMAGE_MANAGER_H 32 | -------------------------------------------------------------------------------- /src/modules/image/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(./include) 3 | include_directories(./src) 4 | include_directories(./3rdparty) 5 | 6 | set(Headers 7 | ./include/image/image_defines.hpp 8 | ./include/image/image.hpp 9 | ./include/image/image_impl.hpp) 10 | 11 | set(Cpps 12 | ./src/image.cpp 13 | ./src/image_impl.cpp) 14 | 15 | if(BUILD_STATIC_LIB) 16 | add_library(mvk_image ${Headers} ${Cpps}) 17 | add_definitions(-DMVK_IMAGE_EXPORT "") 18 | else() 19 | add_library(mvk_image SHARED ${Headers} ${Cpps}) 20 | target_include_directories(mvk_image PUBLIC ${PROJECT_BINARY_DIR}/exports/) 21 | include(GenerateExportHeader) 22 | generate_export_header(mvk_image EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/mvk_image_export.hpp) 23 | endif() 24 | 25 | target_link_libraries(mvk_image mvk_common) 26 | 27 | if(BUILD_TEST) 28 | add_subdirectory(test) 29 | endif() 30 | 31 | -------------------------------------------------------------------------------- /src/modules/caliper/include/caliper/caliper.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file caliper.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-25 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_CALIPER_HPP_ 13 | #define MVK_CALIPER_HPP_ 14 | 15 | #include "caliper/caliper_defines.hpp" 16 | 17 | 18 | namespace mvk 19 | { 20 | class CaliperImpl; 21 | /** 22 | * @brief 卡尺工具类 23 | * 24 | */ 25 | class MVK_CALIPER_EXPORT Caliper 26 | { 27 | private: 28 | std::shared_ptr caliper_impl_; 29 | public: 30 | Caliper(const CALIPER_MODE& mode); 31 | 32 | void SetInputImage(const Image& image); 33 | 34 | void SetROI(const RotateRectf& roi); 35 | 36 | int Measure(); 37 | 38 | CaliperResult GetResult() const; 39 | }; 40 | }//namespace mvk 41 | 42 | #endif //MVK_CALIPER_HPP_ 43 | -------------------------------------------------------------------------------- /src/modules/common/include/common/algorithms.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file algorithms.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-08 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_ALGORITHMS_H_ 13 | #define MVK_ALGORITHMS_H_ 14 | 15 | #include "common/point.hpp" 16 | #include "common/rotate_rectangle.hpp" 17 | #include "common/mat.hpp" 18 | 19 | #include 20 | 21 | namespace mvk 22 | { 23 | /** 24 | * @brief 计算散点点集凸包 25 | * 26 | * @param points(in) 散点点集坐标 27 | * @param convex_hull(in) 凸包坐标 28 | * @return int 执行错误码 29 | */ 30 | int ConvexHull(const std::vector& points, std::vector& convex_hull); 31 | 32 | double PolygonArea(const std::vector& points); 33 | 34 | 35 | //int Img2Col(const Image& image, ) 36 | } // namespace mvk 37 | 38 | #endif //MVK_ALGORITHMS_H_ 39 | -------------------------------------------------------------------------------- /src/modules/caliper/src/caliper.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file caliper.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-22 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #include "caliper/caliper.hpp" 13 | #include "caliper/caliper_impl.hpp" 14 | 15 | namespace mvk 16 | { 17 | Caliper::Caliper(const CALIPER_MODE& mode) 18 | : caliper_impl_(new CaliperImpl(mode)) 19 | { 20 | 21 | } 22 | 23 | void Caliper::SetInputImage(const Image& image) 24 | { 25 | caliper_impl_->SetInputImage(image); 26 | } 27 | 28 | void Caliper::SetROI(const RotateRectf& roi) 29 | { 30 | caliper_impl_->SetROI(roi); 31 | } 32 | 33 | int Caliper::Measure() 34 | { 35 | return caliper_impl_->Measure(); 36 | } 37 | 38 | CaliperResult Caliper::GetResult() const 39 | { 40 | return caliper_impl_->GetResult(); 41 | } 42 | }//namespace mvk 43 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Modules/CMakeHostSystemInformationExtra/gcc_cpufeatures.c: -------------------------------------------------------------------------------- 1 | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | file Copyright.txt for details. */ 3 | 4 | #include 5 | #include 6 | 7 | #define PRINT_CPU_FEATURE(a) if(__builtin_cpu_supports(a)){printf("%s\n", a);} 8 | int main() { 9 | #if defined(GCC_VERSION) 10 | __builtin_cpu_init (); 11 | #endif 12 | // these can be found by gcc8.2 13 | PRINT_CPU_FEATURE("cmov"); 14 | PRINT_CPU_FEATURE("mmx"); 15 | PRINT_CPU_FEATURE("popcnt"); 16 | PRINT_CPU_FEATURE("sse"); 17 | PRINT_CPU_FEATURE("sse2"); 18 | PRINT_CPU_FEATURE("sse3"); 19 | PRINT_CPU_FEATURE("ssse3"); 20 | PRINT_CPU_FEATURE("sse4.1"); 21 | PRINT_CPU_FEATURE("sse4.2"); 22 | PRINT_CPU_FEATURE("avx"); 23 | PRINT_CPU_FEATURE("avx2"); 24 | PRINT_CPU_FEATURE("avx512f"); 25 | 26 | printf("\n"); 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/remove/objectcounter/objectcounter.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "objectcounter.h" 3 | 4 | namespace mvp 5 | { 6 | ObjectCounterTool::ObjectCounterTool(/* args */) 7 | { 8 | } 9 | 10 | ObjectCounterTool::~ObjectCounterTool() 11 | { 12 | } 13 | 14 | static std::shared_ptr ObjectCounterTool::CreateObjectCounterTool() 15 | { 16 | 17 | } 18 | 19 | 20 | int ObjectCounterTool::Init(const std::string& config_json_str) 21 | { 22 | return 0; 23 | } 24 | 25 | 26 | int ObjectCounterTool::Run() 27 | { 28 | return 0; 29 | } 30 | 31 | 32 | int ObjectCounterTool::SetInputImage(const cv::Mat& image) 33 | { 34 | return 0; 35 | } 36 | 37 | int ObjectCounterTool::PreProcess() 38 | { 39 | return 0; 40 | } 41 | }//namespace mvp 42 | -------------------------------------------------------------------------------- /src/modules/common/include/algorithms/im2col.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file im2col.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-07 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_COMMON_ALGORITHMS_IM2COL_HPP_ 13 | #define MVK_COMMON_ALGORITHMS_IM2COL_HPP_ 14 | 15 | namespace mvk 16 | { 17 | /** 18 | * @brief 卷积转矩阵相乘展开步骤 19 | * 20 | * @param data_im(in) 输入图像 21 | * @param channels(in) 图片通道数量 22 | * @param height(in) 图片高度 23 | * @param width(in) 图片宽度 24 | * @param ksize(in) 卷积核尺寸 25 | * @param stride(in) 卷积核移动步长 26 | * @param data_col 27 | */ 28 | void Im2col( 29 | uint8_t* data_im, 30 | int channels, 31 | int height, 32 | int width, 33 | int ksize, 34 | int stride, 35 | uint8_t* data_col); 36 | }//namespace mvk 37 | 38 | #endif //MVK_COMMON_ALGORITHMS_IM2COL_HPP_ 39 | -------------------------------------------------------------------------------- /test/filter/test_threshold.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_threshold.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-15 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #define CATCH_CONFIG_MAIN 13 | #include "catch2/catch_test_macros.hpp" 14 | #include "filter/threshold.hpp" 15 | #include "../test_helper.hpp" 16 | 17 | using namespace mvk; 18 | 19 | TEST_CASE("test mvk-filter threshold", "[mvk-filter]") 20 | { 21 | std::string path = std::string(DATA) + "/images/mvk_filter/256X256_lena_mono.jpg"; 22 | Image mono = LoadImage(path.c_str()); 23 | REQUIRE(!mono.IsEmpty()); 24 | 25 | Image binary; 26 | if(mono.Channels() >1) 27 | { 28 | REQUIRE(Threshold(mono.Convert(CONVERT_TYPE::RGB2GRAY), binary, 128 ) == 0); 29 | } 30 | 31 | std::string binary_png = "binary.png"; 32 | REQUIRE(WriteImage(binary,binary_png.c_str() ) != -1); 33 | REQUIRE(IsFileExists(binary_png)); 34 | } -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/utils/allocator_stats.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_ALLOCATOR_STATS_HPP 6 | #define OPENCV_CORE_ALLOCATOR_STATS_HPP 7 | 8 | #include "../cvdef.h" 9 | 10 | namespace cv { namespace utils { 11 | 12 | class AllocatorStatisticsInterface 13 | { 14 | protected: 15 | AllocatorStatisticsInterface() {} 16 | virtual ~AllocatorStatisticsInterface() {} 17 | public: 18 | virtual uint64_t getCurrentUsage() const = 0; 19 | virtual uint64_t getTotalUsage() const = 0; 20 | virtual uint64_t getNumberOfAllocations() const = 0; 21 | virtual uint64_t getPeakUsage() const = 0; 22 | 23 | /** set peak usage = current usage */ 24 | virtual void resetPeakUsage() = 0; 25 | }; 26 | 27 | }} // namespace 28 | 29 | #endif // OPENCV_CORE_ALLOCATOR_STATS_HPP 30 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/appveyor.yml: -------------------------------------------------------------------------------- 1 | 2 | environment: 3 | matrix: 4 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 5 | platform: x64 6 | GENERATOR: Visual Studio 15 2017 Win64 7 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 8 | platform: x86 9 | GENERATOR: Visual Studio 14 2015 10 | 11 | shallow_clone: true 12 | 13 | install: 14 | - ps: | 15 | New-Item -ItemType directory -Path cmake-build-windows 16 | Set-Location "$env:APPVEYOR_BUILD_FOLDER\cmake-build-windows" 17 | & cmake "-G$env:GENERATOR" .. 2>&1 | %{ "$_" } 18 | if ($LastExitCode -ne 0) { write-output "Fails with code:$LastExitCode"; exit 1 } 19 | & cmake --build . --config Release 2>&1 | %{ "$_" } 20 | if ($LastExitCode -ne 0) { write-output "Fails with code:$LastExitCode"; exit 1 } 21 | & ctest --verbose -C Debug 22 | if ($LastExitCode -ne 0) { write-output "Fails with code:$LastExitCode"; exit 1 } 23 | 24 | build: off 25 | 26 | deploy: off 27 | 28 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/utils/configuration.private.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CONFIGURATION_PRIVATE_HPP 6 | #define OPENCV_CONFIGURATION_PRIVATE_HPP 7 | 8 | #include "opencv2/core/cvstd.hpp" 9 | #include 10 | #include 11 | 12 | namespace cv { namespace utils { 13 | 14 | typedef std::vector Paths; 15 | CV_EXPORTS bool getConfigurationParameterBool(const char* name, bool defaultValue); 16 | CV_EXPORTS size_t getConfigurationParameterSizeT(const char* name, size_t defaultValue); 17 | CV_EXPORTS cv::String getConfigurationParameterString(const char* name, const char* defaultValue); 18 | CV_EXPORTS Paths getConfigurationParameterPaths(const char* name, const Paths &defaultValue = Paths()); 19 | 20 | }} // namespace 21 | 22 | #endif // OPENCV_CONFIGURATION_PRIVATE_HPP 23 | -------------------------------------------------------------------------------- /src/modules/common/include/common/circle.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file circle.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-21 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_CIRCLE_H_ 13 | #define MVK_CIRCLE_H_ 14 | 15 | #include "common/point.hpp" 16 | #include "common/common_defines.hpp" 17 | 18 | namespace mvk 19 | { 20 | /** 21 | * @brief 圆形类 22 | * 23 | */ 24 | struct Circle 25 | { 26 | Point2f center; ///< 圆心 27 | float radius; ///< 半径 28 | Circle(const Point2f& center_, const float& radius_) 29 | : center(center_), radius(radius_){} 30 | }; 31 | 32 | /** 33 | * @brief 计算圆形面积 34 | * 35 | * @param circle(in) 圆形 36 | * @return double 37 | */ 38 | MVK_COMMON_EXPORT double GetCircleArea(const Circle& circle); 39 | } // namespace mvk 40 | 41 | 42 | #endif //MVK_CIRCLE_H_ 43 | 44 | -------------------------------------------------------------------------------- /test/core/test_image_loader_and_writer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/2. 3 | // 4 | 5 | #define CATCH_CONFIG_MAIN 6 | #include "catch2/catch_test_macros.hpp" 7 | #include "core/graph.hpp" 8 | #include "core/image_manager.hpp" 9 | #include "../test_helper.hpp" 10 | 11 | 12 | TEST_CASE("test mango-core image", "[mango-core]") 13 | { 14 | Image img = Image(Size(500, 500), IMAGE_TYPE::IMAGE_8UC4); 15 | 16 | REQUIRE(!img.IsEmpty()); 17 | for(int y = 0; y < 500; y++) 18 | { 19 | for(int x = 0; x < 500; x++) 20 | { 21 | img.Ptr(x, y)[0] = 255; 22 | img.Ptr(x, y)[1] = 0; 23 | img.Ptr(x, y)[2] = 0; 24 | img.Ptr(x, y)[3] = 255; 25 | } 26 | } 27 | REQUIRE(WriteImage(img, "test_core_img.png") != -1); 28 | REQUIRE(IsFileExists("test_core_img.png")); 29 | Image load_img = LoadImage("test_core_img.png"); 30 | REQUIRE(!load_img.IsEmpty()); 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/version.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_VERSION_HPP 6 | #define OPENCV_VERSION_HPP 7 | 8 | #define CV_VERSION_MAJOR 4 9 | #define CV_VERSION_MINOR 5 10 | #define CV_VERSION_REVISION 5 11 | #define CV_VERSION_STATUS "" 12 | 13 | #define CVAUX_STR_EXP(__A) #__A 14 | #define CVAUX_STR(__A) CVAUX_STR_EXP(__A) 15 | 16 | #define CVAUX_STRW_EXP(__A) L ## #__A 17 | #define CVAUX_STRW(__A) CVAUX_STRW_EXP(__A) 18 | 19 | #define CV_VERSION CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS 20 | 21 | /* old style version constants*/ 22 | #define CV_MAJOR_VERSION CV_VERSION_MAJOR 23 | #define CV_MINOR_VERSION CV_VERSION_MINOR 24 | #define CV_SUBMINOR_VERSION CV_VERSION_REVISION 25 | 26 | #endif // OPENCV_VERSION_HPP 27 | -------------------------------------------------------------------------------- /src/modules/common/test/test_point.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_point.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-10-28 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #define CATCH_CONFIG_MAIN 13 | #include "catch2/catch_test_macros.hpp" 14 | #include "common/point.hpp" 15 | 16 | using namespace mvk; 17 | 18 | TEST_CASE("test mvk_common points", "[mvk_common point]") 19 | { 20 | //构造函数 21 | Point pt1(1, 2); 22 | REQUIRE(pt1.x == 1); 23 | REQUIRE(pt1.y == 2); 24 | 25 | //点乘测试 26 | Point v1(0.0f, 1.0f); 27 | Point v2(1.0f, 0.0f); 28 | REQUIRE(v1.Dot(v2) == 0.0f); 29 | 30 | //坐标点相加 31 | Point p1(1, 2); 32 | Point p2(2, 1); 33 | REQUIRE((p1 + p2).x == 3); 34 | REQUIRE((p1 + p2).y == 3); 35 | 36 | //坐标点相减 37 | REQUIRE((p1 - p2).x == -1); 38 | REQUIRE((p1 - p2).y == 1); 39 | 40 | //正交判断 41 | Point a(0, 1); 42 | Point b(0, 0); 43 | Point c(1, 0); 44 | REQUIRE(IsOrthogonal(a, b, c)); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/bufferpool.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | // 5 | // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. 6 | 7 | #ifndef OPENCV_CORE_BUFFER_POOL_HPP 8 | #define OPENCV_CORE_BUFFER_POOL_HPP 9 | 10 | #ifdef _MSC_VER 11 | #pragma warning(push) 12 | #pragma warning(disable: 4265) 13 | #endif 14 | 15 | namespace cv 16 | { 17 | 18 | //! @addtogroup core 19 | //! @{ 20 | 21 | class BufferPoolController 22 | { 23 | protected: 24 | ~BufferPoolController() { } 25 | public: 26 | virtual size_t getReservedSize() const = 0; 27 | virtual size_t getMaxReservedSize() const = 0; 28 | virtual void setMaxReservedSize(size_t size) = 0; 29 | virtual void freeAllReservedBuffers() = 0; 30 | }; 31 | 32 | //! @} 33 | 34 | } 35 | 36 | #ifdef _MSC_VER 37 | #pragma warning(pop) 38 | #endif 39 | 40 | #endif // OPENCV_CORE_BUFFER_POOL_HPP 41 | -------------------------------------------------------------------------------- /src/modules/core/common_data.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef COMMON_DATA_HPP 3 | #define COMMON_DATA_HPP 4 | 5 | #include 6 | 7 | class Point 8 | { 9 | public: 10 | int x, y; 11 | 12 | public: 13 | Point(int x = 0, int y = 0) 14 | : x(x), y(y) {} 15 | }; 16 | 17 | class Size 18 | { 19 | public: 20 | int width, height; 21 | 22 | public: 23 | Size(int width = 0, int height = 0) 24 | : width(width), height(height) {} 25 | 26 | bool operator==(const Size& other) 27 | { 28 | return (width == other.width) && (height == other.height); 29 | } 30 | 31 | bool operator!=(const Size& other) 32 | { 33 | return !(*this == other); 34 | } 35 | }; 36 | 37 | 38 | class Rect 39 | { 40 | public: 41 | int x, y, width, height; 42 | 43 | public: 44 | Rect(int x = 0, int y = 0, int width = 0, int height = 0) 45 | : x(x), y(y), width(width), height(height) {} 46 | 47 | public: 48 | Size inline size() const 49 | { 50 | return Size(width, height); 51 | } 52 | }; 53 | #endif //COMMON_DATA_HPP -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/face_task.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/26. 3 | // 4 | 5 | #ifndef MANGO_FACE_TASK_HPP 6 | #define MANGO_FACE_TASK_HPP 7 | 8 | #include "core/task.hpp" 9 | 10 | class FaceTask: public Task 11 | { 12 | //定义输入输出 13 | const std::vector> input_defines_ = 14 | { 15 | {"input_0", typeid(Image).name()}, 16 | }; 17 | 18 | const std::vector> output_defines_ = 19 | { 20 | {"output_0", typeid(Image).name()}, 21 | }; 22 | 23 | public: 24 | FaceTask(const std::string& name); 25 | int InitTask() final; 26 | int UpdateParams(const std::string& name, const std::any value) final; 27 | int RunTask() final; 28 | 29 | std::vector> GetInputDefines() const final; 30 | std::vector> GetOutputDefines() const final; 31 | private: 32 | std::uint32_t face_handle_ = 0; 33 | }; 34 | 35 | #endif //MANGO_FACE_TASK_HPP 36 | -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/gaussian_filter_task.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/26. 3 | // 4 | 5 | #ifndef MANGO_GAUSSIAN_FILTER_TASK_HPP 6 | #define MANGO_GAUSSIAN_FILTER_TASK_HPP 7 | 8 | #include "core/task.hpp" 9 | 10 | class GaussianFilterTask: public Task 11 | { 12 | //定义输入输出 13 | const std::vector> input_defines_ = 14 | { 15 | {"input_0", typeid(Image).name()}, 16 | }; 17 | 18 | const std::vector> output_defines_ = 19 | { 20 | {"output_0", typeid(Image).name()}, 21 | }; 22 | 23 | public: 24 | GaussianFilterTask(const std::string& name); 25 | int InitTask() final; 26 | int UpdateParams(const std::string& name, const std::any value) final; 27 | int RunTask() final; 28 | 29 | std::vector> GetInputDefines() const final; 30 | std::vector> GetOutputDefines() const final; 31 | }; 32 | 33 | #endif //MANGO_GAUSSIAN_FILTER_TASK_HPP 34 | -------------------------------------------------------------------------------- /test/filter/test_sobel.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_sobel.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-16 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #define CATCH_CONFIG_MAIN 13 | #include "catch2/catch_test_macros.hpp" 14 | #include "filter/sobel.hpp" 15 | #include "../test_helper.hpp" 16 | 17 | using namespace mvk; 18 | 19 | TEST_CASE("test mvk-filter sobel", "[mvk-filter]") 20 | { 21 | std::string path = std::string(DATA) + "/images/mvk_filter/256X256_lena_mono.jpg"; 22 | Image mono = LoadImage(path.c_str()); 23 | REQUIRE(!mono.IsEmpty()); 24 | 25 | Image edge; 26 | int rows = mono.GetSize().height; 27 | int cols = mono.GetSize().width; 28 | Matrix gx(rows, cols); 29 | Matrix gy(rows, cols); 30 | 31 | if(mono.Channels() >1) 32 | { 33 | REQUIRE(Sobel(mono.Convert(CONVERT_TYPE::RGB2GRAY), edge, gx, gy) == 0); 34 | } 35 | 36 | std::string sobel_png = "sobel.png"; 37 | REQUIRE(WriteImage(edge, sobel_png.c_str()) != -1); 38 | REQUIRE(IsFileExists(sobel_png)); 39 | } -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/private/cv_cpu_include_simd_declarations.hpp: -------------------------------------------------------------------------------- 1 | // Helper file to include dispatched functions declaration: 2 | // 3 | // Usage: 4 | // #define CV_CPU_SIMD_FILENAME ".simd.hpp" 5 | // #define CV_CPU_DISPATCH_MODE AVX2 6 | // #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp" 7 | // #define CV_CPU_DISPATCH_MODE SSE2 8 | // #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp" 9 | 10 | #ifndef CV_DISABLE_OPTIMIZATION 11 | #ifdef _MSC_VER 12 | #pragma warning(disable: 4702) // unreachable code 13 | #endif 14 | #endif 15 | 16 | #ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY 17 | #define CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY 18 | #endif 19 | 20 | #undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN 21 | #undef CV_CPU_OPTIMIZATION_NAMESPACE_END 22 | 23 | #define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) { 24 | #define CV_CPU_OPTIMIZATION_NAMESPACE_END } 25 | 26 | #include CV_CPU_SIMD_FILENAME 27 | 28 | #undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN 29 | #undef CV_CPU_OPTIMIZATION_NAMESPACE_END 30 | #undef CV_CPU_DISPATCH_MODE 31 | -------------------------------------------------------------------------------- /src/modules/image/include/image/image_defines.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file image_defines.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief image类一些公共定义 5 | * @version 0.1 6 | * @date 2021-08-17 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_IMAGE_DEFINES_HPP_ 13 | #define MVK_IMAGE_DEFINES_HPP_ 14 | 15 | #ifndef BUILD_STATIC_LIB 16 | #include "mvk_image_export.hpp" 17 | #endif 18 | 19 | namespace mvk 20 | { 21 | /** 22 | * @brief 图像格式类型 23 | * 24 | */ 25 | enum class IMAGE_FORMAT 26 | { 27 | MONO_8_BIT = 0, ///< 单通道8比特灰度图像 28 | RGB_24_BIT = 1, ///< RGB三通道24比特彩色图像 29 | };// enum class IMAGE_FORMAT 30 | 31 | 32 | /** 33 | * @brief 填充边界的类型 34 | * 35 | */ 36 | enum class BORDER_TYPE 37 | { 38 | NONE = 0, ///<不做padding 39 | MIRROR = 1, ///<镜像, 123 | 321 40 | CONSTANT = 2, ///<常数填充, 123 | ccc 41 | REPLICATE = 3, ///<边界复制, 123 | 333 42 | }; 43 | } // namespace mvk 44 | 45 | 46 | #endif //MVK_IMAGE_DEFINES_HPP_ 47 | -------------------------------------------------------------------------------- /src/modules/filter/gaussian_filter.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gaussian_filter.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 高斯滤波 5 | * @version 0.1 6 | * @date 2022-03-11 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_GAUSSIAN_FILTER_HPP_ 13 | #define MVK_FILTER_GAUSSIAN_FILTER_HPP_ 14 | 15 | #include "core/image.hpp" 16 | 17 | namespace mvk 18 | { 19 | /** 20 | * @brief 高斯滤波 21 | * 22 | * @param src(in) 输入图像 23 | * @param dst(out) 滤波输出图像 24 | * @param kernel_size(in) 滤波核尺寸大小推荐奇数(1, 3, 5) 25 | * @param sigma_x(in) 高斯核函数x方向标准差系数,如果为0则由kernel_size计算 26 | * @param sigma_y(in) 高斯核函数x方向标准差系数,如果为0则由kernel_size计算 27 | * @param border_type(in) 边缘填充类型 28 | * @return int 29 | */ 30 | int GaussianFilter(Image& src, 31 | Image& dst, const size_t kernel_size, 32 | const double sigma_x = 0.0, 33 | const double sigma_y = 0.0, 34 | const BORDER_TYPE& border_type = BORDER_TYPE::MIRROR); 35 | 36 | }//namespace mvk 37 | 38 | #endif //MVK_FILTER_GAUSSIAN_FILTER_HPP_ 39 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeHostSystemInformationExtra/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_test(NAME "CMakeHostSystemInformationExtra.arm" 2 | COMMAND "${CMAKE_CTEST_COMMAND}" 3 | --build-and-test 4 | "${CMAKE_SOURCE_DIR}/Tests/CMakeHostSystemInformationExtra/arm" 5 | "${CMAKE_BINARY_DIR}/Tests/CMakeHostSystemInformationExtra/arm" 6 | --build-generator ${CMAKE_GENERATOR} 7 | --build-project CMakeHostSystemInformationExtra 8 | --build-options -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/Modules 9 | --test-command ${CMAKE_CTEST_COMMAND} -C ${CTestTest_CONFIG} 10 | ) 11 | add_test(NAME "CMakeHostSystemInformationExtra.x64" 12 | COMMAND "${CMAKE_CTEST_COMMAND}" 13 | --build-and-test 14 | "${CMAKE_SOURCE_DIR}/Tests/CMakeHostSystemInformationExtra/x86_64" 15 | "${CMAKE_BINARY_DIR}/Tests/CMakeHostSystemInformationExtra/x86_64" 16 | --build-generator ${CMAKE_GENERATOR} 17 | --build-project CMakeHostSystemInformationExtra 18 | --build-options -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/Modules 19 | --test-command ${CMAKE_CTEST_COMMAND} -C ${CTestTest_CONFIG} 20 | ) 21 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/detail/exception_ptr.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_DETAILS_EXCEPTION_PTR_H 6 | #define OPENCV_CORE_DETAILS_EXCEPTION_PTR_H 7 | 8 | #ifndef CV__EXCEPTION_PTR 9 | # if defined(__ANDROID__) && defined(ATOMIC_INT_LOCK_FREE) && ATOMIC_INT_LOCK_FREE < 2 10 | # define CV__EXCEPTION_PTR 0 // Not supported, details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58938 11 | # elif defined(CV_CXX11) 12 | # define CV__EXCEPTION_PTR 1 13 | # elif defined(_MSC_VER) 14 | # define CV__EXCEPTION_PTR (_MSC_VER >= 1600) 15 | # elif defined(__clang__) 16 | # define CV__EXCEPTION_PTR 0 // C++11 only (see above) 17 | # elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) 18 | # define CV__EXCEPTION_PTR (__GXX_EXPERIMENTAL_CXX0X__ > 0) 19 | # endif 20 | #endif 21 | #ifndef CV__EXCEPTION_PTR 22 | # define CV__EXCEPTION_PTR 0 23 | #elif CV__EXCEPTION_PTR 24 | # include // std::exception_ptr 25 | #endif 26 | 27 | #endif // OPENCV_CORE_DETAILS_EXCEPTION_PTR_H 28 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeCompilerMachineOption/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_test(NAME "CMakeCompilerMachineOption.self" 2 | COMMAND "${CMAKE_CTEST_COMMAND}" 3 | --build-and-test 4 | "${CMAKE_SOURCE_DIR}/Tests/CMakeCompilerMachineOption/self" 5 | "${CMAKE_BINARY_DIR}/Tests/CMakeCompilerMachineOption/self" 6 | --build-generator ${CMAKE_GENERATOR} 7 | --build-project CMakeCompilerMachineOption 8 | --build-options "-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/Modules" 9 | --test-command ${CMAKE_CTEST_COMMAND} -C ${CTestTest_CONFIG} 10 | ) 11 | add_test(NAME "CMakeCompilerMachineOption.cross" 12 | COMMAND "${CMAKE_CTEST_COMMAND}" 13 | --build-and-test 14 | "${CMAKE_SOURCE_DIR}/Tests/CMakeCompilerMachineOption/cross" 15 | "${CMAKE_BINARY_DIR}/Tests/CMakeCompilerMachineOption/cross" 16 | --build-generator ${CMAKE_GENERATOR} 17 | --build-project CMakeCompilerMachineOption 18 | --build-options 19 | "-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/Modules" 20 | -DTARGET_ARCHITECTURE=skylake 21 | --test-command ${CMAKE_CTEST_COMMAND} -C ${CTestTest_CONFIG} 22 | ) -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeCompilerMachineOption/cross/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | if(POLICY CMP0066) 4 | cmake_policy(SET CMP0066 NEW) 5 | endif() 6 | 7 | project(CMakeCompilerMachineOption VERSION 1.0 LANGUAGES C) 8 | 9 | include(CMakeCompilerMachineOption) 10 | 11 | set(TARGET_ARCHITECTURE "knl" CACHE STRING "CPU architecture to optimize for. \ 12 | Using an incorrect setting here can result in crashes of the resulting binary because of invalid instructions used. \ 13 | Supported values: \"generic\", \"core\", \"merom\" (65nm Core2), \ 14 | \"penryn\" (45nm Core2), \"nehalem\", \"westmere\", \"sandy-bridge\", \"ivy-bridge\", \ 15 | \"haswell\", \"broadwell\", \"skylake\", \"skylake-xeon\", \"kaby-lake\", \"cannonlake\", \"silvermont\", \ 16 | \"goldmont\", \"knl\" (Knights Landing), \"atom\", \"k8\", \"k8-sse3\", \"barcelona\", \ 17 | \"istanbul\", \"magny-cours\", \"bulldozer\", \"interlagos\", \"piledriver\", \ 18 | \"amd-14h\", \"amd-16h\", \"zen\".") 19 | cmake_compiler_machine_option(ARCHITECTURE_FLAG ${TARGET_ARCHITECTURE}) 20 | add_executable(example example.c) 21 | target_compile_options(example PRIVATE ${ARCHITECTURE_FLAG}) 22 | 23 | # vim: ts=2 sw=2 sts=2 et 24 | -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/beauty_smooth.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/3/8. 3 | // 4 | 5 | #ifndef MANGO_BEAUTY_SMOOTH_H 6 | #define MANGO_BEAUTY_SMOOTH_H 7 | 8 | #include "core/task.hpp" 9 | 10 | enum SMOOTH_TYPE 11 | { 12 | COLOR_SPACE = 0 13 | }; 14 | 15 | class BeautySmoothTask: public Task 16 | { 17 | //定义输入输出 18 | const std::vector> input_defines_ = 19 | { 20 | {"input_0", typeid(Image).name()}, 21 | }; 22 | 23 | const std::vector> output_defines_ = 24 | { 25 | {"output_0", typeid(Image).name()}, 26 | }; 27 | 28 | public: 29 | BeautySmoothTask(const std::string& name); 30 | int InitTask() final; 31 | int UpdateParams(const std::string& name, const std::any value) final; 32 | int RunTask() final; 33 | 34 | std::vector> GetInputDefines() const final; 35 | std::vector> GetOutputDefines() const final; 36 | private: 37 | int SmoothByColorSpace(Image& src, Image& dst, const float intensity); 38 | std::uint32_t face_handle_ = 0; 39 | }; 40 | 41 | #endif //MANGO_BEAUTY_SMOOTH_H 42 | -------------------------------------------------------------------------------- /src/modules/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(./include) 3 | include_directories(./src) 4 | 5 | 6 | set(Headers 7 | ./include/common/point.hpp 8 | ./include/common/rectangle.hpp 9 | ./include/common/circle.hpp 10 | ../core/mat.hpp 11 | ./include/common/rotate_rectangle.hpp 12 | ./include/common/line.hpp 13 | ./include/common/polygon.hpp 14 | ./include/common/algorithms.hpp 15 | ./include/common/common_defines.hpp) 16 | 17 | set(Cpps 18 | ./src/point.cpp 19 | ./src/rectangle.cpp 20 | ./src/circle.cpp 21 | ./src/mat.cpp 22 | ./src/rotate_rectangle.cpp 23 | ./src/line.cpp 24 | ./src/polygon.cpp 25 | ./src/algorithms/convex_hull.cpp) 26 | 27 | if(BUILD_STATIC_LIB) 28 | add_definitions(-DMVK_COMMON_EXPORT "") 29 | add_library(mvk_common ${Headers} ${Cpps}) 30 | else() 31 | add_library(mvk_common SHARED ${Headers} ${Cpps}) 32 | target_include_directories(mvk_common PUBLIC ${PROJECT_BINARY_DIR}/exports/) 33 | include(GenerateExportHeader) 34 | generate_export_header(mvk_common EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/mvk_common_export.hpp) 35 | endif() 36 | 37 | if(BUILD_TEST) 38 | add_subdirectory(test) 39 | add_subdirectory(benchmark) 40 | endif() 41 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Modules/CMakeCompilerMachineOption.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | #[=======================================================================[.rst: 5 | CMakeCompilerMachineOption 6 | -------------------------- 7 | 8 | Get march flags for target Intel micro architecture 9 | 10 | .. command:: cmake_compiler_machine_option 11 | 12 | cmake_compiler_machine_option( 13 | [TARGET_ARCHITECTURE ] 14 | [FEATURES ...]) 15 | 16 | #]=======================================================================] 17 | 18 | include("${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerMachineOption/X64CompilerOptions.cmake") 19 | 20 | function(CMAKE_COMPILER_MACHINE_OPTION outvar tarch) 21 | set(compiler_options) 22 | if("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(x86|AMD64)") 23 | x64_compiler_options(compiler_options ${tarch}) 24 | elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(ARM|aarch64)") 25 | arm_compiler_options(compiler_options ${tarch}) 26 | endif() 27 | set(${outvar} ${compiler_options} PARENT_SCOPE) 28 | endfunction() -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp: -------------------------------------------------------------------------------- 1 | /* See LICENSE file in the root OpenCV directory */ 2 | 3 | #ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_DEFINITIONS_HPP 4 | #define OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_DEFINITIONS_HPP 5 | 6 | #if defined(HAVE_OPENCL_SVM) 7 | #if defined(CL_VERSION_2_0) 8 | 9 | // OpenCL 2.0 contains SVM definitions 10 | 11 | #else 12 | 13 | typedef cl_bitfield cl_device_svm_capabilities; 14 | typedef cl_bitfield cl_svm_mem_flags; 15 | typedef cl_uint cl_kernel_exec_info; 16 | 17 | // 18 | // TODO Add real values after OpenCL 2.0 release 19 | // 20 | 21 | #ifndef CL_DEVICE_SVM_CAPABILITIES 22 | #define CL_DEVICE_SVM_CAPABILITIES 0x1053 23 | 24 | #define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER (1 << 0) 25 | #define CL_DEVICE_SVM_FINE_GRAIN_BUFFER (1 << 1) 26 | #define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM (1 << 2) 27 | #define CL_DEVICE_SVM_ATOMICS (1 << 3) 28 | #endif 29 | 30 | #ifndef CL_MEM_SVM_FINE_GRAIN_BUFFER 31 | #define CL_MEM_SVM_FINE_GRAIN_BUFFER (1 << 10) 32 | #endif 33 | 34 | #ifndef CL_MEM_SVM_ATOMICS 35 | #define CL_MEM_SVM_ATOMICS (1 << 11) 36 | #endif 37 | 38 | 39 | #endif // CL_VERSION_2_0 40 | #endif // HAVE_OPENCL_SVM 41 | 42 | #endif // OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_DEFINITIONS_HPP 43 | -------------------------------------------------------------------------------- /src/modules/common/test/test_algorithms_gemm1.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_algorithms_gemm1.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief gemm1算法朴素测试 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #define CATCH_CONFIG_MAIN 13 | #include "catch2/catch_test_macros.hpp" 14 | #include "algorithms/gemm/gemm_1.hpp" 15 | #include 16 | 17 | using namespace mvk; 18 | 19 | TEST_CASE("test mvk-common-algorithms-gemm1 ", "[mvk_common algorithms]") 20 | { 21 | std::vector> A{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; 22 | std::vector> B{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; 23 | std::vector> C(3, std::vector(3, 0)); 24 | 25 | MatrixMulti1(A, B, C); 26 | 27 | for(int i = 0; i < 3; i++) 28 | { 29 | for(int j = 0; j < 3; j++) 30 | { 31 | REQUIRE(A[i][j] == C[i][j]); 32 | } 33 | } 34 | 35 | //2x3 * 3x2 = 2x2 36 | A = {{1, 1, 1}, {2, 2, 2}}; 37 | B = {{1, 0}, {0, 0}, {0, 0}}; 38 | std::vector> CC(2, std::vector(2, 0)); 39 | 40 | MatrixMulti1(A, B, CC); 41 | REQUIRE(CC[0][0] == 1); 42 | REQUIRE(CC[0][1] == 0); 43 | REQUIRE(CC[1][1] == 0); 44 | REQUIRE(CC[1][0] == 2); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /test/filter/test_box_filter.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_box_filter.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-09 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | 13 | #define CATCH_CONFIG_MAIN 14 | #include "catch2/catch_test_macros.hpp" 15 | #include "filter/box_filter.hpp" 16 | 17 | using namespace mvk; 18 | 19 | TEST_CASE("test mvk-filter box-filter", "[mvk-filter]") 20 | { 21 | std::string rgb_path = std::string(DATA) + "/images/mvk_filter/512X512_lena_rgb.png"; 22 | Image rgb_img = LoadImage(rgb_path.c_str()); 23 | REQUIRE(!rgb_img.IsEmpty()); 24 | Image rgb_5x5_filter; 25 | REQUIRE(BoxFilter(rgb_img, rgb_5x5_filter, 5) == 0); 26 | REQUIRE(WriteImage(rgb_5x5_filter,"rgb_5x5_filter.png") != -1); 27 | 28 | Image rgb_15x15_filter; 29 | REQUIRE(BoxFilter(rgb_img, rgb_15x15_filter, 15) == 0); 30 | REQUIRE(WriteImage(rgb_5x5_filter,"rgb_15x15_filter.png") != -1); 31 | 32 | std::string mono_path = std::string(DATA) + "/images/mvk_filter/256X256_lena_mono.jpg"; 33 | Image mono = LoadImage(mono_path.c_str()); 34 | REQUIRE(!mono.IsEmpty()); 35 | Image mono_7x7_filter; 36 | REQUIRE(BoxFilter(mono, mono_7x7_filter, 7) == 0); 37 | REQUIRE(WriteImage(mono_7x7_filter,"mono_7x7_filter.png") != -1); 38 | } 39 | -------------------------------------------------------------------------------- /src/modules/core/image_manager.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "image_manager.hpp" 3 | 4 | ImageManager::~ImageManager() 5 | { 6 | ClearAllImages(); 7 | } 8 | 9 | int ImageManager::ClearAllImages() 10 | { 11 | image_list_.clear(); 12 | } 13 | 14 | Image ImageManager::CreateImage(const std::uint32_t width, const std::uint32_t height, const std::uint32_t channel, 15 | const bool no_share) 16 | { 17 | void* data = new std::uint8_t[width * height * channel](); 18 | return CreateImage(data, width, height, channel, no_share); 19 | } 20 | 21 | Image ImageManager::CreateImage(void *data, const std::uint32_t width, const std::uint32_t height, 22 | const std::uint32_t channel, const bool no_share) 23 | { 24 | auto status = no_share ? ShareStatus::NO_SHARE: ShareStatus::REUSE_USING; 25 | Image img = Image(Size(width, height), channel, (std::uint8_t*)data); 26 | image_list_.push_back({status, img}); 27 | 28 | return img; 29 | } 30 | 31 | void ImageManager::UpdateImageMemoryStatus(Image img, const ShareStatus status) 32 | { 33 | for(auto& [status, image]: image_list_) 34 | { 35 | if(status != ShareStatus::NO_SHARE && image.Ptr(0,0) == img.Ptr(0,0)) 36 | { 37 | status = status; 38 | } 39 | } 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/remove/caliper/caliper_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by $mango on 4/2/2020. 3 | // 4 | 5 | #include "caliper.h" 6 | 7 | 8 | int main() 9 | { 10 | 11 | cv::Mat img = cv::imread("../../images/blob.jpg", 0); 12 | cv::Ptr caliper = mvp::caliper::Caliper::CreateInstance(cv::Point2d(80, 60), 100, 0); 13 | caliper->Init(img); 14 | caliper->SetParam(); 15 | 16 | int64 s = cv::getTickCount(); 17 | caliper->Run(); 18 | int64 e = cv::getTickCount(); 19 | std::cout<<"Caliper cost time: "<< static_cast(e - s) /cv::getTickFrequency() * 1000<<"ms" <result.peak.x<<","<result.peak.y<result.front<result.center<result.back<result.front, 1, cv::Scalar(0,0,255), 1); 31 | cv::circle(imgShow, caliper->result.center, 1, cv::Scalar(0,0,255), 1); 32 | cv::circle(imgShow, caliper->result.back, 1, cv::Scalar(0,0,255), 1); 33 | 34 | cv::imshow("Caliper Test", imgShow); 35 | cv::waitKey(0); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/remove/ransac/ransac.hpp: -------------------------------------------------------------------------------- 1 | 2 | namespace mvp 3 | { 4 | class Ransac 5 | { 6 | private: 7 | /* data */ 8 | public: 9 | Ransac(/* args */); 10 | ~Ransac(); 11 | 12 | //---------算法流程------------- 13 | virtual int RunRansac() 14 | { 15 | while (!IsGoodEnough()) 16 | { 17 | //step1: 随机抽取估计模型最小数据集 18 | SampleMnimumData(); 19 | 20 | //step2: 使用最小数据集拟合模型 21 | FitModel(); 22 | 23 | //step3: 将所有数据代入拟合模型,计算出内点外点的数目 24 | ComputeCurrentInliers(); 25 | 26 | //step4: 比较当前模型和之前推出的最好的模型的“内点“的数量,记录最大“内点”数的模型参数和“内点”数 27 | RecordBestModel(); 28 | 29 | //step5: 重复1-4步,直到迭代结束或者当前模型已经足够好了(取决于判断条件) 30 | } 31 | } 32 | 33 | virtual int SampleMnimumData() = 0; 34 | 35 | virtual int FitModel() = 0; 36 | 37 | virtual int ComputeCurrentInliers() = 0; 38 | 39 | virtual int RecordBestModel() = 0; 40 | 41 | virtual bool IsGoodEnough() = 0; 42 | }; 43 | 44 | Ransac::Ransac(/* args */) 45 | { 46 | } 47 | 48 | Ransac::~Ransac() 49 | { 50 | } 51 | 52 | }//namespace mvp -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: clang 3 | env: 4 | global: 5 | - secure: "fDuBf8SfmCrImvklI1Opsj1mzEf45E5tckMZaOt6mDCiFT0R0E27x5389ACtc+b0wRZ8kHGaJHfsKksUNImsoP1U8sdBbYCn14XAQ0Ie6dyKHpY4JlmJqeVQ+6t3hXenIHUHEAX3EleUCrJyuxhUF3vtCM9TIuS0hYoUtHP6xN31U9GiBHOEs9LPl3uV3GsHzrGliuNSWaQO7V0B6a8saXSwUyP7eS0oSNxy0LDTfgfKxIA+sgH9j8oqtpJh6T/Cuytv391gZDZ49cT5BWvCyr0aJFW1k/zAmZGO6+wJS9xVf2eBIOeN72mjg05xL4vQ96/YWQIIDVMZM9s7rifZ0gkXVdyf8PSnFVhQjRFK3a7tY4FIZp9UFKaCl9ApYl3VdDq2aVo9a/P6YDii5yLaH4umOsZSjMxeErlHeJZMXhQQxIyfpfn9Zum1qICdFtEZOgZu5YacOcH309MtHOTo3fF0sL/viKSbxpCLYps2BDOfYlumJE9yX4ZqvcchpG38G4gX4WqUsdMiX4gmgTMQe1pL7T9a35gYnnG1AomGO5JkSkiL1XASndKxcHQs424L75E9Vj0J5+gHiHhFDlnenYxInPE/GP1jhNHEEp3pUYHofL6TgVqSk8SJiqNBV2Fk2csdnu0iUsqt69rzdlSLGNLchEtpdXjrrcL1yAD0cw4=" 6 | matrix: 7 | - TARGET=icc 8 | - TARGET=clang 9 | 10 | os: 11 | - linux 12 | - osx 13 | 14 | matrix: 15 | exclude: 16 | - os: osx 17 | env: TARGET=icc 18 | 19 | before_install: 20 | - '[[ "X${TARGET}" == "Xicc" ]] && ${TRAVIS_BUILD_DIR}/install-icc.sh || true' 21 | 22 | script: 23 | - source ~/.bashrc 24 | - mkdir build 25 | - cd build 26 | - env CC=${TARGET} cmake .. 27 | - cmake --build . 28 | - ctest --verbose 29 | 30 | after_script: 31 | - '[[ ! -z "${INTEL_INSTALL_PATH}" ]] && uninstall_intel_software || true' 32 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Modules/CMakeHostSystemInformationExtra/gcc_cpuinfo.c: -------------------------------------------------------------------------------- 1 | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | file Copyright.txt for details. */ 3 | 4 | #include 5 | 6 | #define PRINT_CPU_MICRO_ARCH(a) if(__builtin_cpu_is(a)){printf("%s\n", a);return 0;} 7 | 8 | int main() { 9 | #if defined(GCC_VERSION) 10 | __builtin_cpu_init (); 11 | #endif 12 | // these can be found by gcc8.2 13 | PRINT_CPU_MICRO_ARCH("znver1"); 14 | PRINT_CPU_MICRO_ARCH("amdfam17h"); 15 | PRINT_CPU_MICRO_ARCH("btver2"); 16 | PRINT_CPU_MICRO_ARCH("bdver4"); 17 | PRINT_CPU_MICRO_ARCH("bdver3"); 18 | PRINT_CPU_MICRO_ARCH("bdver2"); 19 | PRINT_CPU_MICRO_ARCH("bdver1"); 20 | PRINT_CPU_MICRO_ARCH("amdfam15h"); 21 | PRINT_CPU_MICRO_ARCH("btver1"); 22 | PRINT_CPU_MICRO_ARCH("istanbul"); 23 | PRINT_CPU_MICRO_ARCH("shanghai"); 24 | PRINT_CPU_MICRO_ARCH("barcelona"); 25 | PRINT_CPU_MICRO_ARCH("amdfam10h"); 26 | PRINT_CPU_MICRO_ARCH("amd"); 27 | PRINT_CPU_MICRO_ARCH("sandybridge"); 28 | PRINT_CPU_MICRO_ARCH("westmere"); 29 | PRINT_CPU_MICRO_ARCH("nehalem"); 30 | PRINT_CPU_MICRO_ARCH("corei7"); 31 | PRINT_CPU_MICRO_ARCH("core2"); 32 | PRINT_CPU_MICRO_ARCH("atom"); 33 | PRINT_CPU_MICRO_ARCH("intel"); 34 | 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/modules/filter/median_filter.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file median_filter.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 中值滤波 5 | * @version 0.1 6 | * @date 2022-03-31 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_MEDIAN_FILTER_HPP_ 13 | #define MVK_FILTER_MEDIAN_FILTER_HPP_ 14 | 15 | #include "core/image.hpp" 16 | 17 | 18 | namespace mvk 19 | { 20 | /** 21 | * @brief 中值滤波 22 | * 23 | * @param src(in) 输入图像 24 | * @param dst(out) 滤波输出图像 25 | * @param kernel_size(in) 滤波核大小 26 | * @param border_type(in) 边缘填充类型 27 | * @return int 28 | */ 29 | int MedianFilter(Image& src, 30 | Image& dst, 31 | const size_t kernel_size, 32 | const BORDER_TYPE& border_type = BORDER_TYPE::MIRROR); 33 | 34 | /** 35 | * @brief 3x3范围的小半径中值滤波,做特殊效率优化 36 | * 37 | * @param src(in) 输入图像 38 | * @param dst(out) 输出图像 39 | * @return int 40 | */ 41 | int MedianFilter3x3(Image& src, Image& dst); 42 | 43 | /** 44 | * @brief 5x5范围的小半径中值滤波,做特殊效率优化 45 | * 46 | * @param src(in) 输入图像 47 | * @param dst(out) 输出图像 48 | * @return int 49 | */ 50 | int MedianFilter5x5(Image& src, Image& dst); 51 | }//namespace mvk 52 | 53 | #endif //MVK_FILTER_MEDIAN_FILTER_HPP_ 54 | -------------------------------------------------------------------------------- /src/modules/lines_detection/include/lines_detection/lines_defines.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_defines.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief lines detection模块相关类型定义 5 | * @version 0.1 6 | * @date 2021-08-21 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_LINES_DEFINES_HPP_ 13 | #define MVK_LINES_DEFINES_HPP_ 14 | 15 | namespace mvk 16 | { 17 | /** 18 | * @brief 直线拟合算法枚举 19 | */ 20 | enum class LineFitMethod 21 | { 22 | REGRESSION = 0, ///< 标准的最小二乘拟合 23 | HUBER = 1, ///< 加权最小二乘拟合,通过Huber方法减小离群点的影响 24 | TUKEY = 2, ///< 加权最小二乘拟合,通过Tukey方法减小离群点的影响 25 | DROP = 3, ///< 加权的最小二乘法拟合,异常值的影响被消除 26 | GAUSS = 4, ///< 加权的最小二乘法拟合,异常值的影响被减小基于最逼近线上的所有其轮廓点的平均值和距离标准方差 27 | ORTHOGONAL = 5, ///< 基于正交回归方法拟合,标准最小二乘算法区别为使用投影误差代替残差计算 28 | RACSAC = 6 ///< 使用随机抽样一致性方法拟合 29 | };//enum class LineFitMethod 30 | 31 | 32 | /** 33 | * @brief 度量距离类型, 与OpenCV中cv::fitLine方法中定义一致 34 | */ 35 | enum class DistType 36 | { 37 | DIST_L2 = 0, 38 | DIST_L1 = 1, 39 | DISL_L12 = 2, 40 | DISL_HUBER = 3, 41 | }; 42 | } // namespace mvk 43 | 44 | 45 | #endif //MVK_LINES_DEFINES_H_ 46 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Modules/GetCPUSIMDFeatures.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | #[=======================================================================[.rst: 5 | GetCPUSIMDFeatures 6 | -------------------------- 7 | 8 | Get feature list for target architecture 9 | 10 | .. command:: get_cpu_simd_features 11 | 12 | get_cpu_simd_features( ) 13 | 14 | #]=======================================================================] 15 | 16 | 17 | include("${CMAKE_CURRENT_LIST_DIR}/GetCPUSIMDFeatures/GetX64SIMDFeatures.cmake") 18 | 19 | function(GET_CPU_SIMD_FEATURES outvar target_architecture) 20 | if("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(x86|AMD64)") 21 | get_x64_simd_features(features ${target_architecture}) 22 | elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(ARM|aarch64)") 23 | # FIXME implement me 24 | message(WARNING "get_arm_simd_features():Not implemented yet. Implement me!") 25 | elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(PPC|PPC64)") 26 | # FIXME implement me 27 | message(WARNING "get_ppc_simd_features():Not implemented yet. Implement me!") 28 | endif() 29 | set(${outvar} ${features} PARENT_SCOPE) 30 | endfunction() -------------------------------------------------------------------------------- /test/filter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_mango_filter) 2 | 3 | include_directories(./) 4 | 5 | add_executable(${PROJECT_NAME}_integral_image test_integral_image.cpp) 6 | target_link_libraries(${PROJECT_NAME}_integral_image mango_filter Catch2::Catch2WithMain) 7 | 8 | add_executable(${PROJECT_NAME}_box_filter test_box_filter.cpp) 9 | target_link_libraries(${PROJECT_NAME}_box_filter mango_filter Catch2::Catch2WithMain) 10 | 11 | add_executable(${PROJECT_NAME}_gaussian_filter test_gaussian_filter.cpp) 12 | target_link_libraries(${PROJECT_NAME}_gaussian_filter mango_filter Catch2::Catch2WithMain) 13 | 14 | add_executable(${PROJECT_NAME}_median_filter test_median_filter.cpp) 15 | target_link_libraries(${PROJECT_NAME}_median_filter mango_filter Catch2::Catch2WithMain) 16 | 17 | 18 | add_executable(${PROJECT_NAME}_threshold test_threshold.cpp) 19 | target_link_libraries(${PROJECT_NAME}_threshold mango_filter Catch2::Catch2WithMain) 20 | 21 | add_executable(${PROJECT_NAME}_sobel test_sobel.cpp) 22 | target_link_libraries(${PROJECT_NAME}_sobel mango_filter Catch2::Catch2WithMain) 23 | 24 | add_executable(${PROJECT_NAME}_blend test_blend.cpp) 25 | target_link_libraries(${PROJECT_NAME}_blend mango_filter mango_core Catch2::Catch2WithMain) 26 | 27 | add_executable(${PROJECT_NAME}_skin_detect test_skin_detect.cpp) 28 | target_link_libraries(${PROJECT_NAME}_skin_detect mango_filter mango_core Catch2::Catch2WithMain) -------------------------------------------------------------------------------- /src/modules/filter/threshold.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file threshold.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 阈值化处理 5 | * @version 0.1 6 | * @date 2022-04-15 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_FILTER_THRESHOLD_HPP_ 13 | #define MVK_FILTER_THRESHOLD_HPP_ 14 | 15 | #include "core/image.hpp" 16 | 17 | namespace mvk 18 | { 19 | /** 20 | * @brief 阈值化类型 21 | * 22 | */ 23 | enum class THRESHOLD_TYPE 24 | { 25 | THRESH_BINARY = 0, ///< if src > t dst = 255 else dst = 0 26 | THRESH_BINARY_INV = 1, ///< if src > t dst = 0 else dst = 255 27 | THRESH_TRUNC = 2, ///< if src > t dst = t else dst = src 28 | THRESH_TOZERO = 3, ///< if src > t dst = src else dst = 0 29 | THRESH_TOZERO_INV = 4 ///< if src > t dst = 0 else dst = src 30 | }; 31 | 32 | /** 33 | * @brief 阈值化处理图像,图像灰度值最大为255 34 | * 35 | * @param src(in) 输入图像 36 | * @param dst(out) 输出图像 37 | * @param thresh(in) 阈值 38 | * @param type(in) 阈值化类型, 详情参考@class THRESHOLD_TYPE "threshold.hpp" 39 | * @return int 40 | */ 41 | int Threshold(Image src, Image& dst, const uint8_t thresh, const THRESHOLD_TYPE type = THRESHOLD_TYPE::THRESH_BINARY); 42 | } //namespace mvk 43 | 44 | #endif //MVK_FILTER_THRESHOLD_HPP_ 45 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(mango) 4 | 5 | set (CMAKE_CXX_STANDARD 20) 6 | 7 | 8 | #设定安装目录 9 | set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install/") 10 | 11 | #设定可执行二进制文件的目录 12 | set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 13 | 14 | #设定存放编译出来的库文件的目录 15 | set( LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 16 | 17 | #并且把该目录设为连接目录 18 | link_directories( ${PROJECT_SOURCE_DIR}/bin) 19 | 20 | # 选择编译为动态库或静态库 21 | option(BUILD_STATIC_LIB "Build the library as static library?" OFF) 22 | if(BUILD_STATIC_LIB) 23 | add_definitions(-DBUILD_STATIC_LIB -DBUILD_STATIC_LIB_) 24 | endif() 25 | 26 | # 是否编译测试 27 | option(BUILD_TEST "Build the test cases?" ON) 28 | if(BUILD_TEST) 29 | # catch2 30 | Include(FetchContent) 31 | FetchContent_Declare( 32 | Catch2 33 | GIT_REPOSITORY https://github.com/catchorg/Catch2.git 34 | GIT_TAG v3.0.0-preview3 35 | ) 36 | FetchContent_MakeAvailable(Catch2) 37 | include(CTest) 38 | 39 | include_directories(./3rdparty/matplotlib) 40 | #find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED) 41 | endif() 42 | 43 | #OpenMP 44 | find_package(OpenMP REQUIRED) 45 | 46 | #simd 47 | include_directories(3rdparty) 48 | include_directories(3rdparty/cv_simd) 49 | 50 | # data 51 | add_definitions(-DDATA="${PROJECT_SOURCE_DIR}/data") 52 | 53 | # 添加源代码目录 54 | add_subdirectory(src) 55 | 56 | # 添加测试目录 57 | add_subdirectory(test) 58 | 59 | -------------------------------------------------------------------------------- /src/modules/common/include/algorithms/gemm/gemm_1.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gemm_1.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief gemm通用矩阵乘法的朴素实现 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_COMMON_ALGORITHMS_GEMM_1_HPP_ 13 | #define MVK_COMMON_ALGORITHMS_GEMM_1_HPP_ 14 | 15 | #include 16 | #include 17 | 18 | namespace mvk 19 | { 20 | 21 | /** 22 | * @brief C = A * B + C 的朴素算法实现 23 | * 24 | * A 大小为 m * k 25 | * B 大小为 k * n 26 | * @tparam T 27 | * @param A 28 | * @param B 29 | * @param C 30 | */ 31 | template 32 | void MatrixMulti1(const std::vector>& A, const std::vector>& B, std::vector>& C) 33 | { 34 | assert(!A.empty() && !B.empty() && !C.empty()); 35 | assert(A.size() == C.size() && A[0].size() == B.size() && B[0].size() == C[0].size()); 36 | int m = A.size(); 37 | int k = A[0].size(); 38 | int n = B.size(); 39 | 40 | for(int j = 0; j < n; j++) 41 | { 42 | for(int i = 0; i < m; i++) 43 | { 44 | for(int t = 0; t < k; t++) 45 | { 46 | C[i][j] += A[i][t] * B[t][j]; 47 | } 48 | } 49 | } 50 | } 51 | }//namespace mvk 52 | 53 | #endif //MVK_COMMON_ALGORITHMS_GEMM_1_HPP_ 54 | -------------------------------------------------------------------------------- /src/modules/common/include/common/line.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file line.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-09-07 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_LINE_H_ 13 | #define MVK_LINE_H_ 14 | 15 | #include "common/point.hpp" 16 | 17 | namespace mvk 18 | { 19 | /** 20 | * @brief 直线段,使用两点表示 21 | * 22 | */ 23 | template 24 | struct Line 25 | { 26 | Point p1; 27 | Point p2; 28 | Line(): p1(Point()), p2(Point()){} 29 | Line(const Point& p1_, const Point& p2_) 30 | :p1(p1_), p2(p2_) 31 | { 32 | 33 | } 34 | 35 | /** 36 | * @brief 判断两直线是否垂直 37 | * 38 | * @param other 39 | * @return true 40 | * @return false 41 | */ 42 | bool IsOrthogonal(const Line& other) const; 43 | 44 | /** 45 | * @brief 46 | * 47 | * @param other 48 | * @return true 49 | * @return false 50 | */ 51 | bool IsParallel(const Line& other) const; 52 | }; 53 | 54 | template 55 | bool Line::IsOrthogonal(const Line& other) const 56 | { 57 | Point v1 = p1 - p2; 58 | Point v2 = other.p1 - other.p2; 59 | return v1.Dot(v2) == 0; 60 | } 61 | 62 | } // namespace mvk 63 | 64 | 65 | #endif //MVK_LINE_H_ 66 | -------------------------------------------------------------------------------- /src/remove/linefit/linefit.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file linefit.cpp 4 | * @brief 直线拟合源文件 5 | * @details 基于最小二乘、huber、tukey等方法拟合直线 6 | * @author 芒果 7 | * @date 2020-4-10 8 | * @version 1.0.0 9 | */ 10 | 11 | 12 | #include "linefit.h" 13 | 14 | #include 15 | 16 | namespace mvp 17 | { 18 | std::shared_ptr LineFit::CreateLineFitTool() 19 | { 20 | return std::make_shared(); 21 | } 22 | 23 | int LineFit::SetParam(const std::string& json_str) 24 | { 25 | return 0; 26 | } 27 | 28 | 29 | int LineFit::SetInputPointArray(const std::vector& point_array) 30 | { 31 | return 0; 32 | } 33 | 34 | 35 | int LineFit::Run() 36 | { 37 | 38 | RunRansac(); 39 | 40 | return 0; 41 | } 42 | 43 | int LineFit::SampleMnimumData() 44 | { 45 | return 0; 46 | } 47 | 48 | int LineFit::FitModel() 49 | { 50 | return 0; 51 | } 52 | 53 | int LineFit::ComputeCurrentInliers() 54 | { 55 | return 0; 56 | } 57 | 58 | int LineFit::RecordBestModel() 59 | { 60 | return 0; 61 | } 62 | 63 | int LineFit::IsGoodEnough() 64 | { 65 | return 0; 66 | } 67 | 68 | int LineFit::SetOutliersDistanceThreshold(const double& threshold) 69 | { 70 | return 0; 71 | } 72 | 73 | 74 | int LineFit::SetForceRemoveRatio(const double& ratio) 75 | { 76 | return 0; 77 | } 78 | 79 | 80 | int LineFit::SetForceRemoveNum(const int& num) 81 | { 82 | return 0; 83 | } 84 | 85 | 86 | int LineFit::SetMaxIterNum(const int& num) 87 | { 88 | return 0; 89 | } 90 | }//namespace mvp 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/remove/debugtool/plot.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by $mango on 4/1/2020. 3 | // 4 | 5 | #include "plot.h" 6 | 7 | // y = f(x), (x,y) 8 | 9 | namespace mvp 10 | { 11 | void Plot(const std::vector &x, const std::vector &y, const std::string& title) 12 | { 13 | // 1. input parameters 14 | CV_Assert(x.size() == y.size() && !x.empty()); 15 | 16 | // 2. transfer to mat 17 | int trow = 0; 18 | for(const auto& e: y) 19 | { 20 | if (trow< e) 21 | trow = e; 22 | } 23 | int col = x.size(); 24 | int row = trow + 50; 25 | 26 | cv::Mat m = cv::Mat(row, col, CV_8UC3, cv::Scalar::all(255)); 27 | // Draw function Line 28 | for(int i = 0; i < x.size(); ++i) // 29 | { 30 | m.at(row - y[i], x[i])[0] = 255;//blue 31 | m.at(row - y[i], x[i])[1] = 0; 32 | m.at(row - y[i], x[i])[2] = 0; 33 | } 34 | // std::cout<<"row:"< 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | int main(int argc, char** argv) 20 | { 21 | std::vector> img_sizes = {{640, 480}, {1280, 720}, {1280, 960}, {1920, 1080}, {1600, 1200}, {2048, 1536}, {2592, 1944}, {3264, 2448}, {3840, 2160}, {4224, 3168}, {5344, 4106}}; 22 | 23 | std::cout << "------------opencv mono median-filter3x3 benchmark-------------\n"; 24 | 25 | std::ofstream out_csv; 26 | out_csv.open("cv-threshold-benchmark.csv", std::ios::out); 27 | for(auto&& [len, wid] : img_sizes) 28 | { 29 | cv::Mat img = cv::Mat(len, wid, CV_8UC1); 30 | cv::Mat dst; 31 | auto t0 = std::chrono::system_clock::now(); 32 | for(int i = 0; i < 10; i++) 33 | { 34 | cv::threshold(img, dst, 128, 255, 0); 35 | } 36 | auto t1 = std::chrono::system_clock::now(); 37 | std::cout << std::to_string(len) + "x" + std::to_string(wid) + " cost " << std::chrono::duration_cast(t1 - t0).count() / 10000.0 << " ms.\n"; 38 | out_csv <(t1 - t0).count() / 10000.0 << std::endl; 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/openvx/ovx_defs.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | // Copyright (C) 2016, Intel Corporation, all rights reserved. 6 | // Third party copyrights are property of their respective owners. 7 | 8 | // OpenVX related definitions and declarations 9 | 10 | #pragma once 11 | #ifndef OPENCV_OVX_DEFS_HPP 12 | #define OPENCV_OVX_DEFS_HPP 13 | 14 | #include "cvconfig.h" 15 | 16 | // utility macro for running OpenVX-based implementations 17 | #ifdef HAVE_OPENVX 18 | 19 | #define IVX_HIDE_INFO_WARNINGS 20 | #define IVX_USE_OPENCV 21 | #include "ivx.hpp" 22 | 23 | namespace cv{ 24 | namespace ovx{ 25 | // Get common thread local OpenVX context 26 | CV_EXPORTS_W ivx::Context& getOpenVXContext(); 27 | 28 | template inline bool skipSmallImages(int w, int h) { return w*h < 3840 * 2160; } 29 | }} 30 | 31 | #define CV_OVX_RUN(condition, func, ...) \ 32 | if (cv::useOpenVX() && (condition) && func) \ 33 | { \ 34 | return __VA_ARGS__; \ 35 | } 36 | 37 | #else 38 | #define CV_OVX_RUN(condition, func, ...) 39 | #endif // HAVE_OPENVX 40 | 41 | // Throw an error in debug mode or try another implementation in release 42 | #ifdef _DEBUG 43 | #define VX_DbgThrow(s) CV_Error(cv::Error::StsInternal, (s)) 44 | #else 45 | #define VX_DbgThrow(s) return false 46 | #endif 47 | 48 | #endif // OPENCV_OVX_DEFS_HPP 49 | -------------------------------------------------------------------------------- /src/remove/libinfo/opencvinfo.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file opencvinfo.h 4 | * @brief OpenCV信息相关 5 | * @details - 6 | * @author 芒果 7 | * @date 2020-3-20 8 | * @version 1.0.0 9 | */ 10 | 11 | #ifndef CMAKE_PROJECT_TEMPLATE_OPENCVINFO_H 12 | #define CMAKE_PROJECT_TEMPLATE_OPENCVINFO_H 13 | 14 | #include "opencv2/opencv.hpp" 15 | 16 | #include 17 | #include 18 | 19 | namespace mvp 20 | { 21 | class OpenCVInfo 22 | { 23 | public: 24 | void Print(); 25 | };// 26 | 27 | class MVLInfo 28 | { 29 | public: 30 | explicit MVLInfo(): MV_MAJOR_VERSION(0), MV_MINOR_VERSION(1), MV_SUBMINOR_VERSION(1) , MV_VERSION("0.1.1") {} 31 | static cv::Ptr CreateInstance(); 32 | 33 | int GetMajorVersion() const { return MV_MAJOR_VERSION;} 34 | int GetMinorVersino() const { return MV_MINOR_VERSION;} 35 | int GetSubminorVersion() const { return MV_SUBMINOR_VERSION; } 36 | 37 | int GetOpenCVMajorVersion() const { return CV_MAJOR_VERSION;} 38 | int GetOpenCVMinorVersino() const { return CV_MINOR_VERSION;} 39 | int GetOpenCVSubminorVersion() const { return CV_SUBMINOR_VERSION; } 40 | 41 | std::string GetMVLInfo() const; 42 | std::string GetOpenCVInfo() const; 43 | void PrintMVLInfo() const; 44 | void PrintOpenCVBuildInfo() const; 45 | 46 | private: 47 | const int MV_MAJOR_VERSION; 48 | const int MV_MINOR_VERSION; 49 | const int MV_SUBMINOR_VERSION; 50 | 51 | const std::string MV_VERSION; 52 | };//MVLInfo 53 | 54 | }// namespace mvp 55 | #endif //CMAKE_PROJECT_TEMPLATE_OPENCVINFO_H 56 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Copyright.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018 Hiroshi Miura 2 | Copyright 2010-2016 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | * Neither the name of Kitware, Inc. nor the names of Contributors 16 | may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/detail/dispatch_helper.impl.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP 6 | #define OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP 7 | 8 | //! @cond IGNORED 9 | 10 | namespace cv { 11 | namespace detail { 12 | 13 | template class Functor, typename... Args> 14 | static inline void depthDispatch(const int depth, Args&&... args) 15 | { 16 | switch (depth) 17 | { 18 | case CV_8U: 19 | Functor{}(std::forward(args)...); 20 | break; 21 | case CV_8S: 22 | Functor{}(std::forward(args)...); 23 | break; 24 | case CV_16U: 25 | Functor{}(std::forward(args)...); 26 | break; 27 | case CV_16S: 28 | Functor{}(std::forward(args)...); 29 | break; 30 | case CV_32S: 31 | Functor{}(std::forward(args)...); 32 | break; 33 | case CV_32F: 34 | Functor{}(std::forward(args)...); 35 | break; 36 | case CV_64F: 37 | Functor{}(std::forward(args)...); 38 | break; 39 | case CV_16F: 40 | default: 41 | CV_Error(cv::Error::BadDepth, "Unsupported matrix type."); 42 | }; 43 | } 44 | 45 | }} 46 | 47 | //! @endcond 48 | 49 | #endif //OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP 50 | -------------------------------------------------------------------------------- /src/modules/filter/benchmark/threshold_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file threshold_benchmark.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-15 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #include "filter/threshold.hpp" 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace mvk; 20 | 21 | int main(int argc, char** argv) 22 | { 23 | std::vector> img_sizes = {{640, 480}, {1280, 720}, {1280, 960}, {1920, 1080}, {1600, 1200}, {2048, 1536}, {2592, 1944}, {3264, 2448}, {3840, 2160}, {4224, 3168}, {5344, 4106}}; 24 | std::ofstream out_csv; 25 | out_csv.open("mvk-threshold-benchmark.csv", std::ios::out); 26 | 27 | std::cout << "-------------mvk-nodes filter threshold benchenmark------------------\n"; 28 | for(auto&& [len, wid]: img_sizes) 29 | { 30 | Image src(len, wid, 100); 31 | Image dst; 32 | auto t0 = std::chrono::system_clock::now(); 33 | for(int i = 0; i < 10; i++) 34 | { 35 | Threshold(src, dst, 128, THRESHOLD_TYPE::THRESH_BINARY); 36 | } 37 | auto t1 = std::chrono::system_clock::now(); 38 | std::cout <(t1 - t0).count() / 10000.0 << " ms." << std::endl; 39 | out_csv <(t1 - t0).count() / 10000.0 << std::endl; 40 | } 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/modules/filter/skin_detect.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/3/7. 3 | // 4 | 5 | 6 | #include "skin_detect.hpp" 7 | 8 | int SkinDetectByColorSpace(Image src, Image& dst) 9 | { 10 | if(src.IsEmpty()){return -1;} 11 | 12 | dst = Image(src.GetSize(), IMAGE_TYPE::IMAGE_8UC1); 13 | int w = src.GetSize().width; 14 | int h = src.GetSize().height; 15 | 16 | auto hsv = src.Convert(CONVERT_TYPE::RGB2HSV); 17 | 18 | for(int i = 0; i < h; i++) 19 | { 20 | for(int j = 0; j < w; j++) 21 | { 22 | auto r = src.Ptr(j ,i)[0]; 23 | auto g = src.Ptr(j ,i)[1]; 24 | auto b = src.Ptr(j ,i)[2]; 25 | auto h = hsv.Ptr(j ,i)[0]; 26 | auto s = hsv.Ptr(j ,i)[1]; 27 | auto v = src.Ptr(j ,i)[2]; 28 | 29 | if((h < 17 && 15 <= s && s <= 170) 30 | && ((r > 95 && b > 20 && std::max({r , g, b}) - std::min({r, g, b}) > 15 && std::abs(r -g ) > 15 && r > g && r > b) 31 | || (r > 220 && g > 210 && b > 170 && std::abs(r - g) <= 15 && r > b && g > b))) 32 | { 33 | //is skin 34 | dst.Ptr(j, i)[0] = 255; 35 | dst.Ptr(j, i)[1] = 255; 36 | dst.Ptr(j, i)[2] = 255; 37 | }else 38 | { 39 | dst.Ptr(j, i)[0] = 0; 40 | dst.Ptr(j, i)[1] = 0; 41 | dst.Ptr(j, i)[2] = 0; 42 | } 43 | } 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /src/modules/lines_detection/include/lines_detection/lines_detection.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_detection.h 3 | * @author mango (2321544362@qq.com) 4 | * @brief 直线检测类声明 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_LINES_DETECTION_HPP_ 13 | #define MVK_LINES_DETECTION_HPP_ 14 | 15 | #include "lines_detection/lines_defines.hpp" 16 | #include "image/image.hpp" 17 | #include "common/rotate_rectangle.hpp" 18 | #include "common/line.hpp" 19 | 20 | #include 21 | 22 | namespace mvk 23 | { 24 | class MVK_LINES_EXPORT LinesDetectionImpl; ///< 直线检测类实现类前置声明 25 | 26 | /** 27 | * @brief 直线检测类声明 28 | * 29 | */ 30 | class MVK_LINES_EXPORT LinesDetection 31 | { 32 | private: 33 | std::shared_ptr lines_impl_; ///< 实现类对象指针 34 | public: 35 | LinesDetection(); 36 | ~LinesDetection(); 37 | 38 | int SetImage(const Image& image); 39 | 40 | int SetAllDetectionParameters(const std::string& json_format_paramters); 41 | 42 | int SetDetectionRoi(const RotateRectangle& rect_roi); 43 | 44 | int SetCaliperNumber(const size_t& number); 45 | 46 | int SetEdgePolarity(const Polarity& polarity); 47 | 48 | int SetLineFitMethod(const LineFitMethod& method); 49 | 50 | int Detect(); 51 | 52 | Line GetLine() const; 53 | 54 | int GetInlierPoints(std::vector& inliers) const; 55 | 56 | int GetOutlierPoints(std::vector& outliers) const; 57 | }; 58 | } // namespace mvk 59 | 60 | 61 | #endif //MVK_LINES_DETECTION_H_ 62 | -------------------------------------------------------------------------------- /src/modules/lines_detection/README.md: -------------------------------------------------------------------------------- 1 | # MVK Lines Detection 2 | 3 | mvk-lines-detection(machine vision lines detection) 2d points line fitting methods implement. Is a module for [MVK](https://github.com/mangosroom/machine-vision-algorithms-library) 4 | 5 | # About The Project 6 | 7 | ## How to Build 8 | 9 | ### Requirements 10 | 11 | - OpenCV 3.x or later 12 | - C++11 or later 13 | - CMake 3.14 or later 14 | 15 | #### Windows 16 | 17 | ```bash 18 | # 1. Download the source code 19 | git clone https://github.com/mangosroom/mvk_line_fitting.git 20 | 21 | # 2. CMake generate the Visual Studio solution 22 | cd mvk_line_fitting 23 | mkdir build 24 | cmake -S ./ -B ./build -G "Visual Studio 16 2019" # x64 default 25 | # cmake -S ./ -B ./build -G "Visual Studio 16 2019" -A Win32 26 | 27 | # 3. Build 28 | cmake --build build --config Debug 29 | cmake --build build --config Release 30 | ``` 31 | 32 | ### Linux 33 | 34 | ```bash 35 | # 1. Download the source code 36 | git clone https://github.com/mangosroom/mvk_line_fitting.git 37 | 38 | # 2. CMake generate the Visual Studio solution 39 | cd mvk_line_fitting 40 | mkdir build 41 | cmake -S ./ -B ./build -G 42 | 43 | # 3. Build 44 | cmake --build build --config Debug 45 | cmake --build build --config Release 46 | ``` 47 | 48 | # Usage 49 | 50 | # Roadmap 51 | 52 | | Method | State | Introduction | Remarks | 53 | | ---- | ---- | ------ | ------ | 54 | | Regresion | Completed | - | - | 55 | | Huber | - | - | - | 56 | | Tukey | - | - | - | 57 | | Racsac | - | - | - | 58 | | Orthogonal | - | - | - | 59 | 60 | # License 61 | 62 | [Apache License 2.0](https://github.com/mangosroom/mvk_line_fitting/blob/main/LICENSE) 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/remove/blobdetect/blobdetect_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 3/20/2020. 3 | // 4 | 5 | #include "blobdetect.h" 6 | #include "opencv2/opencv.hpp" 7 | 8 | #include 9 | 10 | int main() 11 | { 12 | std::cout<<"blob detection"< blobdetect = mv::BlobDetect::CreateInstance(); 14 | cv::Mat img = cv::imread("../../images/blob.jpg"); 15 | if(img.empty()) 16 | return -1; 17 | blobdetect->Init(img); 18 | blobdetect->SetParams(); 19 | int s = cv::getTickCount(); 20 | blobdetect->Run(); 21 | int e = cv::getTickCount(); 22 | std::cout<<"BlobDetect cost time: "<< static_cast(e - s) /cv::getTickFrequency() * 1000<<"ms" <PrintResultInfo(); 24 | 25 | // blobdetect->PrintParameter(); 26 | // blobdetect->DrawOutline(); 27 | blobdetect.release(); 28 | 29 | Ptr sblobdetect = cv::SimpleBlobDetector::create(); 30 | std::vector kps; 31 | s = cv::getTickCount(); 32 | sblobdetect->detect(img, kps); 33 | e = cv::getTickCount(); 34 | std::cout<<"SimpleBlobDetector cost time: "<< static_cast(e - s) /cv::getTickFrequency() * 1000<<"ms" < 21 | 22 | namespace mvk 23 | { 24 | class MVK_LINES_EXPORT LinesDetectionImpl 25 | { 26 | private: 27 | Line line_; ///< 拟合直线结果 28 | std::vector inliers_; ///< 参与直线拟合的内点 29 | std::vector outliers_; ///< 不参与直线拟合的离群点 30 | public: 31 | LinesDetectionImpl(/* args */); 32 | ~LinesDetectionImpl(); 33 | 34 | 35 | int SetImage(const Image& image); 36 | 37 | int SetAllDetectionParameters(const std::string& json_format_paramters); 38 | 39 | int SetDetectionRoi(const RotateRectangle& rect_roi); 40 | 41 | int SetCaliperNumber(const size_t& number); 42 | 43 | int SetEdgePolarity(const Polarity& polarity); 44 | 45 | int SetLineFitMethod(const LineFitMethod& method); 46 | 47 | int Detect(); 48 | 49 | Line GetLine() const; 50 | 51 | int GetInlierPoints(std::vector& inliers) const; 52 | 53 | int GetOutlierPoints(std::vector& outliers) const; 54 | }; 55 | 56 | } // namespace mvk 57 | 58 | #endif //MVK_LINES_DETECTION_IMPL_H_ 59 | -------------------------------------------------------------------------------- /src/modules/filter/benchmark/sobel_benchmark.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sobel_benchmark.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-16 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #include "filter/sobel.hpp" 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace mvk; 20 | 21 | int main(int argc, char** argv) 22 | { 23 | std::vector> img_sizes = {{640, 480}, {1280, 720}, {1280, 960}, {1920, 1080}, {1600, 1200}, {2048, 1536}, {2592, 1944}, {3264, 2448}, {3840, 2160}, {4224, 3168}, {5344, 4106}}; 24 | std::ofstream out_csv; 25 | out_csv.open("mvk-sobel-benchmark.csv", std::ios::out); 26 | 27 | std::cout << "-------------mvk-nodes filter sobel benchenmark------------------\n"; 28 | for(auto&& [len, wid]: img_sizes) 29 | { 30 | Image src(len, wid, 100); 31 | Image dst; 32 | int rows = src.GetHeight(); 33 | int cols = src.GetWidth(); 34 | Matrix gx(rows, cols); 35 | Matrix gy(rows, cols); 36 | auto t0 = std::chrono::system_clock::now(); 37 | for(int i = 0; i < 10; i++) 38 | { 39 | Sobel(src, dst, gx, gy); 40 | } 41 | auto t1 = std::chrono::system_clock::now(); 42 | std::cout <(t1 - t0).count() / 10000.0 << " ms." << std::endl; 43 | out_csv <(t1 - t0).count() / 10000.0 << std::endl; 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /doc/benchmark/median-filter.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | - Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz 4 | - ubuntu 20.04 lts 5 | - gcc 9.3 6 | 7 | ``` 8 | -------------mvk-nodes filter mono median-filter3x3 benchenmark------------------ 9 | 640x480 cost 0.2073 ms. 10 | 1280x720 cost 0.5893 ms. 11 | 1280x960 cost 0.5588 ms. 12 | 1920x1080 cost 0.9262 ms. 13 | 1600x1200 cost 0.6271 ms. 14 | 2048x1536 cost 1.3759 ms. 15 | 2592x1944 cost 1.7738 ms. 16 | 3264x2448 cost 2.8808 ms. 17 | 3840x2160 cost 3.016 ms. 18 | 4224x3168 cost 4.7302 ms. 19 | 5344x4106 cost 7.3888 ms. 20 | -------------mvk-nodes filter rgb median-filter3x3 benchenmark------------------ 21 | 640x480 cost 0.4803 ms. 22 | 1280x720 cost 1.2934 ms. 23 | 1280x960 cost 1.4051 ms. 24 | 1920x1080 cost 2.3873 ms. 25 | 1600x1200 cost 1.7188 ms. 26 | 2048x1536 cost 4.6391 ms. 27 | 2592x1944 cost 21.1008 ms. 28 | 3264x2448 cost 33.0671 ms. 29 | 3840x2160 cost 33.709 ms. 30 | 4224x3168 cost 54.631 ms. 31 | 5344x4106 cost 88.0677 ms. 32 | -------------mvk-nodes filter mono median-filter5x5 benchenmark------------------ 33 | 640x480 cost 1.0758 ms. 34 | 1280x720 cost 1.6997 ms. 35 | 1280x960 cost 2.2723 ms. 36 | 1920x1080 cost 3.076 ms. 37 | 1600x1200 cost 3.1631 ms. 38 | 2048x1536 cost 4.4575 ms. 39 | 2592x1944 cost 6.221 ms. 40 | 3264x2448 cost 8.8507 ms. 41 | 3840x2160 cost 8.66 ms. 42 | 4224x3168 cost 14.1367 ms. 43 | 5344x4106 cost 21.0628 ms. 44 | -------------mvk-nodes filter rgb median-filter5x5 benchenmark------------------ 45 | 640x480 cost 1.2297 ms. 46 | 1280x720 cost 2.7997 ms. 47 | 1280x960 cost 3.5918 ms. 48 | 1920x1080 cost 5.518 ms. 49 | 1600x1200 cost 5.1136 ms. 50 | 2048x1536 cost 8.5474 ms. 51 | 2592x1944 cost 13.8798 ms. 52 | 3264x2448 cost 19.7184 ms. 53 | 3840x2160 cost 20.8748 ms. 54 | 4224x3168 cost 45.7735 ms. 55 | 5344x4106 cost 73.6998 ms. 56 | ``` -------------------------------------------------------------------------------- /src/modules/lines_detection/src/lines_detection_impl.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_detection_impl.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "lines_detection/lines_detection_impl.h" 13 | 14 | namespace mvk 15 | { 16 | LinesDetectionImpl::LinesDetectionImpl() 17 | : line_(Line(Point(), Vector())) 18 | { 19 | 20 | } 21 | 22 | LinesDetectionImpl::~LinesDetectionImpl() 23 | { 24 | } 25 | 26 | int LinesDetectionImpl::SetImage(const Image& image) 27 | { 28 | return 0; 29 | } 30 | 31 | int LinesDetectionImpl::SetAllDetectionParameters(const std::string& json_format_paramters) 32 | { 33 | return 0; 34 | } 35 | 36 | int LinesDetectionImpl::SetDetectionRoi(const RotateRectangle& rect_roi) 37 | { 38 | return 0; 39 | } 40 | 41 | int LinesDetectionImpl::SetCaliperNumber(const size_t& number) 42 | { 43 | return 0; 44 | } 45 | 46 | int LinesDetectionImpl::SetEdgePolarity(const Polarity& polarity) 47 | { 48 | return 0; 49 | } 50 | 51 | int LinesDetectionImpl::SetLineFitMethod(const LineFitMethod& method) 52 | { 53 | return 0; 54 | } 55 | 56 | int LinesDetectionImpl::Detect() 57 | { 58 | return 0; 59 | } 60 | 61 | Line LinesDetectionImpl::GetLine() const 62 | { 63 | return line_; 64 | } 65 | 66 | int LinesDetectionImpl::GetInlierPoints(std::vector& inliers) const 67 | { 68 | inliers = inliers_; 69 | return 0; 70 | } 71 | 72 | int LinesDetectionImpl::GetOutlierPoints(std::vector& outliers) const 73 | { 74 | outliers = outliers_; 75 | return 0; 76 | } 77 | } // namespace mvk 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/modules/core/data_source.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "data_source.hpp" 3 | #include "graph.hpp" 4 | 5 | DataSource::DataSource(const std::string &name) 6 | : Task(name) 7 | { 8 | 9 | } 10 | 11 | void DataSource::SetData(const std::vector &data, std::shared_ptr& graph_context) 12 | { 13 | data_ = data; 14 | for(int i = 0; i < data_.size(); ++i) 15 | { 16 | //auto name_in_manager = name_ + "_input_" + std::to_string(i); 17 | //graph_context->graph_data_manager->CreateData(name_in_manager, data_[i]); 18 | } 19 | } 20 | 21 | int DataSource::InitTask() 22 | { 23 | return 0; 24 | } 25 | 26 | std::vector> DataSource::GetDefines() const 27 | { 28 | std::vector> defines(data_.size()); 29 | for(int i = 0; i < data_.size(); ++i) 30 | { 31 | defines[i].first = "input_" + std::to_string(i);//name; 32 | defines[i].second = data_[i].type().name();//type; 33 | } 34 | return defines; 35 | } 36 | 37 | std::vector> DataSource::GetInputDefines() const 38 | { 39 | return {};//no input config 40 | } 41 | 42 | std::vector> DataSource::GetOutputDefines() const 43 | { 44 | return GetDefines(); 45 | } 46 | 47 | int DataSource::RunTask() 48 | { 49 | for(int i = 0; i < data_.size(); ++i) 50 | { 51 | output_data_[GetDefines()[i].first] = data_[i]; 52 | if(data_[i].has_value() && data_[i].type().name() == typeid(Image).name()) 53 | { 54 | auto img = std::any_cast(data_[i]); 55 | } 56 | } 57 | } 58 | 59 | int DataSource::UpdateParams(const std::string &name, const std::any value) 60 | { 61 | return 0; 62 | } 63 | 64 | int DataSource::Release() 65 | { 66 | data_.clear(); 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /test/filter/test_integral_image.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_integral_image.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-09 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #define CATCH_CONFIG_MAIN 13 | #include "catch2/catch_test_macros.hpp" 14 | #include "filter/integral_image.hpp" 15 | 16 | using namespace mvk; 17 | 18 | TEST_CASE("test mvk-filter integral-image","[mvk-filter]") 19 | { 20 | //5x5 21 | //---------------- 22 | // 1 1 1 1 1 23 | // 1 1 1 1 1 24 | // 1 1 1 1 1 25 | // 1 1 1 1 1 26 | // 1 1 1 1 1 27 | std::uint8_t* data = new std::uint8_t[25](); 28 | for(int i = 0; i < 25; i++) 29 | { 30 | data[i] = 1; 31 | } 32 | Image img(Size(5, 5), IMAGE_TYPE::IMAGE_8UC1,data); 33 | Matrix integral; 34 | REQUIRE(ComputeIntegral(img, integral) == 0); 35 | REQUIRE(integral(0, 0) == 1); 36 | REQUIRE(integral(0, 4) == 5); 37 | REQUIRE(integral(4, 0) == 5); 38 | REQUIRE(integral(2, 2) == 9); 39 | REQUIRE(integral(4, 4) == 25); 40 | 41 | std::uint8_t* rgb_data = new std::uint8_t[25*3](); 42 | for(int i = 0; i < 75; i++) 43 | { 44 | if(i%3 == 0) 45 | { 46 | rgb_data[i] = 1; 47 | }else if(i%3 == 1) 48 | { 49 | rgb_data[i] = 2; 50 | }else 51 | { 52 | rgb_data[i] = 3; 53 | } 54 | } 55 | Image rgb(Size(5, 5), IMAGE_TYPE::IMAGE_8UC3, rgb_data); 56 | Matrix rgb_integral; 57 | REQUIRE(ComputeIntegral(rgb, rgb_integral) == 0); 58 | REQUIRE(rgb_integral(0, 0) == 1); 59 | REQUIRE(rgb_integral(0, 1) == 2); 60 | REQUIRE(rgb_integral(0, 2) == 3); 61 | REQUIRE(rgb_integral(4, 4 * 3) == 25); 62 | REQUIRE(rgb_integral(4, 4 * 3 + 1) == 50); 63 | REQUIRE(rgb_integral(4, 4 * 3 + 2) == 75); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/modules/caliper/test/test_caliper.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file test_caliper.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-25 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #include "caliper/caliper.hpp" 13 | #include "filter/gaussian_filter.hpp" 14 | #include 15 | #include 16 | #include "matplotlibcpp.h" 17 | namespace plt = matplotlibcpp; 18 | 19 | using namespace mvk; 20 | 21 | 22 | 23 | int main(int argc, char** argv) 24 | { 25 | Caliper caliper(CALIPER_MODE::SINGLE_EDGE); 26 | Image img(800, 400, 255); 27 | Image rgb(800, 400, {255, 255, 255}); 28 | 29 | //画横线 30 | for(int i = 0; i < 400; i++) 31 | { 32 | for(int j = 0; j < 800; j++) 33 | { 34 | if((j / 100) % 2 == 0) 35 | { 36 | img.GetPixel(i, j)[0] = 0; 37 | rgb.GetPixel(i, j)[0] = 0; 38 | rgb.GetPixel(i, j)[1] = 0; 39 | rgb.GetPixel(i, j)[2] = 0; 40 | } 41 | } 42 | } 43 | //高斯滤波处理 44 | Image mono; 45 | GaussianFilter(img, mono, 5); 46 | //mono.Save("caliper_mono.png"); 47 | 48 | caliper.SetInputImage(img); 49 | RotateRectf roi; 50 | roi.points[0] = {50.0f, 200.0f}; 51 | roi.points[1] = {750.0f, 200.0f}; 52 | roi.points[2] = {750.0f, 300.0f}; 53 | roi.points[3] = {50.0f, 300.0f}; 54 | caliper.SetROI(roi); 55 | 56 | int ret = caliper.Measure(); 57 | std::cout << " ret = "<< ret << std::endl; 58 | 59 | auto result = caliper.GetResult(); 60 | 61 | for(auto& p: result.peaks) 62 | { 63 | std::cout << p.p.x << "," << p.p.y << std::endl; 64 | rgb.GetPixel(p.p.y, p.p.x)[0] = 255; 65 | } 66 | 67 | plt::plot(result.project_curve); 68 | plt::save("project_curve.png"); 69 | rgb.Save("caliper.png"); 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/utils/logger.defines.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_LOGGER_DEFINES_HPP 6 | #define OPENCV_LOGGER_DEFINES_HPP 7 | 8 | //! @addtogroup core_logging 9 | //! @{ 10 | 11 | // Supported logging levels and their semantic 12 | #define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogLevel() call 13 | #define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error) 14 | #define CV_LOG_LEVEL_ERROR 2 //!< Error message 15 | #define CV_LOG_LEVEL_WARN 3 //!< Warning message 16 | #define CV_LOG_LEVEL_INFO 4 //!< Info message 17 | #define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build. 18 | #define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. 19 | 20 | namespace cv { 21 | namespace utils { 22 | namespace logging { 23 | 24 | //! Supported logging levels and their semantic 25 | enum LogLevel { 26 | LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call 27 | LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error) 28 | LOG_LEVEL_ERROR = 2, //!< Error message 29 | LOG_LEVEL_WARNING = 3, //!< Warning message 30 | LOG_LEVEL_INFO = 4, //!< Info message 31 | LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build. 32 | LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. 33 | #ifndef CV_DOXYGEN 34 | ENUM_LOG_LEVEL_FORCE_INT = INT_MAX 35 | #endif 36 | }; 37 | 38 | }}} // namespace 39 | 40 | //! @} 41 | 42 | #endif // OPENCV_LOGGER_DEFINES_HPP 43 | -------------------------------------------------------------------------------- /src/modules/caliper/include/caliper/caliper_impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file caliper_impl.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-03-08 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_CALIPER_IMPL_HPP_ 13 | #define MVK_CALIPER_IMPL_HPP_ 14 | 15 | #include "caliper/caliper_defines.hpp" 16 | 17 | namespace mvk 18 | { 19 | /** 20 | * @brief 卡尺工具实现类 21 | * 22 | */ 23 | class CaliperImpl 24 | { 25 | private: 26 | //--------------data------------------------ 27 | Image input_image_; ///< 输入图像 28 | RotateRectf roi_; 29 | CaliperResult result_; 30 | 31 | //------------- config --------------------- 32 | CaliperParameters config_; ///< 配置参数 33 | public: 34 | CaliperImpl(const CALIPER_MODE& mode); 35 | 36 | int ComputeProjectCurve(const Image& image, const RotateRectf& roi, std::vector& project_curve); 37 | 38 | int CurveConv(const std::vector& project_curve, std::vector& project_curve_conv, const size_t filter_kernel_size); 39 | 40 | int FindPeaks(const std::vector& derivative1, const std::vector& derivative2, std::vector& peaks); 41 | 42 | int FilterByPolarity(const std::vector& derivative1, const std::vector& peaks, std::vector& filter_peaks, const Polarity& polarity); 43 | 44 | int GradePeaks(const GRADE_MODE& grade_mode, const std::vector& peaks, std::vector& grade_peaks); 45 | 46 | int ReMaptoImage(const RotateRectf& roi, const std::vector& project_peaks, std::vector& image_peaks); 47 | 48 | void SetInputImage(const Image& image); 49 | 50 | void SetROI(const RotateRectf& roi); 51 | 52 | int Measure(); 53 | 54 | CaliperResult GetResult() const; 55 | }; 56 | }//namespace mvk 57 | 58 | #endif //MVK_CALIPER_IMPL_HPP_ 59 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/README.md: -------------------------------------------------------------------------------- 1 | # Optimize cflags for architecture features 2 | 3 | [![Build Status](https://travis-ci.org/miurahr/cmake-optimize-architecture-flag.svg?branch=master)](https://travis-ci.org/miurahr/cmake-optimize-architecture-flag) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/3xbllgket0ws79dw?svg=true)](https://ci.appveyor.com/project/miurahr/cmake-optimize-architecture-flag) 5 | 6 | Here is a cmake module and sample program to optimize architecture features 7 | such as a SIMD extensions. 8 | 9 | ## STATUS 10 | 11 | * Module `CMakeHostSystemInformationExtra`/function `cmake_host_system_information_extra()` is production ready on 12 | x86_64 and ARM platforms. 13 | - Tested on Linux, Mac, Windows with gcc, clang and icc on x86_64. 14 | - Tested on Linux on ARM using AWS EC2 A1 instance. 15 | * Module `CMakeCompilerMachineOption()` is experimental status. 16 | 17 | ## How to use? 18 | 19 | 1. Place cmake scripts under `Modules` folder in your project and add search path 20 | in your `CMakeLists.txt` by setting `CMAKE_MODULE_PATH` variable. 21 | 22 | 2. Include script using 23 | 24 | ``` 25 | include(CMakeHostSystemInformationExtra) 26 | include(GetCPUSIMDFeatures) 27 | include(CMakeCompilerMachineOption) 28 | ``` 29 | in your `CMakeLists.txt` 30 | 31 | 3. Call function `cmake_host_system_information_extra(RESULT QUERY ...)` 32 | to detect host system information. 33 | 34 | 4. Optimize compiler options 35 | 36 | Here is an example to optimize example project for skylake generation of Intel CPU. 37 | ``` 38 | set(TARGET_ARCHITECTURE skylake) 39 | cmake_compiler_machine_option(ARCHITECTURE_FLAG ${TARGET_ARCHITECTURE}) 40 | message(STATUS "Use compiler option: ${ARCHITECTURE_FLAG}") 41 | add_executable(example example.c) 42 | target_compile_options(example PRIVATE ${ARCHITECTURE_FLAG}) 43 | ``` 44 | Please see CMakeLists.txt for more details. 45 | 46 | ## License 47 | 48 | This is distributed under OSI-Approved 3-Clause BSD license. 49 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/detail/async_promise.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_ASYNC_PROMISE_HPP 6 | #define OPENCV_CORE_ASYNC_PROMISE_HPP 7 | 8 | #include "../async.hpp" 9 | 10 | #include "exception_ptr.hpp" 11 | 12 | namespace cv { 13 | 14 | /** @addtogroup core_async 15 | @{ 16 | */ 17 | 18 | 19 | /** @brief Provides result of asynchronous operations 20 | 21 | */ 22 | class CV_EXPORTS AsyncPromise 23 | { 24 | public: 25 | ~AsyncPromise() CV_NOEXCEPT; 26 | AsyncPromise() CV_NOEXCEPT; 27 | explicit AsyncPromise(const AsyncPromise& o) CV_NOEXCEPT; 28 | AsyncPromise& operator=(const AsyncPromise& o) CV_NOEXCEPT; 29 | void release() CV_NOEXCEPT; 30 | 31 | /** Returns associated AsyncArray 32 | @note Can be called once 33 | */ 34 | AsyncArray getArrayResult(); 35 | 36 | /** Stores asynchronous result. 37 | @param[in] value result 38 | */ 39 | void setValue(InputArray value); 40 | 41 | // TODO "move" setters 42 | 43 | #if CV__EXCEPTION_PTR 44 | /** Stores exception. 45 | @param[in] exception exception to be raised in AsyncArray 46 | */ 47 | void setException(std::exception_ptr exception); 48 | #endif 49 | 50 | /** Stores exception. 51 | @param[in] exception exception to be raised in AsyncArray 52 | */ 53 | void setException(const cv::Exception& exception); 54 | 55 | #ifdef CV_CXX11 56 | explicit AsyncPromise(AsyncPromise&& o) { p = o.p; o.p = NULL; } 57 | AsyncPromise& operator=(AsyncPromise&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } 58 | #endif 59 | 60 | 61 | // PImpl 62 | typedef struct AsyncArray::Impl Impl; friend struct AsyncArray::Impl; 63 | inline void* _getImpl() const CV_NOEXCEPT { return p; } 64 | protected: 65 | Impl* p; 66 | }; 67 | 68 | 69 | //! @} 70 | } // namespace 71 | #endif // OPENCV_CORE_ASYNC_PROMISE_HPP 72 | -------------------------------------------------------------------------------- /src/modules/caliper/include/caliper/caliper_defines.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file caliper_defines.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-22 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_CALIPER_DEFINES_HPP_ 13 | #define MVK_CALIPER_DEFINES_HPP_ 14 | 15 | #ifndef BUILD_STATIC_LIB 16 | #include "mvk_caliper_export.hpp" 17 | #endif 18 | 19 | #include "image/image.hpp" 20 | #include "common/rotate_rectangle.hpp" 21 | #include 22 | 23 | namespace mvk 24 | { 25 | /** 26 | * @brief 峰值点 27 | * 28 | */ 29 | struct Peak 30 | { 31 | Point2f p; 32 | float score; 33 | }; 34 | 35 | /** 36 | * @brief 卡尺工具结果 37 | * 38 | */ 39 | struct CaliperResult 40 | { 41 | float length; 42 | std::vector peaks; 43 | std::vector project_curve; 44 | }; 45 | 46 | /** 47 | * @brief 卡尺模式 48 | * 49 | */ 50 | enum class CALIPER_MODE 51 | { 52 | SINGLE_EDGE = 0, ///< 单边缘模式 53 | DOUBLE_EDGE = 1 ///< 双边缘点模式 54 | }; 55 | 56 | /** 57 | * @brief 评分模式 58 | * 59 | */ 60 | enum class GRADE_MODE 61 | { 62 | DEFAULT = 0 63 | }; 64 | 65 | /** 66 | * @brief 灰度极性 67 | * 68 | */ 69 | enum class Polarity 70 | { 71 | ANY = 0, ///< 任意 72 | WHITE_TO_BLACK = 1, ///< 从白到黑 73 | BLACK_TO_WHITE = 2 ///< 从黑到白 74 | }; 75 | 76 | /** 77 | * @brief 卡尺工具参数 78 | * 79 | */ 80 | struct CaliperParameters 81 | { 82 | Polarity polarity{Polarity::ANY}; ///< 扫描方向极性 83 | CALIPER_MODE work_mode{CALIPER_MODE::SINGLE_EDGE}; ///< 工具工作模式 84 | GRADE_MODE grade_mode{GRADE_MODE::DEFAULT}; ///< 评分模式 85 | size_t filter_kernel_size{3}; ///< 滤波核大小,奇数 86 | }; 87 | }//namespace mvk 88 | 89 | #endif //MVK_CALIPER_DEFINES_HPP_ -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/gaussian_filter_task.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/26. 3 | // 4 | 5 | #include "gaussian_filter_task.hpp" 6 | #include "filter/gaussian_filter.hpp" 7 | 8 | GaussianFilterTask::GaussianFilterTask(const std::string &name) : Task(name) 9 | { 10 | 11 | } 12 | 13 | int GaussianFilterTask::InitTask() 14 | { 15 | //init 16 | param_.insert(std::make_pair("kernel_size", std::make_any(5))); 17 | param_.insert(std::make_pair("border_type", std::make_any(BORDER_TYPE::MIRROR))); 18 | param_.insert(std::make_pair("sigma_x", std::make_any(0.0f))); 19 | param_.insert(std::make_pair("sigma_y", std::make_any(0.0f))); 20 | } 21 | 22 | int GaussianFilterTask::UpdateParams(const std::string& name, const std::any value) 23 | { 24 | if(param_.find(name) != param_.end()) 25 | { 26 | param_[name] = value; 27 | } 28 | return 0; 29 | } 30 | 31 | int GaussianFilterTask::RunTask() 32 | { 33 | //get input data and params 34 | auto input_data = GetInputData(); 35 | for(auto& data: input_data) 36 | { 37 | if(!data.has_value()) {return -1;} 38 | } 39 | 40 | 41 | //process 42 | auto src = std::any_cast(input_data[0]); 43 | Image dst = std::any_cast(output_data_[output_defines_[0].first]); 44 | 45 | int ret = mvk::GaussianFilter(src, dst, std::any_cast(param_["kernel_size"]), 46 | std::any_cast(param_["sigma_x"]), 47 | std::any_cast(param_["sigma_y"]), 48 | std::any_cast(param_["border_type"])); 49 | 50 | //set output data 51 | output_data_[output_defines_[0].first] = dst; 52 | 53 | return ret; 54 | } 55 | 56 | std::vector> GaussianFilterTask::GetInputDefines() const 57 | { 58 | return input_defines_; 59 | } 60 | 61 | std::vector> GaussianFilterTask::GetOutputDefines() const 62 | { 63 | return output_defines_; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/modules/common/include/algorithms/gemm/gemm_3.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gemm_3.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief gemm通用矩阵乘法优化-外层循环展开,封装展开步骤 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_COMMON_ALGORITHMS_GEMM_3_HPP_ 13 | #define MVK_COMMON_ALGORITHMS_GEMM_3_HPP_ 14 | 15 | #include 16 | #include 17 | 18 | namespace mvk 19 | { 20 | template 21 | void AddDot1x4(const std::vector>& A, 22 | const std::vector>& B, 23 | std::vector>& C, 24 | const int i, 25 | const int j, 26 | const int k) 27 | { 28 | AddDot(A, B, C, i, j, k); 29 | AddDot(A, B, C, i, j + 1, k); 30 | AddDot(A, B, C, i, j + 2, k); 31 | AddDot(A, B, C, i, j + 3, k); 32 | } 33 | 34 | /** 35 | * @brief C = A * B + C 36 | * 37 | * A 大小为 m * k 38 | * B 大小为 k * n 39 | * @tparam T 40 | * @param A 41 | * @param B 42 | * @param C 43 | */ 44 | template 45 | void MatrixMulti3(const std::vector>& A, const std::vector>& B, std::vector>& C) 46 | { 47 | assert(!A.empty() && !B.empty() && !C.empty()); 48 | assert(A.size() == C.size() && A[0].size() == B.size() && B[0].size() == C[0].size()); 49 | int m = A.size(); 50 | int k = A[0].size(); 51 | int n = B.size(); 52 | 53 | //外层循环展开4 54 | int j = 0; 55 | for(; j < n - 4; j += 4) 56 | { 57 | for(int i = 0; i < m; i++) 58 | { 59 | AddDot1x4(A, B, C, i, j, k); 60 | } 61 | } 62 | for(; j < n; j++) 63 | { 64 | for(int i = 0; i < m; i++) 65 | { 66 | AddDot(A, B, C, i, j, k); 67 | } 68 | } 69 | } 70 | }//namespace mvk 71 | 72 | 73 | #endif //MVK_COMMON_ALGORITHMS_GEMM_3_HPP_ 74 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/patches/CheckCCompilerFlag.cmake.diff: -------------------------------------------------------------------------------- 1 | --- /opt/cmake-3.12.0-Linux-x86_64/share/cmake-3.12/Modules/CheckCCompilerFlag.cmake 2018-07-17 20:29:59.000000000 +0900 2 | +++ CheckCCompilerFlag.cmake 2018-11-15 21:40:16.442425885 +0900 3 | @@ -40,6 +40,28 @@ 4 | set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") 5 | set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") 6 | 7 | + if("${_FLAG}" STREQUAL "-mfma") 8 | + # Compiling with FMA3 support may fail only at the assembler level. 9 | + # In that case we need to have such an instruction in the test code 10 | + set(_c_code "#include 11 | + __m128 foo(__m128 x) { return _mm_fmadd_ps(x, x, x); } 12 | + int main() { return 0; }") 13 | + elseif("${_FLAG}" STREQUAL "-march=knl" 14 | + OR "${_FLAG}" STREQUAL "-march=skylake-avx512" 15 | + OR "${_FLAG}" STREQUAL "/arch:AVX512" 16 | + OR "${_FLAG}" STREQUAL "/arch:KNL" 17 | + OR "${_FLAG}" MATCHES "^-mavx512.") 18 | + # Make sure the intrinsics are there 19 | + set(_c_code "#include 20 | + __m512 foo(__m256 v) { 21 | + return _mm512_castpd_ps(_mm512_insertf64x4(_mm512_setzero_pd(), _mm256_castps_pd(v), 0x0)); 22 | + } 23 | + __m512i bar() { return _mm512_setzero_si512(); } 24 | + int main() { return 0; }") 25 | + else() 26 | + set(_c_code " int main() { return 0; }") 27 | + endif() 28 | + 29 | # Normalize locale during test compilation. 30 | set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) 31 | foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) 32 | @@ -47,7 +69,7 @@ 33 | set(ENV{${v}} C) 34 | endforeach() 35 | CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) 36 | - CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} 37 | + CHECK_C_SOURCE_COMPILES("${_c_code}" ${_RESULT} 38 | # Some compilers do not fail with a bad flag 39 | FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU 40 | ${_CheckCCompilerFlag_COMMON_PATTERNS} 41 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/lines_detection.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lines_detection.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #include "lines_detection/lines_detection.h" 13 | #include "lines_detection/lines_detection_impl.h" 14 | 15 | namespace mvk 16 | { 17 | LinesDetection::LinesDetection() 18 | : lines_impl_(new LinesDetectionImpl()) 19 | { 20 | } 21 | 22 | LinesDetection::~LinesDetection() 23 | { 24 | } 25 | 26 | int LinesDetection::SetImage(const Image& image) 27 | { 28 | return lines_impl_->SetImage(image); 29 | } 30 | 31 | int LinesDetection::SetAllDetectionParameters(const std::string& json_format_paramters) 32 | { 33 | return lines_impl_->SetAllDetectionParameters(json_format_paramters); 34 | } 35 | 36 | int LinesDetection::SetDetectionRoi(const RotateRectangle& rect_roi) 37 | { 38 | return lines_impl_->SetDetectionRoi(rect_roi); 39 | } 40 | 41 | int LinesDetection::SetCaliperNumber(const size_t& number) 42 | { 43 | return lines_impl_->SetCaliperNumber(number); 44 | } 45 | 46 | int LinesDetection::SetEdgePolarity(const Polarity& polarity) 47 | { 48 | return lines_impl_->SetEdgePolarity(polarity); 49 | } 50 | 51 | int LinesDetection::SetLineFitMethod(const LineFitMethod& method) 52 | { 53 | return lines_impl_->SetLineFitMethod(method); 54 | } 55 | 56 | int LinesDetection::Detect() 57 | { 58 | return lines_impl_->Detect(); 59 | } 60 | 61 | Line LinesDetection::GetLine() const 62 | { 63 | return lines_impl_->GetLine(); 64 | } 65 | 66 | int LinesDetection::GetInlierPoints(std::vector& inliers) const 67 | { 68 | return lines_impl_->GetInlierPoints(inliers); 69 | } 70 | 71 | int LinesDetection::GetOutlierPoints(std::vector& outliers) const 72 | { 73 | return lines_impl_->GetOutlierPoints(outliers); 74 | } 75 | } // namespace mvk 76 | -------------------------------------------------------------------------------- /src/modules/common/include/algorithms/gemm/gemm_2.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gemm_2.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief gemm通用矩阵乘法优化-外层循环展开 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | #ifndef MVK_COMMON_ALGORITHMS_GEMM_2_HPP_ 13 | #define MVK_COMMON_ALGORITHMS_GEMM_2_HPP_ 14 | 15 | #include 16 | #include 17 | 18 | namespace mvk 19 | { 20 | 21 | template 22 | void AddDot(const std::vector>& A, 23 | const std::vector>& B, 24 | std::vector>& C, 25 | const int i, 26 | const int j, 27 | const int k) 28 | { 29 | for(int t = 0; t < k; t++) 30 | { 31 | C[i][j] += A[i][t] * B[t][j]; 32 | } 33 | } 34 | 35 | /** 36 | * @brief C = A * B + C 37 | * 38 | * A 大小为 m * k 39 | * B 大小为 k * n 40 | * @tparam T 41 | * @param A 42 | * @param B 43 | * @param C 44 | */ 45 | template 46 | void MatrixMulti2(const std::vector>& A, const std::vector>& B, std::vector>& C) 47 | { 48 | assert(!A.empty() && !B.empty() && !C.empty()); 49 | assert(A.size() == C.size() && A[0].size() == B.size() && B[0].size() == C[0].size()); 50 | int m = A.size(); 51 | int k = A[0].size(); 52 | int n = B.size(); 53 | 54 | //外层循环展开4 55 | int j = 0; 56 | for(; j < n - 4; j += 4) 57 | { 58 | for(int i = 0; i < m; i++) 59 | { 60 | AddDot(A, B, C, i, j, k); 61 | AddDot(A, B, C, i, j + 1, k); 62 | AddDot(A, B, C, i, j + 2, k); 63 | AddDot(A, B, C, i, j + 3, k); 64 | } 65 | } 66 | for(; j < n; j++) 67 | { 68 | for(int i = 0; i < m; i++) 69 | { 70 | AddDot(A, B, C, i, j, k); 71 | } 72 | } 73 | } 74 | }//namespace mvk 75 | 76 | 77 | #endif //MVK_COMMON_ALGORITHMS_GEMM_2_HPP_ 78 | -------------------------------------------------------------------------------- /opencv-benchmark/median-filter/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file main.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-16 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | #include "opencv2/opencv.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | int main(int argc, char** argv) 20 | { 21 | std::vector> img_sizes = {{640, 480}, {1280, 720}, {1280, 960}, {1920, 1080}, {1600, 1200}, {2048, 1536}, {2592, 1944}, {3264, 2448}, {3840, 2160}, {4224, 3168}, {5344, 4106}}; 22 | 23 | std::cout << "------------opencv mono median-filter3x3 benchmark-------------\n"; 24 | 25 | std::ofstream out_csv; 26 | out_csv.open("cv-threshold-benchmark.csv", std::ios::out); 27 | for(auto&& [len, wid] : img_sizes) 28 | { 29 | cv::Mat img = cv::Mat(len, wid, CV_8UC1); 30 | cv::Mat dst; 31 | auto t0 = std::chrono::system_clock::now(); 32 | for(int i = 0; i < 10; i++) 33 | { 34 | cv::medianBlur(img, dst, 3); 35 | } 36 | auto t1 = std::chrono::system_clock::now(); 37 | std::cout << std::to_string(len) + "x" + std::to_string(wid) + " cost " << std::chrono::duration_cast(t1 - t0).count() / 10000.0 << " ms.\n"; 38 | out_csv <(t1 - t0).count() / 10000.0 << std::endl; 39 | } 40 | 41 | std::cout << "------------opencv rgb median-filter3x3 benchmark-------------\n"; 42 | for(auto&& [len, wid] : img_sizes) 43 | { 44 | cv::Mat img = cv::Mat(len, wid, CV_8UC3); 45 | cv::Mat dst; 46 | auto t0 = std::chrono::system_clock::now(); 47 | for(int i = 0; i < 10; i++) 48 | { 49 | cv::medianBlur(img, dst, 3); 50 | } 51 | auto t1 = std::chrono::system_clock::now(); 52 | std::cout << std::to_string(len) + "x" + std::to_string(wid) + " cost " << std::chrono::duration_cast(t1 - t0).count() / 10000.0 << " ms.\n"; 53 | } 54 | 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /src/modules/common/src/algorithms/im2col.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file im2col.cpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 5 | * @version 0.1 6 | * @date 2022-04-02 7 | * 8 | * @copyright Copyright (c) 2022 9 | * 10 | */ 11 | 12 | 13 | namespace mvk 14 | { 15 | 16 | template 17 | DataType Im2colGetPixel(DataType *im, int height, int width, int channels, 18 | int row, int col, int channel, int pad) 19 | { 20 | row -= pad; 21 | col -= pad; 22 | 23 | if (row < 0 || col < 0 || row >= height || col >= width) return 0; 24 | return im[col + width*(row + height*channel)]; 25 | } 26 | 27 | void Im2col( 28 | uint8_t* data_im,// 输入图片数量 29 | int channels, // 单张图片的 通道数量 30 | int height, // 图片高度 31 | int width, // 宽度 32 | int ksize, // 卷积核尺寸 33 | int stride, // 步长 34 | uint8_t* data_col)// 输出 展开 35 | { 36 | int pad = 0; 37 | int c,h,w; 38 | 39 | int height_col = (height + 2*pad - ksize) / stride + 1; 40 | int width_col = (width + 2*pad - ksize) / stride + 1; 41 | int channels_col = channels * ksize * ksize;// 特征图展开 列长度 总行数 42 | 43 | for (c = 0; c < channels_col; ++c) 44 | { 45 | // caffe源码实现是一行一行来实现的 46 | // 下面的三个坐标表示在卷积核里面的位置。存储是一个通道,一行一行的存储。 47 | // 因此wide_offset是ksize的取余,h_offset是ksize(核的宽)的倍数然后对ksize(每个核的高)的取余。 48 | // c_im,每个核的通道为ksize*ksize。 49 | int w_offset = c % ksize; 50 | int h_offset = (c / ksize) % ksize; 51 | int c_im = c / ksize / ksize; 52 | 53 | for (h = 0; h < height_col; ++h) 54 | { 55 | for (w = 0; w < width_col; ++w) 56 | { 57 | int im_row = h_offset + h * stride; 58 | int im_col = w_offset + w * stride; 59 | int col_index = (c * height_col + h) * width_col + w; 60 | data_col[col_index] = Im2colGetPixel(data_im, height, width, channels, im_row, im_col, c_im, pad); 61 | } 62 | } 63 | } 64 | } 65 | }//namespace mvk 66 | -------------------------------------------------------------------------------- /src/remove/objectcounter/objectcounter.h: -------------------------------------------------------------------------------- 1 | #ifndef MVP_OBJECTCOUNTER_H 2 | #define MVP_OBJECTCOUNTER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "opencv2/opencv.hpp" 9 | 10 | namespace mvp 11 | { 12 | namespace objectcounter 13 | { 14 | /** 15 | * @brief 物体计数工具计算结果 16 | */ 17 | struct ObjectCounterResult 18 | { 19 | uint object_num; ///< 物体个数 20 | std::vector object_locations; ///< 物体位置 21 | }; 22 | 23 | /** 24 | * @brief 物体计数工具类 25 | */ 26 | class ObjectCounterTool 27 | { 28 | private: 29 | ObjectCounterResult result_; ///< 算法处理结果 30 | public: 31 | 32 | /** 33 | * @brief 默认构造函数 34 | * 35 | */ 36 | ObjectCounterTool(/* args */); 37 | 38 | /** 39 | * @brief 析构函数 40 | * 41 | */ 42 | ~ObjectCounterTool(); 43 | 44 | /** 45 | * @brief 创建物体计数工具类实例 46 | * @return 物体计数工具类实例指针 47 | */ 48 | static std::shared_ptr CreateObjectCounterTool(); 49 | 50 | /** 51 | * @brief 初始化函数 52 | * @param config_json_str(in) json格式参数配置字符串 53 | * @return 函数状态,负数为异常 54 | */ 55 | int Init(const std::string& config_json_str); 56 | 57 | /** 58 | * @brief 执行物体计数算法流程 59 | * @return 函数状态,负数为异常 60 | */ 61 | int Run(); 62 | 63 | /** 64 | * @brief 设置算法输入图像 65 | * @param image(in) 输入图像 66 | * @return 函数状态,负数为异常 67 | */ 68 | int SetInputImage(const cv::Mat& image); 69 | 70 | 71 | protected: 72 | /** 73 | * @brief 预处理 74 | * @return 函数状态,负数为异常 75 | */ 76 | int PreProcess(); 77 | }; 78 | 79 | }//namespace objectcounter 80 | }//namespace mvp 81 | 82 | #endif //MVP_OBJECTCOUNTER_H -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/parallel/backend/parallel_for.openmp.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP 6 | #define OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP 7 | 8 | #include "opencv2/core/parallel/parallel_backend.hpp" 9 | 10 | #if !defined(_OPENMP) && !defined(OPENCV_SKIP_OPENMP_PRESENSE_CHECK) 11 | #error "This file must be compiled with enabled OpenMP" 12 | #endif 13 | 14 | #include 15 | 16 | namespace cv { namespace parallel { namespace openmp { 17 | 18 | /** OpenMP parallel_for API implementation 19 | * 20 | * @sa setParallelForBackend 21 | * @ingroup core_parallel_backend 22 | */ 23 | class ParallelForBackend : public ParallelForAPI 24 | { 25 | protected: 26 | int numThreads; 27 | int numThreadsMax; 28 | public: 29 | ParallelForBackend() 30 | { 31 | numThreads = 0; 32 | numThreadsMax = omp_get_max_threads(); 33 | } 34 | 35 | virtual ~ParallelForBackend() {} 36 | 37 | virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) CV_OVERRIDE 38 | { 39 | #pragma omp parallel for schedule(dynamic) num_threads(numThreads > 0 ? numThreads : numThreadsMax) 40 | for (int i = 0; i < tasks; ++i) 41 | body_callback(i, i + 1, callback_data); 42 | } 43 | 44 | virtual int getThreadNum() const CV_OVERRIDE 45 | { 46 | return omp_get_thread_num(); 47 | } 48 | 49 | virtual int getNumThreads() const CV_OVERRIDE 50 | { 51 | return numThreads > 0 52 | ? numThreads 53 | : numThreadsMax; 54 | } 55 | 56 | virtual int setNumThreads(int nThreads) CV_OVERRIDE 57 | { 58 | int oldNumThreads = numThreads; 59 | numThreads = nThreads; 60 | // nothing needed as numThreads is used in #pragma omp parallel for directly 61 | return oldNumThreads; 62 | } 63 | 64 | const char* getName() const CV_OVERRIDE 65 | { 66 | return "openmp"; 67 | } 68 | }; 69 | 70 | }}} // namespace 71 | 72 | #endif // OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP 73 | -------------------------------------------------------------------------------- /test/filter/test_median_filter.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch2/catch_test_macros.hpp" 3 | #include "filter/median_filter.hpp" 4 | #include 5 | 6 | using namespace mvk; 7 | 8 | TEST_CASE("test mvk-filter median-filter", "[mvk-filter]") 9 | { 10 | std::string rgb_path = std::string(DATA) + "/images/mvk_filter/rgb_nosie_5x5.png"; 11 | Image rgb_img = LoadImage(rgb_path.c_str()); 12 | REQUIRE(!rgb_img.IsEmpty()); 13 | 14 | Image rgb_medianfilter_5x5; 15 | REQUIRE(MedianFilter(rgb_img, rgb_medianfilter_5x5, 5) == 0); 16 | REQUIRE( WriteImage(rgb_medianfilter_5x5, "rgb_medianfilter_5x5.png") != -1); 17 | 18 | 19 | std::string mono_path = std::string(DATA) + "/images/mvk_filter/256X256_lena_mono.jpg"; 20 | Image mono = LoadImage(mono_path.c_str()).Convert(CONVERT_TYPE::RGB2GRAY); 21 | REQUIRE(!mono.IsEmpty()); 22 | 23 | //添加噪声 24 | std::random_device rd; 25 | std::mt19937 gen(rd()); 26 | std::uniform_int_distribution<> dist(1, 230); 27 | for(int i = 0; i < 100; i++) 28 | { 29 | int x = dist(gen); 30 | int y = dist(gen); 31 | mono.At(x, y) = 0; 32 | } 33 | 34 | Image mono_medianfilter_7x7; 35 | REQUIRE(MedianFilter(mono, mono_medianfilter_7x7, 7) == 0); 36 | REQUIRE(WriteImage(mono_medianfilter_7x7, "mono_medianfilter_7x7.png") != -1); 37 | 38 | //测试3x3滤波 39 | Image mono_medianfilter_fast3x3; 40 | REQUIRE(MedianFilter3x3(mono, mono_medianfilter_fast3x3) == 0); 41 | REQUIRE(WriteImage(mono_medianfilter_fast3x3, "mono_medianfilter_fast3x3.png") != -1); 42 | 43 | 44 | Image rgb_medianfilter_fast3x3; 45 | REQUIRE(MedianFilter3x3(rgb_img, rgb_medianfilter_fast3x3) == 0); 46 | REQUIRE(WriteImage(rgb_medianfilter_fast3x3, "rgb_medianfilter_fast3x3.png") != -1); 47 | 48 | 49 | //测试5x5滤波 50 | Image mono_medianfilter_fast5x5; 51 | REQUIRE(MedianFilter5x5(mono, mono_medianfilter_fast5x5) == 0); 52 | REQUIRE(WriteImage(mono_medianfilter_fast5x5, "mono_medianfilter_fast5x5.png") != -1); 53 | 54 | 55 | Image rgb_medianfilter_fast5x5; 56 | REQUIRE(MedianFilter5x5(rgb_img, rgb_medianfilter_fast5x5) == 0); 57 | REQUIRE(WriteImage(rgb_medianfilter_fast5x5, "rgb_medianfilter_fast5x5.png") != -1); 58 | } -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/utils/filesystem.private.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of OpenCV project. 2 | // It is subject to the license terms in the LICENSE file found in the top-level directory 3 | // of this distribution and at http://opencv.org/license.html. 4 | 5 | #ifndef OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP 6 | #define OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP 7 | 8 | // TODO Move to CMake? 9 | #ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT 10 | # if defined(__EMSCRIPTEN__) || defined(__native_client__) 11 | /* no support */ 12 | # elif defined WINRT || defined _WIN32_WCE 13 | /* not supported */ 14 | # elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \ 15 | defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__ 16 | # define OPENCV_HAVE_FILESYSTEM_SUPPORT 1 17 | # elif defined(__APPLE__) 18 | # include 19 | # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) 20 | # define OPENCV_HAVE_FILESYSTEM_SUPPORT 1 // OSX, iOS only 21 | # endif 22 | # else 23 | /* unknown */ 24 | # endif 25 | # ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT 26 | # define OPENCV_HAVE_FILESYSTEM_SUPPORT 0 27 | # endif 28 | #endif 29 | 30 | #if OPENCV_HAVE_FILESYSTEM_SUPPORT 31 | namespace cv { namespace utils { namespace fs { 32 | 33 | /** 34 | * File-based lock object. 35 | * 36 | * Provides interprocess synchronization mechanism. 37 | * Platform dependent. 38 | * 39 | * Supports multiple readers / single writer access pattern (RW / readers–writer / shared-exclusive lock). 40 | * 41 | * File must exist. 42 | * File can't be re-used (for example, I/O operations via std::fstream is not safe) 43 | */ 44 | class CV_EXPORTS FileLock { 45 | public: 46 | explicit FileLock(const char* fname); 47 | ~FileLock(); 48 | 49 | void lock(); //< acquire exclusive (writer) lock 50 | void unlock(); //< release exclusive (writer) lock 51 | 52 | void lock_shared(); //< acquire shareable (reader) lock 53 | void unlock_shared(); //< release shareable (reader) lock 54 | 55 | struct Impl; 56 | protected: 57 | Impl* pImpl; 58 | 59 | private: 60 | FileLock(const FileLock&); // disabled 61 | FileLock& operator=(const FileLock&); // disabled 62 | }; 63 | 64 | }}} // namespace 65 | #endif 66 | #endif // OPENCV_UTILS_FILESYSTEM_PRIVATE_HPP 67 | -------------------------------------------------------------------------------- /src/modules/common/include/common/rotate_rectangle.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rotate_rectangle.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 旋转矩形类 5 | * @version 0.1 6 | * @date 2021-08-24 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef MVK_ROTATE_RECTANGLE_HPP_ 13 | #define MVK_ROTATE_RECTANGLE_HPP_ 14 | 15 | #include "common/point.hpp" 16 | #include 17 | #include 18 | 19 | namespace mvk 20 | { 21 | /** 22 | * @brief 旋转矩形,顺时针坐标点 23 | * 方向角度定义: 坐标点0 ----> 1直线与x轴夹角 24 | * 宽度定义: 坐标点0 <---> 1 ( 2 <----> 3)的距离 25 | * 高度定义: 坐标点0 <---> 1 ( 2 <----> 3)的距离 26 | */ 27 | template 28 | struct RotateRect 29 | { 30 | std::array, 4> points; 31 | 32 | /** 33 | * @brief 获取矩形宽度: 34 | * 宽度定义: 坐标点0 <---> 1 ( 2 <----> 3)的距离 35 | * 36 | * @return float 37 | */ 38 | float GetWidth() const 39 | { 40 | Point diff = points[1] - points[0]; 41 | return std::sqrt(diff.x * diff.x + diff.y * diff.y); 42 | } 43 | 44 | /** 45 | * @brief 获取矩形高度 46 | * 高度定义: 坐标点0 <---> 1 ( 2 <----> 3)的距离 47 | * 48 | * @return float 49 | */ 50 | float GetHeight() const 51 | { 52 | Point diff = points[2] - points[1]; 53 | return std::sqrt(diff.x * diff.x + diff.y * diff.y); 54 | } 55 | 56 | /** 57 | * @brief 获取矩形面积 58 | * 59 | * @return float 60 | */ 61 | float GetAngle() 62 | { 63 | Point v = points[1] - points[0]; 64 | //归一化 65 | double vm = std::sqrt(std::pow(v.x) + std::pow(v.y)); 66 | v.x /= vm; 67 | v.y /= vm; 68 | Point vx(1.0, 0); 69 | return std::acos(vx.Dot(v)); 70 | } 71 | 72 | Point GetDirection() const 73 | { 74 | auto diret = points[1] - points[0]; 75 | diret.Normalize(); 76 | return diret; 77 | } 78 | 79 | float GetArea() const 80 | { 81 | return GetWidth() * GetHeight(); 82 | } 83 | }; 84 | 85 | using RotateRectf = RotateRect; 86 | } // namespace mvk 87 | 88 | #endif //MVK_ROTATE_RECTANGLE_H_ 89 | -------------------------------------------------------------------------------- /src/modules/lines_detection/src/regression_implement.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file regression_implement.hpp 3 | * @author mango (2321544362@qq.com) 4 | * @brief 基于标准残差回归算法直线拟合实现 5 | * @version 0.1 6 | * @date 2021-07-03 7 | * 8 | * @copyright Copyright (c) 2021 9 | * 10 | */ 11 | 12 | #ifndef REGRESSION_IMPLEMENT_HPP_ 13 | #define REGRESSION_IMPLEMENT_HPP_ 14 | 15 | #include "line_fit.h" 16 | 17 | namespace mvk 18 | { 19 | namespace line_fit 20 | { 21 | /** 22 | * @brief 基于标准残差回归算法直线拟合实现 23 | * 24 | * @param points(in) 输入点集 25 | * @param result(out) 拟合结果 26 | * @param type(in) 点坐标距离度量类型 27 | * @return int 执行错误码 28 | */ 29 | int RegressionLineFit(const std::vector& points, LineFitResult& result, const DistType& type = DistType::DIST_L2) 30 | { 31 | if(points.size() < 2) {return -1;} 32 | 33 | // 设置权重 | weights setting 34 | auto weigths = std::vector(points.size(), 1); 35 | 36 | // AX = B 37 | // 构造A矩阵 38 | const int N = 2; 39 | cv::Mat A = cv::Mat::zeros(N, N, CV_64FC1); 40 | 41 | for (int row = 0;row < A.rows;row++) 42 | { 43 | for (int col = 0; col < A.cols;col++) 44 | { 45 | for (int k = 0;k < points.size();k++) 46 | { 47 | A.at(row, col) = A.at(row, col) + pow(points[k].x, row + col) * weigths[k]; 48 | } 49 | } 50 | } 51 | 52 | //构造B矩阵 53 | cv::Mat B = cv::Mat::zeros(N, 1, CV_64FC1); 54 | for (int row = 0;row < B.rows;row++) 55 | { 56 | for (int k = 0;k < points.size();k++) 57 | { 58 | B.at(row, 0) = B.at(row, 0) + pow(points[k].x, row)*points[k].y * weigths[k]; 59 | } 60 | } 61 | 62 | // 求解A*X = B 63 | cv::Mat X; 64 | cv::solve(A, B, X,cv::DECOMP_LU); 65 | 66 | // y = b + ax 67 | result.b = X.at(0,0); 68 | result.a = X.at(1, 0); 69 | 70 | return 0; 71 | } 72 | }//namespace line_fit 73 | }//namespace mvk 74 | 75 | #endif //REGRESSION_IMPLEMENT_HPP_ 76 | -------------------------------------------------------------------------------- /3rdparty/cmake_optimize_architecture/Tests/CMakeHostSystemInformationExtra/x86_64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | if(POLICY CMP0066) 4 | cmake_policy(SET CMP0066 NEW) 5 | endif() 6 | 7 | project(CMakeHostSystemInformationExtra.X86_64 VERSION 1.0 LANGUAGES C) 8 | include(CMakeHostSystemInformationExtra) 9 | 10 | if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") 11 | 12 | set(TEST_CPUINFO_1 "processor : 0 13 | vendor_id : GenuineIntel 14 | cpu family : 6 15 | model : 78 16 | model name : Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz 17 | stepping : 3 18 | microcode : 0xc6 19 | cpu MHz : 897.745 20 | cache size : 3072 KB 21 | physical id : 0 22 | siblings : 4 23 | core id : 0 24 | cpu cores : 2 25 | apicid : 0 26 | initial apicid : 0 27 | fpu : yes 28 | fpu_exception : yes 29 | cpuid level : 22 30 | wp : yes 31 | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d 32 | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf 33 | bogomips : 4608.00 34 | clflush size : 64 35 | cache_alignment : 64 36 | address sizes : 39 bits physical, 48 bits virtual 37 | power management: 38 | ") 39 | set(TEST_EXPECT_1 "skylake") 40 | 41 | foreach(testno IN ITEMS 1) 42 | set(_PROC_CPUINFO "/tmp/CmakeHostSystemInformationExtra__test__cpuinfo") 43 | file(WRITE ${_PROC_CPUINFO} "${TEST_CPUINFO_${testno}}") 44 | detect_x64_micro_architecture(arg1 arg2) 45 | if(arg2 MATCHES "${TEST_EXPECT_${testno}}") 46 | message(STATUS "Test ${testno} passed for ${arg2}") 47 | else() 48 | message(FATAL_ERROR "Test ${testno} got unexpected result: ${arg2}.") 49 | endif() 50 | endforeach() 51 | elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") 52 | # TODO 53 | endif() 54 | 55 | # vim: ts=2 sw=2 sts=2 et 56 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp: -------------------------------------------------------------------------------- 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 | // 5 | // By downloading, copying, installing or using the software you agree to this license. 6 | // If you do not agree to this license, do not download, install, 7 | // copy or use the software. 8 | // 9 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 | // Third party copyrights are property of their respective owners. 15 | // 16 | // Redistribution and use in source and binary forms, with or without modification, 17 | // are permitted provided that the following conditions are met: 18 | // 19 | // * Redistribution's of source code must retain the above copyright notice, 20 | // this list of conditions and the following disclaimer. 21 | // 22 | // * Redistribution's in binary form must reproduce the above copyright notice, 23 | // this list of conditions and the following disclaimer in the documentation 24 | // and/or other materials provided with the distribution. 25 | // 26 | // * The name of the copyright holders may not be used to endorse or promote products 27 | // derived from this software without specific prior written permission. 28 | // 29 | // This software is provided by the copyright holders and contributors "as is" and 30 | // any express or implied warranties, including, but not limited to, the implied 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 | // In no event shall the OpenCV Foundation or contributors be liable for any direct, 33 | // indirect, incidental, special, exemplary, or consequential damages 34 | // (including, but not limited to, procurement of substitute goods or services; 35 | // loss of use, data, or profits; or business interruption) however caused 36 | // and on any theory of liability, whether in contract, strict liability, 37 | // or tort (including negligence or otherwise) arising in any way out of 38 | // the use of this software, even if advised of the possibility of such damage. 39 | // 40 | //M*/ 41 | 42 | #ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_WRAPPERS_HPP 43 | #define OPENCV_CORE_OCL_RUNTIME_OPENCL_WRAPPERS_HPP 44 | 45 | #include "autogenerated/opencl_core_wrappers.hpp" 46 | 47 | #endif // OPENCV_CORE_OCL_RUNTIME_OPENCL_WRAPPERS_HPP 48 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp: -------------------------------------------------------------------------------- 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 | // 5 | // By downloading, copying, installing or using the software you agree to this license. 6 | // If you do not agree to this license, do not download, install, 7 | // copy or use the software. 8 | // 9 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 | // Third party copyrights are property of their respective owners. 15 | // 16 | // Redistribution and use in source and binary forms, with or without modification, 17 | // are permitted provided that the following conditions are met: 18 | // 19 | // * Redistribution's of source code must retain the above copyright notice, 20 | // this list of conditions and the following disclaimer. 21 | // 22 | // * Redistribution's in binary form must reproduce the above copyright notice, 23 | // this list of conditions and the following disclaimer in the documentation 24 | // and/or other materials provided with the distribution. 25 | // 26 | // * The name of the copyright holders may not be used to endorse or promote products 27 | // derived from this software without specific prior written permission. 28 | // 29 | // This software is provided by the copyright holders and contributors "as is" and 30 | // any express or implied warranties, including, but not limited to, the implied 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 | // In no event shall the OpenCV Foundation or contributors be liable for any direct, 33 | // indirect, incidental, special, exemplary, or consequential damages 34 | // (including, but not limited to, procurement of substitute goods or services; 35 | // loss of use, data, or profits; or business interruption) however caused 36 | // and on any theory of liability, whether in contract, strict liability, 37 | // or tort (including negligence or otherwise) arising in any way out of 38 | // the use of this software, even if advised of the possibility of such damage. 39 | // 40 | //M*/ 41 | 42 | #ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP 43 | #define OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP 44 | 45 | #include "autogenerated/opencl_gl_wrappers.hpp" 46 | 47 | #endif // OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP 48 | -------------------------------------------------------------------------------- /src/modules/filter/blend.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/2/28. 3 | // 4 | 5 | #include "blend.hpp" 6 | #include 7 | 8 | int AddWeighted(Image src1, const float alpha, Image src2, const float beta, Image dst ,const float gamma) 9 | { 10 | if(src1.IsEmpty() || src2.IsEmpty()) 11 | { 12 | std::cerr<< "AddWeighted error, src1 or src2 is empty!" << std::endl; 13 | return -1; 14 | } 15 | if(src1.GetSize() != src2.GetSize() || src2.Channels() != src1.Channels()) 16 | { 17 | std::cerr<< "AddWeighted error, src1 size != src2 size" << std::endl; 18 | return -1; 19 | } 20 | 21 | if(dst.GetSize() != src1.GetSize() || dst.Channels() != src1.Channels()) 22 | { 23 | dst = src1.Clone(); 24 | } 25 | 26 | int w = src1.GetSize().width; 27 | int h = src1.GetSize().height; 28 | int c = src1.Channels(); 29 | 30 | for(int i = 0; i < h; i++) 31 | { 32 | for(int j = 0; j < w; j++) 33 | { 34 | for(int k = 0; k < c; k++) 35 | { 36 | dst.Ptr(j, i)[k] = std::round(src1.Ptr(j, i)[k] * alpha + src2.Ptr(j, i)[k] * beta + gamma); 37 | } 38 | } 39 | } 40 | return 0; 41 | } 42 | 43 | int NormalBlend(Image src, Image blend, Image& dst) 44 | { 45 | assert(src.Channels() == 4); 46 | if(src.IsEmpty() ) 47 | { 48 | std::cerr<< "NormalBlend error, src1 is empty!" << std::endl; 49 | return -1; 50 | } 51 | if(blend.IsEmpty() || blend.GetSize() != src.GetSize()) 52 | { 53 | std::cerr<< "NormalBlend error, blend" << std::endl; 54 | } 55 | 56 | if(src.Channels() != 4) 57 | { 58 | std::cerr<< "NormalBlend error, src not have alpha channel" << std::endl; 59 | return -1; 60 | } 61 | if(dst.GetSize() != src.GetSize() != dst.Channels() != src.Channels()) 62 | { 63 | dst = src.Clone(); 64 | } 65 | 66 | int w = src.GetSize().width; 67 | int h = src.GetSize().height; 68 | 69 | for(int i = 0; i < h; i++) 70 | { 71 | for(int j = 0; j < w; j++) 72 | { 73 | float alpha = src.Ptr(j, i)[3] / 255.0; 74 | for(int k = 0; k < 3; k++) 75 | { 76 | dst.Ptr(j, i)[k] = src.Ptr(j, i)[k] * (1.0 - alpha) + blend.Ptr(j, i)[k] * alpha; 77 | } 78 | //src.Ptr(j, i)[3] = 255; 79 | } 80 | } 81 | return 0; 82 | } -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/core.hpp: -------------------------------------------------------------------------------- 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 | // 5 | // By downloading, copying, installing or using the software you agree to this license. 6 | // If you do not agree to this license, do not download, install, 7 | // copy or use the software. 8 | // 9 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. 16 | // Third party copyrights are property of their respective owners. 17 | // 18 | // Redistribution and use in source and binary forms, with or without modification, 19 | // are permitted provided that the following conditions are met: 20 | // 21 | // * Redistribution's of source code must retain the above copyright notice, 22 | // this list of conditions and the following disclaimer. 23 | // 24 | // * Redistribution's in binary form must reproduce the above copyright notice, 25 | // this list of conditions and the following disclaimer in the documentation 26 | // and/or other materials provided with the distribution. 27 | // 28 | // * The name of the copyright holders may not be used to endorse or promote products 29 | // derived from this software without specific prior written permission. 30 | // 31 | // This software is provided by the copyright holders and contributors "as is" and 32 | // any express or implied warranties, including, but not limited to, the implied 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, 35 | // indirect, incidental, special, exemplary, or consequential damages 36 | // (including, but not limited to, procurement of substitute goods or services; 37 | // loss of use, data, or profits; or business interruption) however caused 38 | // and on any theory of liability, whether in contract, strict liability, 39 | // or tort (including negligence or otherwise) arising in any way out of 40 | // the use of this software, even if advised of the possibility of such damage. 41 | // 42 | //M*/ 43 | 44 | #ifdef __OPENCV_BUILD 45 | #error this is a compatibility header which should not be used inside the OpenCV library 46 | #endif 47 | 48 | #include "opencv2/core.hpp" 49 | -------------------------------------------------------------------------------- /src/remove/linefit/linefit_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 4/10/2020. 3 | // 4 | 5 | #include"linefit.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | enum class OutlierType 12 | { 13 | RANDOM = 0, 14 | GAUSS, 15 | SINGLE_DIRECTION 16 | }; 17 | 18 | // 构造拟合点 19 | void CreatePoints(const cv::Size& planeSize, std::vector& points, const cv::Point2d& lineStart, const int& angle, const size_t& len, const size_t& outlierNum = 10, const size_t& distance = 0, const OutlierType& type = OutlierType::RANDOM); 20 | 21 | int main() 22 | { 23 | std::vector pts; 24 | CreatePoints({ 1000,800 }, pts, { 200.0 , 120.0 }, 30, 350, 20, 35); 25 | 26 | cv::Mat img = cv::Mat(800, 1000, CV_8UC3, cv::Scalar::all(255)); 27 | 28 | 29 | for (size_t i = 0; i < pts.size(); i++) 30 | { 31 | cv::circle(img, pts.at(i), 1, cv::Scalar(255, 0, 0)); 32 | } 33 | 34 | cv::Ptr lineFit = mv::LineFit::CreateInstance(pts,mv::FitAlgorithms::REGRESSION); 35 | 36 | lineFit->Run(); 37 | 38 | mv::LineFitResult res = lineFit->GetResult(); 39 | 40 | cv::Point2d lineStart, lineEnd; 41 | lineStart = { 200, 120 }; 42 | lineEnd.x = 200 + 350; 43 | lineEnd.y = res.a * lineEnd.x + res.b; 44 | 45 | cv::line(img, lineStart, lineEnd, cv::Scalar(0, 255, 0), 2); 46 | 47 | cv::imshow("Create points", img); 48 | cv::waitKey(0); 49 | 50 | return 0; 51 | } 52 | 53 | 54 | void CreatePoints(const cv::Size& planeSize, std::vector& points, const cv::Point2d& lineStart, const int& angle, const size_t& len, const size_t& outlierNum, const size_t& distance, const OutlierType& type) 55 | { 56 | points.clear(); 57 | const double PI = std::acos(-1); 58 | 59 | // 创建聚合点 60 | srand((unsigned)time(nullptr)); 61 | for (int i = 0; i < len; i++) 62 | { 63 | double x = lineStart.x + i; 64 | double yOffset = static_cast(i) * std::tan(static_cast(angle) * PI / 180) + rand() % distance - 0.5*distance; 65 | double y = lineStart.y + yOffset; 66 | 67 | if (x > 0 && x < planeSize.width && y > 0 && y < planeSize.height) 68 | { 69 | points.push_back({ x, y }); 70 | } 71 | } 72 | 73 | // 创建离群点 74 | 75 | switch (type) 76 | { 77 | case OutlierType::GAUSS: 78 | break; 79 | case OutlierType::RANDOM: 80 | srand((unsigned)time(nullptr)); 81 | for (size_t i = 0; i < outlierNum; i++) 82 | { 83 | double x = rand() % planeSize.width; 84 | double y = rand() % planeSize.height; 85 | points.push_back({ x, y }); 86 | } 87 | break; 88 | case OutlierType::SINGLE_DIRECTION: 89 | break; 90 | default: 91 | break; 92 | } 93 | } -------------------------------------------------------------------------------- /src/modules/effect_buildin_task/beauty_smooth.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 2024/3/8. 3 | // 4 | 5 | #include "beauty_smooth.hpp" 6 | #include "filter/skin_detect.hpp" 7 | 8 | 9 | BeautySmoothTask::BeautySmoothTask(const std::string& name): Task(name) 10 | { 11 | 12 | } 13 | 14 | int BeautySmoothTask::InitTask() 15 | { 16 | param_.insert(std::make_pair("smooth_type", std::make_any(SMOOTH_TYPE::COLOR_SPACE))); 17 | param_.insert(std::make_pair("smooth_intensity", std::make_any(1.0f))); 18 | return 0; 19 | } 20 | 21 | int BeautySmoothTask::UpdateParams(const std::string& name, const std::any value) 22 | { 23 | 24 | } 25 | 26 | int BeautySmoothTask::RunTask() 27 | { 28 | //1. get input data and params 29 | auto input_data = GetInputData(); 30 | for(auto& data: input_data) 31 | { 32 | if(!data.has_value()) {return -1;} 33 | } 34 | 35 | 36 | //process 37 | auto src = std::any_cast(input_data[0]); 38 | Image dst = std::any_cast(output_data_[output_defines_[0].first]); 39 | SMOOTH_TYPE type = std::any_cast(param_["smooth_type"]); 40 | float intensity = std::any_cast(param_["smooth_intensity"]); 41 | 42 | int ret = 0; 43 | switch (type) 44 | { 45 | case SMOOTH_TYPE::COLOR_SPACE: 46 | { 47 | ret = SmoothByColorSpace(src, dst, intensity); 48 | break; 49 | } 50 | default: 51 | ret = -1; 52 | } 53 | 54 | //2. set output data 55 | output_data_[output_defines_[0].first] = dst; 56 | return ret; 57 | } 58 | 59 | std::vector> BeautySmoothTask::GetInputDefines() const 60 | { 61 | return input_defines_; 62 | } 63 | 64 | std::vector> BeautySmoothTask::GetOutputDefines() const 65 | { 66 | return output_defines_; 67 | } 68 | 69 | int BeautySmoothTask::SmoothByColorSpace(Image& src, Image& dst, const float intensity) 70 | { 71 | if(src.IsEmpty()){return -1;} 72 | 73 | if(intensity < 0.00001) 74 | { 75 | if(dst.GetSize() == src.GetSize() && dst.GetType() == src.GetType()) 76 | { 77 | int data_size = dst.GetSize().height * dst.GetSize().width * dst.Channels(); 78 | std::memcmp(src.Ptr(0, 0), dst.Ptr(0, 0), data_size); 79 | } else 80 | { 81 | src.CopyTo(dst); 82 | } 83 | }else 84 | { 85 | //1. mask 86 | Image mask; 87 | SkinDetectByColorSpace(src, mask); 88 | } 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/opencl/runtime/opencl_clfft.hpp: -------------------------------------------------------------------------------- 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 | // 5 | // By downloading, copying, installing or using the software you agree to this license. 6 | // If you do not agree to this license, do not download, install, 7 | // copy or use the software. 8 | // 9 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 | // Third party copyrights are property of their respective owners. 15 | // 16 | // Redistribution and use in source and binary forms, with or without modification, 17 | // are permitted provided that the following conditions are met: 18 | // 19 | // * Redistribution's of source code must retain the above copyright notice, 20 | // this list of conditions and the following disclaimer. 21 | // 22 | // * Redistribution's in binary form must reproduce the above copyright notice, 23 | // this list of conditions and the following disclaimer in the documentation 24 | // and/or other materials provided with the distribution. 25 | // 26 | // * The name of the copyright holders may not be used to endorse or promote products 27 | // derived from this software without specific prior written permission. 28 | // 29 | // This software is provided by the copyright holders and contributors "as is" and 30 | // any express or implied warranties, including, but not limited to, the implied 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 | // In no event shall the OpenCV Foundation or contributors be liable for any direct, 33 | // indirect, incidental, special, exemplary, or consequential damages 34 | // (including, but not limited to, procurement of substitute goods or services; 35 | // loss of use, data, or profits; or business interruption) however caused 36 | // and on any theory of liability, whether in contract, strict liability, 37 | // or tort (including negligence or otherwise) arising in any way out of 38 | // the use of this software, even if advised of the possibility of such damage. 39 | // 40 | //M*/ 41 | 42 | #ifndef OPENCV_CORE_OCL_RUNTIME_CLAMDFFT_HPP 43 | #define OPENCV_CORE_OCL_RUNTIME_CLAMDFFT_HPP 44 | 45 | #ifdef HAVE_CLAMDFFT 46 | 47 | #include "opencl_core.hpp" 48 | 49 | #include "autogenerated/opencl_clfft.hpp" 50 | 51 | #endif // HAVE_CLAMDFFT 52 | 53 | #endif // OPENCV_CORE_OCL_RUNTIME_CLAMDFFT_HPP 54 | -------------------------------------------------------------------------------- /3rdparty/cv_simd/opencv2/core/opencl/runtime/opencl_clblas.hpp: -------------------------------------------------------------------------------- 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 | // 5 | // By downloading, copying, installing or using the software you agree to this license. 6 | // If you do not agree to this license, do not download, install, 7 | // copy or use the software. 8 | // 9 | // 10 | // License Agreement 11 | // For Open Source Computer Vision Library 12 | // 13 | // Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. 14 | // Third party copyrights are property of their respective owners. 15 | // 16 | // Redistribution and use in source and binary forms, with or without modification, 17 | // are permitted provided that the following conditions are met: 18 | // 19 | // * Redistribution's of source code must retain the above copyright notice, 20 | // this list of conditions and the following disclaimer. 21 | // 22 | // * Redistribution's in binary form must reproduce the above copyright notice, 23 | // this list of conditions and the following disclaimer in the documentation 24 | // and/or other materials provided with the distribution. 25 | // 26 | // * The name of the copyright holders may not be used to endorse or promote products 27 | // derived from this software without specific prior written permission. 28 | // 29 | // This software is provided by the copyright holders and contributors "as is" and 30 | // any express or implied warranties, including, but not limited to, the implied 31 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 | // In no event shall the OpenCV Foundation or contributors be liable for any direct, 33 | // indirect, incidental, special, exemplary, or consequential damages 34 | // (including, but not limited to, procurement of substitute goods or services; 35 | // loss of use, data, or profits; or business interruption) however caused 36 | // and on any theory of liability, whether in contract, strict liability, 37 | // or tort (including negligence or otherwise) arising in any way out of 38 | // the use of this software, even if advised of the possibility of such damage. 39 | // 40 | //M*/ 41 | 42 | #ifndef OPENCV_CORE_OCL_RUNTIME_CLAMDBLAS_HPP 43 | #define OPENCV_CORE_OCL_RUNTIME_CLAMDBLAS_HPP 44 | 45 | #ifdef HAVE_CLAMDBLAS 46 | 47 | #include "opencl_core.hpp" 48 | 49 | #include "autogenerated/opencl_clblas.hpp" 50 | 51 | #endif // HAVE_CLAMDBLAS 52 | 53 | #endif // OPENCV_CORE_OCL_RUNTIME_CLAMDBLAS_HPP 54 | -------------------------------------------------------------------------------- /doc/benchmark/benchmarkd.md: -------------------------------------------------------------------------------- 1 | # 性能表现 2 | 3 | ## 测试平台: 4 | 5 | - Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz 6 | - ubuntu 20.04 lts 7 | - gcc 9.3 8 | 9 | ## 中值滤波3x3 10 | 11 | ``` 12 | ------------opencv mono median-filter3x3 benchmark------------- 13 | 640x480 cost 1 ms. 14 | 1280x720 cost 2 ms. 15 | 1280x960 cost 2 ms. 16 | 1920x1080 cost 3 ms. 17 | 1600x1200 cost 3 ms. 18 | 2048x1536 cost 2 ms. 19 | 2592x1944 cost 4 ms. 20 | 3264x2448 cost 7 ms. 21 | 3840x2160 cost 7 ms. 22 | 4224x3168 cost 11 ms. 23 | 5344x4106 cost 17 ms. 24 | ------------opencv rgb median-filter3x3 benchmark------------- 25 | 640x480 cost 1 ms. 26 | 1280x720 cost 2 ms. 27 | 1280x960 cost 3 ms. 28 | 1920x1080 cost 3 ms. 29 | 1600x1200 cost 1 ms. 30 | 2048x1536 cost 5 ms. 31 | 2592x1944 cost 8 ms. 32 | 3264x2448 cost 16 ms. 33 | 3840x2160 cost 15 ms. 34 | 4224x3168 cost 31 ms. 35 | 5344x4106 cost 54 ms. 36 | 37 | -------------mvk-nodes filter mono median-filter3x3 benchenmark------------------ 38 | 640x480 cost 0 ms. 39 | 1280x720 cost 0 ms. 40 | 1280x960 cost 0 ms. 41 | 1920x1080 cost 3 ms. 42 | 1600x1200 cost 1 ms. 43 | 2048x1536 cost 2 ms. 44 | 2592x1944 cost 2 ms. 45 | 3264x2448 cost 4 ms. 46 | 3840x2160 cost 4 ms. 47 | 4224x3168 cost 7 ms. 48 | 5344x4106 cost 11 ms. 49 | -------------mvk-nodes filter rgb median-filter3x3 benchenmark------------------ 50 | 640x480 cost 0 ms. 51 | 1280x720 cost 3 ms. 52 | 1280x960 cost 2 ms. 53 | 1920x1080 cost 5 ms. 54 | 1600x1200 cost 1 ms. 55 | 2048x1536 cost 12 ms. 56 | 2592x1944 cost 19 ms. 57 | 3264x2448 cost 30 ms. 58 | 3840x2160 cost 31 ms. 59 | 4224x3168 cost 50 ms. 60 | 5344x4106 cost 81 ms. 61 | ``` 62 | 63 | ![median-filter3x3-benchmark](../median-filter3x3-benchmark.png) 64 | 65 | ## 阈值化处理 66 | 67 | ### 二值化 68 | 69 | ``` 70 | -------------mvk-nodes filter threshold benchenmark------------------ 71 | 640x480 cost 0.0908 ms. 72 | 1280x720 cost 0.1711 ms. 73 | 1280x960 cost 0.2034 ms. 74 | 1920x1080 cost 0.4087 ms. 75 | 1600x1200 cost 0.4867 ms. 76 | 2048x1536 cost 0.9005 ms. 77 | 2592x1944 cost 1.0191 ms. 78 | 3264x2448 cost 1.5688 ms. 79 | 3840x2160 cost 1.5972 ms. 80 | 4224x3168 cost 2.6267 ms. 81 | 5344x4106 cost 4.1337 ms. 82 | 83 | ------------opencv mono median-filter3x3 benchmark------------- 84 | 640x480 cost 0.134 ms. 85 | 1280x720 cost 0.0793 ms. 86 | 1280x960 cost 0.0732 ms. 87 | 1920x1080 cost 0.1653 ms. 88 | 1600x1200 cost 0.1183 ms. 89 | 2048x1536 cost 0.3897 ms. 90 | 2592x1944 cost 0.5908 ms. 91 | 3264x2448 cost 0.987 ms. 92 | 3840x2160 cost 1.0167 ms. 93 | 4224x3168 cost 1.6279 ms. 94 | 5344x4106 cost 2.7114 ms. 95 | ``` 96 | ![threshold-benchmark](../threshold-benchmark.png) 97 | 98 | 注:opencv版本为4.5.4 -------------------------------------------------------------------------------- /3rdparty/stb_image/LICENSE: -------------------------------------------------------------------------------- 1 | This software is available under 2 licenses -- choose whichever you prefer. 2 | ------------------------------------------------------------------------------ 3 | ALTERNATIVE A - MIT License 4 | Copyright (c) 2017 Sean Barrett 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | ------------------------------------------------------------------------------ 21 | ALTERNATIVE B - Public Domain (www.unlicense.org) 22 | This is free and unencumbered software released into the public domain. 23 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 24 | software, either in source code form or as a compiled binary, for any purpose, 25 | commercial or non-commercial, and by any means. 26 | In jurisdictions that recognize copyright laws, the author or authors of this 27 | software dedicate any and all copyright interest in the software to the public 28 | domain. We make this dedication for the benefit of the public at large and to 29 | the detriment of our heirs and successors. We intend this dedication to be an 30 | overt act of relinquishment in perpetuity of all present and future rights to 31 | this software under copyright law. 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 36 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /src/modules/image/3rdparty/stb/LICENSE: -------------------------------------------------------------------------------- 1 | This software is available under 2 licenses -- choose whichever you prefer. 2 | ------------------------------------------------------------------------------ 3 | ALTERNATIVE A - MIT License 4 | Copyright (c) 2017 Sean Barrett 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | ------------------------------------------------------------------------------ 21 | ALTERNATIVE B - Public Domain (www.unlicense.org) 22 | This is free and unencumbered software released into the public domain. 23 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 24 | software, either in source code form or as a compiled binary, for any purpose, 25 | commercial or non-commercial, and by any means. 26 | In jurisdictions that recognize copyright laws, the author or authors of this 27 | software dedicate any and all copyright interest in the software to the public 28 | domain. We make this dedication for the benefit of the public at large and to 29 | the detriment of our heirs and successors. We intend this dedication to be an 30 | overt act of relinquishment in perpetuity of all present and future rights to 31 | this software under copyright law. 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 36 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /src/remove/blobdetect/blobdetect.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by mango on 3/28/2020. 3 | // 4 | 5 | /** 6 | * @file blobdetect.h 7 | * @brief blob检测头文件 8 | * @details 基于OpenCV SimpleBlobDetector拓展的blob检测算子 9 | * @author 芒果 10 | * @date 2020-3-28 11 | * @version 1.0.0 12 | */ 13 | 14 | #ifndef MACHINE_VISION_LIBRARY_BLOBDETECT_H 15 | #define MACHINE_VISION_LIBRARY_BLOBDETECT_H 16 | 17 | #include "opencv2/features2d.hpp" 18 | 19 | using namespace cv; 20 | namespace mv 21 | { 22 | // Single blob info 23 | struct BlobInfo 24 | { 25 | cv::Point2d location; //center point's coordinate 26 | std::vector outline; //outline 27 | double area; //area 28 | double radius; //radius 29 | double confidence; //blob detection confidence 30 | };//BlobInfo 31 | 32 | struct BlobDetectResult 33 | { 34 | std::vector blobList; 35 | };//BlobDetectResult 36 | 37 | class BlobDetect: protected SimpleBlobDetector 38 | { 39 | public: 40 | explicit BlobDetect(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); 41 | 42 | static Ptr CreateInstance(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); 43 | 44 | 45 | // Workflow 46 | // 1. 47 | void Init(cv::Mat& inputImage); // input image 48 | // 2. 49 | void SetParams(); // default value 50 | void SetParams(std::string name, float value); // set value by param name 51 | // 3. detection 52 | // .... 53 | 54 | void Run(); // run detection processing 55 | 56 | // --------------debug--------------------------- 57 | void PrintResultInfo() const; // print result information of detection 58 | void PrintParameter() const; 59 | void DrawOutline() const; 60 | 61 | 62 | 63 | // class members for user 64 | cv::Mat inputImage; 65 | BlobDetectResult result; 66 | protected: 67 | 68 | private: 69 | void FindBlobs(InputArray image, InputArray binaryImage, std::vector ¢ers) const; 70 | void Detect( InputArray image, InputArray mask=noArray() ); 71 | 72 | std::vector keyPoints; 73 | Params params; 74 | };//BlobDetect 75 | }//namespace mv 76 | #endif //MACHINE_VISION_LIBRARY_BLOBDETECT_H 77 | --------------------------------------------------------------------------------