diff --git a/components/3rd_party/libjuice/component.py b/components/3rd_party/libjuice/component.py index 23a4b984..a646626b 100644 --- a/components/3rd_party/libjuice/component.py +++ b/components/3rd_party/libjuice/component.py @@ -4,7 +4,7 @@ def add_file_downloads(confs : dict) -> list: @param confs kconfig vars, dict type @return list type, items is dict type ''' - version = f"{confs['CONFIG_LIBJUICE_VERSION_MAJOR']}.{confs['CONFIG_LIBJUICE_VERSION_MINOR']}.{confs['CONFIG_LIBJUICE_VERSION_PATCH']}.{confs['CONFIG_LIBJUICE_COMPILED_VERSION']}" + version = f"{confs['CONFIG_LIBJUICE_VERSION_MAJOR']}.{confs['CONFIG_LIBJUICE_VERSION_MINOR']}.{confs['CONFIG_LIBJUICE_VERSION_PATCH']}" url = f"https://github.com/paullouisageneau/libjuice/archive/refs/tags/v{version}.tar.gz" if version == "1.5.8": sha256sum = "aa81809384c7e2594853304034a60fa2c2a234483b31cb531a4fc19e5877b709" diff --git a/components/3rd_party/onnxruntime/CMakeLists.txt b/components/3rd_party/onnxruntime/CMakeLists.txt index caf2ac2a..5e4b27e5 100644 --- a/components/3rd_party/onnxruntime/CMakeLists.txt +++ b/components/3rd_party/onnxruntime/CMakeLists.txt @@ -9,7 +9,7 @@ endif() if(PLATFORM_MAIXCAM) list(APPEND ADD_INCLUDE "${src_path}/include") elseif(PLATFORM_MAIXCAM2) - list(APPEND ADD_INCLUDE "${src_path}/include/onnxruntime") + list(APPEND ADD_INCLUDE "${src_path}/include") endif() # list(APPEND ADD_PRIVATE_INCLUDE "include_private") diff --git a/components/basic/port/linux/maix_sys_linux.cpp b/components/basic/port/linux/maix_sys_linux.cpp index f70cec64..da5a13e9 100644 --- a/components/basic/port/linux/maix_sys_linux.cpp +++ b/components/basic/port/linux/maix_sys_linux.cpp @@ -18,6 +18,11 @@ namespace maix::sys } } + void poweroff() + { + log::info("Your platform is linux, poweroff will not execute"); + } + void register_default_signal_handle() { signal(SIGINT, signal_handle); } diff --git a/components/llm/src/linux/maix_vlm_qwen3_linux.cpp b/components/llm/src/linux/maix_vlm_qwen3_linux.cpp new file mode 100644 index 00000000..46589d4b --- /dev/null +++ b/components/llm/src/linux/maix_vlm_qwen3_linux.cpp @@ -0,0 +1,100 @@ +/** + * LLM Qwen3VL implementation on MaixCam2 + * @license Apache-2.0 + * @author lxo@sipeed + * @date 2025-11-24 + */ + +#include "maix_vlm_qwen3.hpp" +#include "maix_nn.hpp" +#include "maix_basic.hpp" + + namespace maix::nn + { + + Qwen3VL::Qwen3VL(const std::string &model) + { + (void)model; + } + + Qwen3VL::~Qwen3VL() + { + } + + void Qwen3VL::set_log_level(log::LogLevel level, bool color) + { + (void)level; + (void)color; + } + + err::Err Qwen3VL::load(const std::string &model) + { + (void)model; + return err::ERR_NOT_IMPL; + } + + err::Err Qwen3VL::unload() + { + return err::ERR_NOT_IMPL; + } + + + void Qwen3VL::set_system_prompt(const std::string &prompt) + { + (void)prompt; + } + + int Qwen3VL::input_width() + { + return 0; + } + + int Qwen3VL::input_height() + { + return 0; + } + + maix::image::Format Qwen3VL::input_format() + { + return maix::image::Format::FMT_RGB888; + } + + err::Err Qwen3VL::set_image(maix::image::Image &img, maix::image::Fit fit) + { + (void)img; + (void)fit; + return err::ERR_NONE; + } + + void Qwen3VL::clear_image() + { + } + + bool Qwen3VL::is_image_set() + { + return false; + } + + nn::Qwen3VLResp Qwen3VL::send(const std::string &msg) + { + (void)msg; + return nn::Qwen3VLResp(); + } + + void Qwen3VL::cancel() + { + + } + + bool Qwen3VL::is_ready() { + return false; + } + + err::Err Qwen3VL::start_service() { + return err::ERR_NOT_IMPL; + } + + err::Err Qwen3VL::stop_service() { + return err::ERR_NOT_IMPL; + } + } // namespace maix::nn diff --git a/components/llm/src/linux/maix_vlm_smolvlm_linux.cpp b/components/llm/src/linux/maix_vlm_smolvlm_linux.cpp new file mode 100644 index 00000000..e0287a9d --- /dev/null +++ b/components/llm/src/linux/maix_vlm_smolvlm_linux.cpp @@ -0,0 +1,86 @@ +/** + * LLM SmolVLM implementation on Linux + * @license Apache-2.0 + * @author lxo@sipeed + * @date 2025-11-24 + */ + +#include "maix_vlm_smolvlm.hpp" +#include "maix_nn.hpp" + +namespace maix::nn +{ + SmolVLM::SmolVLM(const std::string &model) + { + (void)model; + } + + SmolVLM::~SmolVLM() + { + + } + + void SmolVLM::set_log_level(log::LogLevel level, bool color) + { + (void)level; + (void)color; + } + + err::Err SmolVLM::load(const std::string &model) + { + (void)model; + return err::ERR_NOT_IMPL; + } + + err::Err SmolVLM::unload() + { + return err::ERR_NOT_IMPL; + } + + + void SmolVLM::set_system_prompt(const std::string &prompt) + { + (void)prompt; + } + + int SmolVLM::input_width() + { + return 0; + } + + int SmolVLM::input_height() + { + return 0; + } + + maix::image::Format SmolVLM::input_format() + { + return maix::image::Format::FMT_RGB888; + } + + err::Err SmolVLM::set_image(maix::image::Image &img, maix::image::Fit fit) + { + (void)img; + (void)fit; + return err::ERR_NOT_IMPL; + } + + void SmolVLM::clear_image() + { + } + + bool SmolVLM::is_image_set() + { + } + + nn::SmolVLMResp SmolVLM::send(const std::string &msg) + { + (void)msg; + return nn::SmolVLMResp(); + } + + void SmolVLM::cancel() + { + } + +} // namespace maix::nn diff --git a/components/llm/src/maixcam2/maix_vlm_qwen3_maixcam2.cpp b/components/llm/src/maixcam2/maix_vlm_qwen3_maixcam2.cpp index 46e84a5f..51d3b202 100644 --- a/components/llm/src/maixcam2/maix_vlm_qwen3_maixcam2.cpp +++ b/components/llm/src/maixcam2/maix_vlm_qwen3_maixcam2.cpp @@ -2,7 +2,7 @@ * LLM Qwen3VL implementation on MaixCam2 * @license Apache-2.0 * @author lxo@sipeed - * @date 2025-011-24 + * @date 2025-11-24 */ #include "maix_vlm_qwen3.hpp" diff --git a/components/llm/src/maixcam2/maix_vlm_smolvlm_maixcam2.cpp b/components/llm/src/maixcam2/maix_vlm_smolvlm_maixcam2.cpp index 2d2b7e3d..87bd1624 100644 --- a/components/llm/src/maixcam2/maix_vlm_smolvlm_maixcam2.cpp +++ b/components/llm/src/maixcam2/maix_vlm_smolvlm_maixcam2.cpp @@ -1,8 +1,8 @@ /** * LLM SmolVLM implementation on MaixCam2 * @license Apache-2.0 - * @author neucrack@sipeed - * @date 2025-06-03 + * @author lxo@sipeed + * @date 2025-11-24 */ #include "maix_vlm_smolvlm.hpp" diff --git a/components/nn/port/maixcam2/maix_nn_melotts_maixcam2.cpp b/components/nn/port/maixcam2/maix_nn_melotts_maixcam2.cpp index e2759c97..4deea7d5 100644 --- a/components/nn/port/maixcam2/maix_nn_melotts_maixcam2.cpp +++ b/components/nn/port/maixcam2/maix_nn_melotts_maixcam2.cpp @@ -17,7 +17,7 @@ #include #include #include -#include "onnxruntime_cxx_api.h" +#include "onnxruntime/onnxruntime_cxx_api.h" #include "maix_nn_melotts.hpp" namespace maix::nn diff --git a/components/peripheral/port/linux/maix_uart_port.cpp b/components/peripheral/port/linux/maix_uart_port.cpp index 2bc089a7..29c8aabf 100644 --- a/components/peripheral/port/linux/maix_uart_port.cpp +++ b/components/peripheral/port/linux/maix_uart_port.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include diff --git a/components/peripheral/port/linux_common/maix_uart.cpp b/components/peripheral/port/linux_common/maix_uart.cpp index e96730fc..45486f37 100755 --- a/components/peripheral/port/linux_common/maix_uart.cpp +++ b/components/peripheral/port/linux_common/maix_uart.cpp @@ -252,46 +252,46 @@ namespace maix::peripheral::uart this->close(); } - static int set_pinmux(uint64_t addr, uint32_t value) - { -// 假设我们的系统页大小为4KB -#define PAGE_SIZE 4096 -#define PAGE_MASK (PAGE_SIZE - 1) - int fd; - void *map_base, *virt_addr; +// static int set_pinmux(uint64_t addr, uint32_t value) +// { +// // 假设我们的系统页大小为4KB +// #define PAGE_SIZE 4096 +// #define PAGE_MASK (PAGE_SIZE - 1) +// int fd; +// void *map_base, *virt_addr; - /* 打开 /dev/mem 文件 */ - if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) - { - perror("Error opening /dev/mem"); - return -1; - } +// /* 打开 /dev/mem 文件 */ +// if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) +// { +// perror("Error opening /dev/mem"); +// return -1; +// } - /* 映射需要访问的物理内存页到进程空间 */ - map_base = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~PAGE_MASK); - if (map_base == (void *)-1) - { - perror("Error mapping memory"); - close(fd); - return -1; - } +// /* 映射需要访问的物理内存页到进程空间 */ +// map_base = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~PAGE_MASK); +// if (map_base == (void *)-1) +// { +// perror("Error mapping memory"); +// close(fd); +// return -1; +// } - /* 计算目标寄存器的虚拟地址 */ - virt_addr = (char *)map_base + (addr & PAGE_MASK); +// /* 计算目标寄存器的虚拟地址 */ +// virt_addr = (char *)map_base + (addr & PAGE_MASK); - /* 写入值到目标寄存器 */ - *((uint32_t *)virt_addr) = value; +// /* 写入值到目标寄存器 */ +// *((uint32_t *)virt_addr) = value; - /* 取消映射并关闭文件描述符 */ - if (munmap(map_base, PAGE_SIZE) == -1) - { - perror("Error unmapping memory"); - } +// /* 取消映射并关闭文件描述符 */ +// if (munmap(map_base, PAGE_SIZE) == -1) +// { +// perror("Error unmapping memory"); +// } - close(fd); +// close(fd); - return 0; - } +// return 0; +// } err::Err UART::open() { diff --git a/components/peripheral/port/maixcam/maix_uart_port.cpp b/components/peripheral/port/maixcam/maix_uart_port.cpp index 2ebf08bd..c974b4a9 100644 --- a/components/peripheral/port/maixcam/maix_uart_port.cpp +++ b/components/peripheral/port/maixcam/maix_uart_port.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include diff --git a/components/peripheral/port/maixcam2/maix_uart_port.cpp b/components/peripheral/port/maixcam2/maix_uart_port.cpp index 4d75d403..28481970 100644 --- a/components/peripheral/port/maixcam2/maix_uart_port.cpp +++ b/components/peripheral/port/maixcam2/maix_uart_port.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include diff --git a/examples/network_websocket_client/main/src/main.cpp b/examples/network_websocket_client/main/src/main.cpp index d311470f..ce3c584a 100644 --- a/examples/network_websocket_client/main/src/main.cpp +++ b/examples/network_websocket_client/main/src/main.cpp @@ -1,58 +1,163 @@ -#include - #include "maix_basic.hpp" -#include "main.h" - +#include "maix_err.hpp" #include #include +// This header pulls in the WebSocket++ abstracted thread support that will +// select between boost::thread and std::thread based on how the build system +// is configured. +#include -typedef websocketpp::client client; - -using websocketpp::lib::placeholders::_1; -using websocketpp::lib::placeholders::_2; -using websocketpp::lib::bind; -using namespace maix; - - -// pull out the type of messages sent by our config -typedef websocketpp::config::asio_client::message_type::ptr message_ptr; - -// This message handler will be invoked once for each incoming message. It -// prints the message and then sends a copy of the message back to the server. -void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) { - std::cout << "on_message called with hdl: " << hdl.lock().get() - << " and message: " << msg->get_payload() - << std::endl; - - - // websocketpp::lib::error_code ec; - - // c->send(hdl, msg->get_payload(), msg->get_opcode(), ec); - // if (ec) { - // std::cout << "Echo failed because: " << ec.message() << std::endl; - // } +/** + * Define a semi-cross platform helper method that waits/sleeps for a bit. + */ +void wait_a_bit() { +#ifdef WIN32 + Sleep(1000); +#else + sleep(1); +#endif } -struct send_thread_args{ - client *c; - websocketpp::connection_hdl hdl; +/** + * The telemetry client connects to a WebSocket server and sends a message every + * second containing an integer count. This example can be used as the basis for + * programs where a client connects and pushes data for logging, stress/load + * testing, etc. + */ +class telemetry_client { +public: + typedef websocketpp::client client; + typedef websocketpp::lib::lock_guard scoped_lock; + + telemetry_client() : m_open(false),m_done(false) { + // set up access channels to only log interesting things + m_client.clear_access_channels(websocketpp::log::alevel::all); + m_client.set_access_channels(websocketpp::log::alevel::connect); + m_client.set_access_channels(websocketpp::log::alevel::disconnect); + m_client.set_access_channels(websocketpp::log::alevel::app); + + // Initialize the Asio transport policy + m_client.init_asio(); + + // Bind the handlers we are using + using websocketpp::lib::placeholders::_1; + using websocketpp::lib::bind; + m_client.set_open_handler(bind(&telemetry_client::on_open,this,_1)); + m_client.set_close_handler(bind(&telemetry_client::on_close,this,_1)); + m_client.set_fail_handler(bind(&telemetry_client::on_fail,this,_1)); + } + + // This method will block until the connection is complete + void run(const std::string & uri) { + // Create a new connection to the given URI + websocketpp::lib::error_code ec; + client::connection_ptr con = m_client.get_connection(uri, ec); + if (ec) { + m_client.get_alog().write(websocketpp::log::alevel::app, + "Get Connection Error: "+ec.message()); + return; + } + + // Grab a handle for this connection so we can talk to it in a thread + // safe manor after the event loop starts. + m_hdl = con->get_handle(); + + // Queue the connection. No DNS queries or network connections will be + // made until the io_service event loop is run. + m_client.connect(con); + + // Create a thread to run the ASIO io_service event loop + websocketpp::lib::thread asio_thread(&client::run, &m_client); + + // Create a thread to run the telemetry loop + websocketpp::lib::thread telemetry_thread(&telemetry_client::telemetry_loop,this); + + asio_thread.join(); + telemetry_thread.join(); + } + + // The open handler will signal that we are ready to start sending telemetry + void on_open(websocketpp::connection_hdl) { + m_client.get_alog().write(websocketpp::log::alevel::app, + "Connection opened, starting telemetry!"); + + scoped_lock guard(m_lock); + m_open = true; + } + + // The close handler will signal that we should stop sending telemetry + void on_close(websocketpp::connection_hdl) { + m_client.get_alog().write(websocketpp::log::alevel::app, + "Connection closed, stopping telemetry!"); + + scoped_lock guard(m_lock); + m_done = true; + } + + // The fail handler will signal that we should stop sending telemetry + void on_fail(websocketpp::connection_hdl) { + m_client.get_alog().write(websocketpp::log::alevel::app, + "Connection failed, stopping telemetry!"); + + scoped_lock guard(m_lock); + m_done = true; + } + + void telemetry_loop() { + uint64_t count = 0; + std::stringstream val; + websocketpp::lib::error_code ec; + + while(1) { + bool wait = false; + + { + scoped_lock guard(m_lock); + // If the connection has been closed, stop generating telemetry + if (m_done) {break;} + + // If the connection hasn't been opened yet wait a bit and retry + if (!m_open) { + wait = true; + } + } + + if (wait) { + wait_a_bit(); + continue; + } + + val.str(""); + val << "count is " << count++; + + m_client.get_alog().write(websocketpp::log::alevel::app, val.str()); + m_client.send(m_hdl,val.str(),websocketpp::frame::opcode::text,ec); + + // The most likely error that we will get is that the connection is + // not in the right state. Usually this means we tried to send a + // message to a connection that was closed or in the process of + // closing. While many errors here can be easily recovered from, + // in this simple example, we'll stop the telemetry loop. + if (ec) { + m_client.get_alog().write(websocketpp::log::alevel::app, + "Send Error: "+ec.message()); + break; + } + + wait_a_bit(); + } + } +private: + client m_client; + websocketpp::connection_hdl m_hdl; + websocketpp::lib::mutex m_lock; + bool m_open; + bool m_done; }; -void on_connected(server *s, websocketpp::connection_hdl hdl) -{ - log::info("new client connected\n"); -} - -void on_disconnect(server *s, websocketpp::connection_hdl hdl) -{ - log::info("client disconnected\n"); -} - - int _main(int argc, char* argv[]) { - // Create a client endpoint - client c; + telemetry_client c; std::string uri = "ws://localhost:9002"; @@ -60,70 +165,13 @@ int _main(int argc, char* argv[]) { uri = argv[1]; } - try { - // Set logging to be pretty verbose (everything except message payloads) - c.set_access_channels(websocketpp::log::alevel::all); - c.clear_access_channels(websocketpp::log::alevel::frame_payload); - - // Initialize ASIO - c.init_asio(); - - // Register our message handler - c.set_message_handler(bind(&on_message,&c,::_1,::_2)); - // disconnect handler - echo_server.set_close_handler(bind(&on_disconnect, &echo_server, ::_1)); - // connect handler - echo_server.set_open_handler(bind(&on_connected, &echo_server, ::_1)); - - websocketpp::lib::error_code ec; - client::connection_ptr con = c.get_connection(uri, ec); - if (ec) { - std::cout << "could not create connection because: " << ec.message() << std::endl; - return 0; - } - - // Note that connect here only requests a connection. No network messages are - // exchanged until the event loop starts running in the next line. - c.connect(con); - - send_thread_args args; - args.c = &c; - args.hdl = con->get_handle(); - - // new thread to send message - maix::thread::Thread t = maix::thread::Thread([](void *args){ - send_thread_args *args_ = (send_thread_args *)args; - client *c = args_->c; - websocketpp::connection_hdl hdl = args_->hdl; - int count = 0; - log::info("send thread started\n"); - while(1){ - websocketpp::lib::error_code ec; - std::string msg = "hello world " + std::to_string(count++) + "\n"; - log::info("send message: %s", msg.c_str()); - c->send(hdl, msg, websocketpp::frame::opcode::text, ec); - if (ec) { - std::cout << "Echo failed because: " << ec.message() << std::endl; - } - time::sleep(5); - - } - }, &args); - log::info("start thread\n"); - t.detach(); - - // Start the ASIO io_service run loop - // this will cause a single connection to be made to the server. c.run() - // will exit when this connection is closed. - c.run(); - } catch (websocketpp::exception const & e) { - std::cout << e.what() << std::endl; - } + c.run(uri); return 0; } int main(int argc, char* argv[]) { + using namespace maix; // Catch signal and process sys::register_default_signal_handle(); diff --git a/examples/nn_face_recognizer/main/src/main.cpp b/examples/nn_face_recognizer/main/src/main.cpp index 37488091..5f0a7a58 100644 --- a/examples/nn_face_recognizer/main/src/main.cpp +++ b/examples/nn_face_recognizer/main/src/main.cpp @@ -42,9 +42,10 @@ int _main(int argc, char *argv[]) uint64_t t = time::ticks_ms(); maix::image::Image *img = cam.read(); err::check_null_raise(img, "read camera failed"); - std::vector *result = recognizer.recognize(*img, conf_threshold, iou_threshold); - for (auto &r : *result) + nn::FaceObjects *results = recognizer.recognize(*img, conf_threshold, iou_threshold); + for (auto &result : *results) { + auto r = *result; img->draw_rect(r.x, r.y, r.w, r.h, maix::image::Color::from_rgb(255, 0, 0)); snprintf(tmp_chars, sizeof(tmp_chars), "%s:%.2f", recognizer.labels[r.class_id].c_str(), r.score); img->draw_string(r.x, r.y, tmp_chars, maix::image::Color::from_rgb(255, 0, 0)); @@ -52,7 +53,7 @@ int _main(int argc, char *argv[]) img->draw_keypoints(r.points, image::COLOR_RED, radius > 4 ? 4 : radius); } disp.show(*img); - delete result; + delete results; delete img; log::info("time: %d ms", time::ticks_ms() - t); } diff --git a/examples/nn_melotts/main/src/main.cpp b/examples/nn_melotts/main/src/main.cpp index 21690ade..3da23021 100644 --- a/examples/nn_melotts/main/src/main.cpp +++ b/examples/nn_melotts/main/src/main.cpp @@ -2,6 +2,7 @@ #include "maix_basic.hpp" #include "maix_nn_melotts.hpp" #include "main.h" +#include "maix_image.hpp" #ifndef PLATFORM_MAIXCAM2 #error "This demo only support maixcam2" #else diff --git a/examples/stream_rtsp_yolo_demo/main/src/main.cpp b/examples/stream_rtsp_yolo_demo/main/src/main.cpp index d30bf2d4..75cc27d5 100644 --- a/examples/stream_rtsp_yolo_demo/main/src/main.cpp +++ b/examples/stream_rtsp_yolo_demo/main/src/main.cpp @@ -14,6 +14,7 @@ #include #include #include "queue" +#ifdef PLATFORM_MAIXCAM #include "sophgo_middleware.hpp" #include "rtsp_server.h" @@ -284,6 +285,14 @@ int _main(int argc, char* argv[]) return 0; } +#else +using namespace maix; +int _main(int argc, char* argv[]) +{ + log::error("This example is not supported on this platform."); + return 0; +} +#endif int main(int argc, char* argv[]) { diff --git a/examples/time_ntp/main/src/main.cpp b/examples/time_ntp/main/src/main.cpp index 549ad773..2c5eed3c 100644 --- a/examples/time_ntp/main/src/main.cpp +++ b/examples/time_ntp/main/src/main.cpp @@ -1,14 +1,14 @@ #include "maix_basic.hpp" #include "main.h" -#include "maix_ntp.hpp" +#include "maix_time.hpp" using namespace maix; int _main(int argc, char* argv[]) { // auto t = maix::ext_dev::ntp::time_with_config("./ntp_config.yaml"); - auto t = maix::ext_dev::ntp::sync_sys_time("ntp.tencent.com"); + auto t = time::ntp_sync_sys_time("ntp.tencent.com"); if (t.empty()) return -1; maix::log::info("\tNTP response : [ %04d-%02d-%02d %02d:%02d:%02d ]\n", diff --git a/examples/video_camera_recorder_simple/.gitignore b/examples/video_camera_recorder_simple/.gitignore deleted file mode 100644 index a323bd48..00000000 --- a/examples/video_camera_recorder_simple/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ - - -build -dist -.config.mk -.flash.conf.json -data - -/CMakeLists.txt diff --git a/examples/video_camera_recorder_simple/main/CMakeLists.txt b/examples/video_camera_recorder_simple/main/CMakeLists.txt deleted file mode 100644 index f79dc771..00000000 --- a/examples/video_camera_recorder_simple/main/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -############### Add include ################### -list(APPEND ADD_INCLUDE "include" - ) -list(APPEND ADD_PRIVATE_INCLUDE "") -############################################### - -############ Add source files ################# -# list(APPEND ADD_SRCS "src/main.c" -# "src/test.c" -# ) -append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD_SRCS -# list(REMOVE_ITEM COMPONENT_SRCS "src/test2.c") -# FILE(GLOB_RECURSE EXTRA_SRC "src/*.c") -# FILE(GLOB EXTRA_SRC "src/*.c") -# list(APPEND ADD_SRCS ${EXTRA_SRC}) -# aux_source_directory(src ADD_SRCS) # collect all source file in src dir, will set var ADD_SRCS -# append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD_SRCS -# list(REMOVE_ITEM COMPONENT_SRCS "src/test.c") -# set(ADD_ASM_SRCS "src/asm.S") -# list(APPEND ADD_SRCS ${ADD_ASM_SRCS}) -# SET_PROPERTY(SOURCE ${ADD_ASM_SRCS} PROPERTY LANGUAGE C) # set .S ASM file as C language -# SET_SOURCE_FILES_PROPERTIES(${ADD_ASM_SRCS} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D BBBBB") -############################################### - -###### Add required/dependent components ###### -list(APPEND ADD_REQUIREMENTS vision) -############################################### - -###### Add link search path for requirements/libs ###### -# list(APPEND ADD_LINK_SEARCH_PATH "${CONFIG_TOOLCHAIN_PATH}/lib") -# list(APPEND ADD_REQUIREMENTS pthread m) # add system libs, pthread and math lib for example here -# set (OpenCV_DIR opencv/lib/cmake/opencv4) -# find_package(OpenCV REQUIRED) -############################################### - -############ Add static libs ################## -# list(APPEND ADD_STATIC_LIB "lib/libtest.a") -############################################### - -#### Add compile option for this component #### -#### Just for this component, won't affect other -#### modules, including component that depend -#### on this component -# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1) - -#### Add compile option for this component -#### and components depend on this component -# list(APPEND ADD_DEFINITIONS -DAAAAA222=1 -# -DAAAAA333=1) -############################################### - -############ Add static libs ################## -#### Update parent's variables like CMAKE_C_LINK_FLAGS -# set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) -############################################### - -######### Add files need to download ######### -# list(APPEND ADD_FILE_DOWNLOADS "{ -# 'url': 'https://*****/abcde.tar.xz', -# 'urls': [], # backup urls, if url failed, will try urls -# 'sites': [], # download site, user can manually download file and put it into dl_path -# 'sha256sum': '', -# 'filename': 'abcde.tar.xz', -# 'path': 'toolchains/xxxxx', -# 'check_files': [] -# }" -# ) -# -# then extracted file in ${DL_EXTRACTED_PATH}/toolchains/xxxxx, -# you can directly use then, for example use it in add_custom_command -############################################## - -# register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib -register_component() diff --git a/examples/video_camera_recorder_simple/main/Kconfig b/examples/video_camera_recorder_simple/main/Kconfig deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/video_camera_recorder_simple/main/include/main.h b/examples/video_camera_recorder_simple/main/include/main.h deleted file mode 100644 index 141204d1..00000000 --- a/examples/video_camera_recorder_simple/main/include/main.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void hello(); - diff --git a/examples/video_camera_recorder_simple/main/src/main.cpp b/examples/video_camera_recorder_simple/main/src/main.cpp deleted file mode 100644 index 7a5f0975..00000000 --- a/examples/video_camera_recorder_simple/main/src/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -#include "stdio.h" -#include "main.h" -#include "maix_util.hpp" -#include "maix_image.hpp" -#include "maix_time.hpp" -#include "maix_display.hpp" -#include "maix_video.hpp" -#include "maix_camera.hpp" -#include "maix_basic.hpp" -#include "csignal" -#include -#include -#include -#include - -using namespace maix; - -int _main(int argc, char* argv[]) -{ - camera::Camera cam = camera::Camera(2560, 1440, image::Format::FMT_YVU420SP); - video::Video v = video::Video("output.mp4", true); - - v.bind_camera(&cam); - v.record_start(); - - int sleep_s = 5; - while(!app::need_exit()) { - if (sleep_s -- <= 0) { - v.record_finish(); - log::info("record finished!\r\n"); - } - time::sleep(1); - } - - return 0; -} - -int main(int argc, char* argv[]) -{ - // Catch signal and process - sys::register_default_signal_handle(); - - // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, - // if we don't catch exception, when program throw exception, the objects will not be destructed. - // So we catch exception here to let resources be released(call objects' destructor) before exit. - CATCH_EXCEPTION_RUN_RETURN(_main, -1, argc, argv); -} diff --git a/examples/vision_image_method/main.c b/examples/vision_image_method/main.c deleted file mode 100644 index 54219f33..00000000 --- a/examples/vision_image_method/main.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -using namespace std; - -// 计算点到直线的垂直距离 -double perpendicularDistance(double x0, double y0, double rho, double theta) { - // 计算距离 - double distance = fabs(x0 * cos(theta) + y0 * sin(theta) - rho); - return distance; -} - -int main() { - double x0, y0, rho, theta; - - // 输入直线参数 rho 和 theta - cout << "请输入直线的 rho: "; - cin >> rho; - cout << "请输入直线的 theta (弧度): "; - cin >> theta; - - // 输入点的坐标 - cout << "请输入点的 x 坐标: "; - cin >> x0; - cout << "请输入点的 y 坐标: "; - cin >> y0; - - // 计算垂直距离 - double distance = perpendicularDistance(x0, y0, rho, theta); - - // 输出结果 - cout << "点 (" << x0 << ", " << y0 << ") 到直线的垂直距离为: " << distance << endl; - - return 0; -} diff --git a/examples/vision_image_method/main/CMakeLists.txt b/examples/vision_image_method/main/CMakeLists.txt index 31b95fd1..864470d4 100644 --- a/examples/vision_image_method/main/CMakeLists.txt +++ b/examples/vision_image_method/main/CMakeLists.txt @@ -3,16 +3,6 @@ list(APPEND ADD_INCLUDE "include" ) ############################################### -# ed lib -list(APPEND ADD_PRIVATE_INCLUDE "ed_lib/ED_Lib") -list(APPEND ADD_SRCS "ed_lib/ED_Lib/ED.cpp" - "ed_lib/ED_Lib/EDCircles.cpp" - "ed_lib/ED_Lib/EDColor.cpp" - "ed_lib/ED_Lib/EDLines.cpp" - "ed_lib/ED_Lib/EDPF.cpp" - "ed_lib/ED_Lib/NFA.cpp" - ) - ############ Add source files ################# # list(APPEND ADD_SRCS "src/main.c" # "src/test.c" diff --git a/examples/vision_image_method/main/src/main.cpp b/examples/vision_image_method/main/src/main.cpp index a63d0ecc..11632412 100644 --- a/examples/vision_image_method/main/src/main.cpp +++ b/examples/vision_image_method/main/src/main.cpp @@ -138,7 +138,6 @@ static int cmd_init(int argc, char* argv[]) priv.method_list.push_back(image_method_t{"find_qrcode", test_find_qrcode}); priv.method_list.push_back(image_method_t{"qrcode_detector", test_qrcode_detector}); priv.method_list.push_back(image_method_t{"find_lines", test_find_lines}); - priv.method_list.push_back(image_method_t{"ed lib", test_ed_lib}); priv.method_list.push_back(image_method_t{"tracking line", test_tracking_line}); priv.method_list.push_back(image_method_t{"find_barcode", test_find_barcode}); priv.method_list.push_back(image_method_t{"to_format", test_to_format}); diff --git a/examples/vision_image_method/main/src/test_ed_lib.cpp b/examples/vision_image_method/main/src/test_ed_lib.cpp deleted file mode 100644 index 250e2756..00000000 --- a/examples/vision_image_method/main/src/test_ed_lib.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "test_image.hpp" - -#include "EDLib.h" - -static int ED_Lib_test(image::Image *input) -{ - auto img = input; - auto gray_img = (image::Image *)nullptr; - auto need_free_gray_img = false; - if (img->format() != image::FMT_GRAYSCALE) { - gray_img = img->to_format(image::FMT_GRAYSCALE); - need_free_gray_img = true; - } else { - gray_img = img; - need_free_gray_img = false; - } - - auto cv_gray = cv::Mat(gray_img->height(), gray_img->width(), CV_8UC1, gray_img->data()); - - uint64_t t = time::ticks_ms(); - double line_error = 1.0; - int min_line_len = -1; - double max_distance = 6; - double max_error = 1.3; - auto ed_lines = EDLines(cv_gray, line_error, min_line_len, max_distance, max_error); - auto ed_lines_res = ed_lines.getLines(); - log::info(" EDLines use %ld ms, size:%d", time::ticks_ms() - t, ed_lines_res.size()); - - for (auto &l : ed_lines_res) { - img->draw_line(l.start.x, l.start.y, l.end.x, l.end.y, image::COLOR_GREEN); - } - - if (need_free_gray_img) { - delete gray_img; - } - return 0; -} - -int test_ed_lib(image::Image *img) { - ED_Lib_test(img); - return 0; -} \ No newline at end of file diff --git a/examples/vision_touchscreen_read/main/src/main.cpp b/examples/vision_touchscreen_read/main/src/main.cpp index dc81ace2..509959d8 100644 --- a/examples/vision_touchscreen_read/main/src/main.cpp +++ b/examples/vision_touchscreen_read/main/src/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) // // support default maix communication protol commands // comm::add_default_comm_listener(); - default key action + // default key action peripheral::key::add_default_listener(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, diff --git a/test/test_examples/test_cases.sh b/test/test_examples/test_cases.sh index a046702d..6f3704a9 100755 --- a/test/test_examples/test_cases.sh +++ b/test/test_examples/test_cases.sh @@ -5,6 +5,7 @@ set -x platform=$1 need_run=$2 +start_from="$3" if [ "${need_run}x" == "1x" ]; then run_cmd="maixcdk run" else @@ -12,7 +13,10 @@ else fi blacklist=("maixcdk-example") - +start_test_flag=false +if [ "$start_from" == "" ]; then + start_test_flag=true +fi function test_script() { set +x @@ -62,6 +66,18 @@ for dir in */; do continue fi + # 检查是否开始测试 + if [ -n $start_test_flag ]; then + if [[ "${dir}" == "${start_from}/" ]]; then + start_test_flag=true + fi + fi + + if ! $start_test_flag; then + echo "skip $dir, wait ${start_from}" + continue + fi + test_start "${dir%/}" fi done