This commit is contained in:
Neucrack
2025-03-27 18:31:16 +08:00
parent 14a98737f1
commit a2c648d8ae
15 changed files with 254 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
mainmenu "MaixCDK configuration, platform: ${PLATFORM}"
mainmenu "MaixCDK configuration, platform: ${PLATFORM} ${PLATFORM_MAIXCAM2}"
menu "SDK Components Configuration"
osource "${SDK_PATH}/components/*/Kconfig"
@@ -38,3 +38,10 @@ config COMPONENTS_COMPILE_FROM_SOURCE
default n
help
All components compile from source instead of using prebuilt libraries or local libraries.
config PLATFORM
string
option env="PLATFORM"
help
Platform name, see platform dir in MaixCDK.

View File

@@ -32,68 +32,113 @@ append_srcs_dir(ADD_SRCS "${msp_common_path}") # append source file in src d
###############################################
############ Add dynamic libs ##################
set(libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_skel.so"
"${msp_glibc_path}/lib/libax_skel.so"
"${msp_glibc_path}/lib/libax_avs.so"
"${msp_glibc_path}/lib/libax_utility.so"
"${msp_glibc_path}/lib/libax_af.so"
"${msp_glibc_path}/lib/libax_venc.so"
# "${msp_glibc_path}/lib/libax_faac.so"
"${msp_glibc_path}/lib/libax_proton.so"
"${msp_glibc_path}/lib/libsns_sc500ai.so"
"${msp_glibc_path}/lib/libax_nt_stream.so"
"${msp_glibc_path}/lib/libax_audio_3a.so"
"${msp_glibc_path}/lib/libax_interpreter.so"
"${msp_glibc_path}/lib/libsns_sc231ai.so"
"${msp_glibc_path}/lib/libax_ivps.so"
"${msp_glibc_path}/lib/libax_ives.so"
# "${msp_glibc_path}/lib/libax_audio.so"
"${msp_glibc_path}/lib/libax_ae.so"
"${msp_glibc_path}/lib/libax_skel_tiny.so"
"${msp_glibc_path}/lib/libsns_imx664.so"
"${msp_glibc_path}/lib/libax_efuse.so"
"${msp_glibc_path}/lib/libax_vo.so"
"${msp_glibc_path}/lib/libsns_sc430ai.so"
"${msp_glibc_path}/lib/libsns_s5kjn1sq03.so"
# "${msp_glibc_path}/lib/libax_fdk.so"
"${msp_glibc_path}/lib/libsns_sc450ai.so"
"${msp_glibc_path}/lib/libax_sys.so"
"${msp_glibc_path}/lib/libax_vdec.so"
"${msp_glibc_path}/lib/libax_awb.so"
"${msp_glibc_path}/lib/libax_mipi.so"
"${msp_glibc_path}/lib/liblens_t5719.so"
"${msp_glibc_path}/lib/libsns_imx678.so"
"${msp_glibc_path}/lib/libax_ive.so"
"${msp_glibc_path}/lib/libax_engine.so"
"${msp_glibc_path}/lib/libsns_os04d10.so"
"${msp_glibc_path}/lib/libsns_mis2032.so"
"${msp_glibc_path}/lib/libax_nt_ctrl.so"
"${msp_glibc_path}/lib/libsns_os08c10.so"
"${msp_glibc_path}/lib/libax_avscali.so"
# "${msp_glibc_path}/lib/libax_opus.so"
"${msp_glibc_path}/lib/libsns_sc200ai.so"
"${msp_glibc_path}/lib/libsns_dummy.so"
"${msp_glibc_path}/lib/libsns_os04a10.so"
"${msp_glibc_path}/lib/libsns_sc530ai.so"
"${msp_glibc_path}/lib/libax_engine_tiny.so"
"${msp_glibc_path}/lib/libsns_gc4653.so"
"${msp_glibc_path}/lib/libax_gzipd.so"
"${msp_glibc_path}/lib/libax_thermal.so"
"${msp_glibc_path}/lib/libsns_sc4210.so"
"${msp_glibc_path}/lib/libsns_gc4663.so"
"${msp_glibc_path}/lib/libsns_sc830ai.so"
"${msp_glibc_path}/lib/libsns_c4395.so"
"${msp_glibc_path}/lib/libax_cipher.so"
# "${msp_glibc_path}/lib/libax_opal.so"
"${msp_glibc_path}/lib/libsns_sc850sl.so"
"${msp_glibc_path}/lib/libax_syslog.so"
"${msp_glibc_path}/lib/libsns_dummy_bittrue.so"
"${msp_glibc_path}/lib/liblens_dciris.so"
# "${srcs_path}/third-party/faac/lib/arm64/glibc/libfaac.so.0"
# "${srcs_path}/third-party/fdk-aac/lib/arm64/glibc/libfdk-aac.so.2"
# "${srcs_path}/third-party/opus/lib/arm64/glibc/libopus.so.0"
# "${msp_app_path}/component/resource/lib/arm64/glibc/appweb/libmpr.so"
)
set(libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_sys.so"
)
if(CONFIG_AX620E_MSP_ENABLE_SENSOR_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_af.so"
"${msp_glibc_path}/lib/libax_venc.so"
"${msp_glibc_path}/lib/libax_vdec.so"
"${msp_glibc_path}/lib/libax_proton.so"
"${msp_glibc_path}/lib/libax_mipi.so"
"${msp_glibc_path}/lib/libax_ae.so"
"${msp_glibc_path}/lib/libax_awb.so"
"${msp_glibc_path}/lib/libax_ive.so"
"${msp_glibc_path}/lib/libax_ivps.so"
"${msp_glibc_path}/lib/libax_nt_stream.so"
"${msp_glibc_path}/lib/libax_nt_ctrl.so"
# sofficial supported sensors
"${msp_glibc_path}/lib/libsns_sc850sl.so"
"${msp_glibc_path}/lib/libsns_os04a10.so"
"${msp_glibc_path}/lib/libsns_gc4653.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_EXTRA_SENSOR_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libsns_sc500ai.so"
"${msp_glibc_path}/lib/libsns_sc231ai.so"
"${msp_glibc_path}/lib/libsns_imx664.so"
"${msp_glibc_path}/lib/libsns_sc430ai.so"
"${msp_glibc_path}/lib/libsns_s5kjn1sq03.so"
"${msp_glibc_path}/lib/libsns_sc450ai.so"
"${msp_glibc_path}/lib/libsns_imx678.so"
"${msp_glibc_path}/lib/libsns_os04d10.so"
"${msp_glibc_path}/lib/libsns_mis2032.so"
"${msp_glibc_path}/lib/libsns_os08c10.so"
"${msp_glibc_path}/lib/libsns_sc200ai.so"
"${msp_glibc_path}/lib/libsns_sc530ai.so"
"${msp_glibc_path}/lib/libsns_sc4210.so"
"${msp_glibc_path}/lib/libsns_gc4663.so"
"${msp_glibc_path}/lib/libsns_sc830ai.so"
"${msp_glibc_path}/lib/libsns_c4395.so"
"${msp_glibc_path}/lib/libsns_dummy.so"
"${msp_glibc_path}/lib/libsns_dummy_bittrue.so"
"${msp_glibc_path}/lib/liblens_t5719.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_NPU_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_engine.so"
# "${msp_glibc_path}/lib/libax_engine_tiny.so"
"${msp_glibc_path}/lib/libax_interpreter.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_AUDIO_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_audio_3a.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_IVES_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_ives.so" # Intelligent Video Extension System
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_SKEL_LIB) # SKELeton Artificial Intelligent Algorithm
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_skel.so"
# "${msp_glibc_path}/lib/libax_skel_tiny.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_OPAL_LIB) # OPerator Abstract Layer(IPC application high level API)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_opal.so")
endif()
if(CONFIG_AX620E_MSP_ENABLE_EFUSE_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_efuse.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_VO_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_vo.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_GZIP_LIB) # hardware acceleration API for gzip
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_gzipd.so"
)
endif()
if(CONFIG_AX620E_MSP_ENABLE_EXTRA_LIB)
list(APPEND libax_dynamic_lib_file "${msp_glibc_path}/lib/libax_utility.so"
"${msp_glibc_path}/lib/libax_avs.so"
"${msp_glibc_path}/lib/libax_avscali.so"
"${msp_glibc_path}/lib/libax_thermal.so"
"${msp_glibc_path}/lib/libax_cipher.so"
"${msp_glibc_path}/lib/libax_syslog.so"
"${msp_glibc_path}/lib/liblens_dciris.so"
# "${msp_glibc_path}/lib/libax_audio.so"
# "${msp_glibc_path}/lib/libax_fdk.so"
# "${msp_glibc_path}/lib/libax_opus.so"
# "${msp_glibc_path}/lib/libax_faac.so"
# "${srcs_path}/third-party/faac/lib/arm64/glibc/libfaac.so.0"
# "${srcs_path}/third-party/fdk-aac/lib/arm64/glibc/libfdk-aac.so.2"
# "${srcs_path}/third-party/opus/lib/arm64/glibc/libopus.so.0"
# "${msp_app_path}/component/resource/lib/arm64/glibc/appweb/libmpr.so"
)
endif()
set_property(SOURCE ${libax_dynamic_lib_file} PROPERTY GENERATED 1)
list(APPEND ADD_DYNAMIC_LIB ${libax_dynamic_lib_file})

View File

@@ -0,0 +1,73 @@
# AX620e MSP Options, only for maixcam2 platform
if PLATFORM = "maixcam2"
menu "AX620E MSP Options"
config AX620E_MSP_ENABLE_NPU_LIB
bool "Enable NPU library"
default n
help
Enable NPU library
config AX620E_MSP_ENABLE_VO_LIB
bool "Enable vo library"
default n
help
Enable vo library
config AX620E_MSP_ENABLE_SENSOR_LIB
bool "Enable maixcam2 official sensor library"
default n
help
Enable sensor library
config AX620E_MSP_ENABLE_EXTRA_SENSOR_LIB
bool "Enable extra sensor library, maybe no ISP ajustment"
default n
help
Enable extra sensor library
config AX620E_MSP_ENABLE_AUDIO_LIB
bool "Enable audio library"
default n
help
Enable audio library
config AX620E_MSP_ENABLE_IVES_LIB
bool "Enable IVES(Intelligent Video Extension System) library"
default n
help
Enable IVES(Intelligent Video Extension System) library
config AX620E_MSP_ENABLE_SKEL_LIB
bool "Enable SKEL(Skeleton Artificial Intelligent Algorithm) library"
default n
help
Enable SKEL(Skeleton Artificial Intelligent Algorithm) library
config AX620E_MSP_ENABLE_OPAL_LIB
bool "Enable OPAL(Operator Abstract Layer) library"
default n
help
Enable OPAL(Operator Abstract Layer) library
config AX620E_MSP_ENABLE_EFUSE_LIB
bool "Enable efuse library"
default n
help
Enable efuse library
config AX620E_MSP_ENABLE_GZIP_LIB
bool "Enable hardware acceleration API for gzip"
default n
help
Enable hardware acceleration API for gzip
config AX620E_MSP_ENABLE_EXTRA_LIB
bool "Enable extra libraries"
default n
help
Enable extra libraries
endmenu
endif

View File

@@ -1,4 +1,5 @@
# SUNXI_MPP version major minor patch
if PLATFORM = "m2dock"
menu "SUNXI_MPP version"
config SUNXI_MPP_VERSION_MAJOR
int "SUNXI_MPP package major version"
@@ -18,3 +19,4 @@ config SUNXI_MPP_VERSION_PATCH
help
SUNXI_MPP package patch version
endmenu
endif

View File

@@ -292,6 +292,14 @@ namespace maix::fs
*/
int tell();
/**
* Get file size
* @attention will change file seek position temporarily when get file size.
* @return file size if success, -err::Err code if failed
* @maixpy maix.fs.File.size
*/
int size();
/**
* Flush file
* @return err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed

View File

@@ -410,6 +410,20 @@ namespace maix::fs
return std::ftell((FILE *)_fp);
}
int File::size()
{
// get file size use std::fseek and std::ftell
if (_fp == nullptr)
{
return -err::ERR_NOT_READY;
}
int pos = std::ftell((FILE *)_fp);
std::fseek((FILE *)_fp, 0, SEEK_END);
int size = std::ftell((FILE *)_fp);
std::fseek((FILE *)_fp, pos, SEEK_SET);
return size;
}
err::Err File::flush()
{
// flush file use std::fflush

View File

@@ -9,21 +9,17 @@ if(PLATFORM_MAIXCAM)
if(CONFIG_MAIXCAM_LIB_COMPILE_FROM_SOURCE)
set(source_dir "maixcdk_maixcam_lib")
append_srcs_dir(ADD_SRCS "${source_dir}")
# nn
list(APPEND ADD_INCLUDE "../nn/include")
list(APPEND ADD_INCLUDE "../vision/include")
append_srcs_dir(ADD_SRCS "${source_dir}/nn")
append_srcs_dir(ADD_SRCS "${source_dir}/maixcam")
append_srcs_dir(ADD_SRCS "${source_dir}/common")
list(APPEND ADD_REQUIREMENTS cvi_tpu)
# media_server
append_srcs_dir(ADD_SRCS "${source_dir}/media_server")
list(APPEND ADD_REQUIREMENTS media_server)
# middleware
list(APPEND ADD_SRCS "${source_dir}/middleware/sophgo_middleware.cpp")
set_property(SOURCE ${middleware_src_dir} PROPERTY GENERATED 1)
list(APPEND ADD_REQUIREMENTS sophgo-middleware)
list(APPEND ADD_DEFINITIONS_PRIVATE -Wl,--exclude-libs,ALL)
@@ -39,10 +35,12 @@ elseif(PLATFORM_MAIXCAM2)
list(APPEND ADD_REQUIREMENTS maixcam2_msp)
list(APPEND ADD_INCLUDE "../vision/include")
set(source_dir "maixcdk_maixcam_lib/maixcam2")
list(APPEND ADD_INCLUDE "../nn/include")
set(source_dir "maixcdk_maixcam_lib")
append_srcs_dir(ADD_SRCS "${source_dir}/maixcam2")
append_srcs_dir(ADD_SRCS "${source_dir}/common")
if(CONFIG_MAIXCAM_LIB_COMPILE_FROM_SOURCE)
append_srcs_dir(ADD_SRCS "${source_dir}")
register_component(DYNAMIC)
else()
list(APPEND ADD_DYNAMIC_LIB "lib/libmaixcam2_lib.so")

View File

@@ -1,3 +1,4 @@
menu "runtime lib options"
config MAIXCAM_LIB_COMPILE_FROM_SOURCE
bool "compile maixcam_lib from souce code"
default n
@@ -11,3 +12,4 @@ config MAIXCAM_LIB_ENC
help
enc maixcam lib, for internal debug usage
endif
endmenu

View File

@@ -1,9 +1,10 @@
#include "global_config.h"
#include "maix_nn.hpp"
#include "maix_image.hpp"
namespace maix::nn
{
err::Err maixcam_load_cvimodel(const std::string &model_path, MUD *mud_obj);
err::Err mud_load_raw_model(const std::string &model_path, MUD *mud_obj);
int maix_nn_self_learn_classifier_learn(std::vector<float *> &features, std::vector<float *> &features_samples, int feature_num);
class NN_MaixCam : public NNBase

View File

@@ -0,0 +1,9 @@
menu "nn component configuration"
config NN_ENABLE
bool "Enable nn component"
default y
select AX620E_MSP_ENABLE_NPU_LIB if PLATFORM = "maixcam2"
help
To use this component, you must enable it here.
endmenu

View File

@@ -172,7 +172,7 @@ namespace maix::nn
err::Err e = _model->extra_info_labels(labels);
if(e == err::Err::ERR_NONE)
{
log::print("\tlabels num: %ld\n", labels.size());
log::info("labels num: %ld", labels.size());
}
else
{

View File

@@ -11,7 +11,7 @@
#include "inifile.h"
#include "maix_nn_self_learn_classifier.hpp"
#if PLATFORM_MAIXCAM
#if PLATFORM_MAIXCAM || PLATFORM_MAIXCAM2
#include "maix_nn_maixcam.hpp"
#include "speech/dr_wav.h"
#endif
@@ -145,15 +145,13 @@ namespace maix::nn
log::error("model path %s not exists\n", model_path.c_str());
return err::ERR_ARGS;
}
#if PLATFORM_MAIXCAM
// if model_path end with .cvimodel, load cvi model
if(model_path.find(".cvimodel") != std::string::npos)
{
return maixcam_load_cvimodel(model_path, this);
}
#endif
if(model_path.find(".mud") == std::string::npos)
{
if(mud_load_raw_model(model_path, this) == err::ERR_NONE)
{
return err::ERR_NONE;
}
log::error("model path %s not end with .mud\n", model_path.c_str());
return err::ERR_ARGS;
}
@@ -198,7 +196,7 @@ namespace maix::nn
NN::NN(const std::string &model_path, bool dual_buff)
{
_impl = nullptr;
#if PLATFORM_MAIXCAM
#if PLATFORM_MAIXCAM || PLATFORM_MAIXCAM2
_impl = new NN_MaixCam(dual_buff);
#endif
if(!_impl)
@@ -311,7 +309,7 @@ namespace maix::nn
int SelfLearnClassifier::learn()
{
#if PLATFORM_MAIXCAM
#if PLATFORM_MAIXCAM || PLATFORM_MAIXCAM2
return maix_nn_self_learn_classifier_learn(_features, _features_sample, _feature_num);
#else
throw err::Exception(err::ERR_NOT_IMPL);

View File

@@ -0,0 +1,9 @@
menu "vision component configuration"
config VISION_ENABLE
bool "Enable vision component"
default y
select AX620E_MSP_ENABLE_NPU_LIB if PLATFORM = "maixcam2"
select AX620E_MSP_ENABLE_SENSOR_LIB if PLATFORM = "maixcam2"
help
To use this component, you must enable it here.
endmenu

View File

@@ -1,7 +1,8 @@
config PYTHON_PKG_EXAMPLE
bool "python pkg example"
config PYTHON_PKG_EXAMPLE_CONFIG1
bool "config from component maixcdk-example, a MaixCDK component installed by pip"
default n
help
python pkg example
component installed by pip as a python package from pypi.org,
installed by pip install maixcdk-xxxx, more info read documentation.

View File

@@ -39,7 +39,7 @@ int _main(int argc, char* argv[])
std::vector<std::pair<int, float>> * result = classifier.classify(*img);
for(int i = 0; i < 5; ++i)
{
log::info("top %d: %5.2f%% %s, ", i + 1, result->at(i).second * 100, classifier.labels[result->at(i).first].c_str());
log::info("top %d: %5.2f%% %s, idx: %d", i + 1, result->at(i).second * 100, classifier.labels[result->at(i).first].c_str(), result->at(i).first);
}
delete result;
delete img;