* Fix compilation errors

This commit is contained in:
lxowalle
2025-12-05 10:23:32 +08:00
parent dc9e26e67a
commit eb395eca9d
28 changed files with 416 additions and 379 deletions

View File

@@ -4,7 +4,7 @@ def add_file_downloads(confs : dict) -> list:
@param confs kconfig vars, dict type @param confs kconfig vars, dict type
@return list type, items is 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" url = f"https://github.com/paullouisageneau/libjuice/archive/refs/tags/v{version}.tar.gz"
if version == "1.5.8": if version == "1.5.8":
sha256sum = "aa81809384c7e2594853304034a60fa2c2a234483b31cb531a4fc19e5877b709" sha256sum = "aa81809384c7e2594853304034a60fa2c2a234483b31cb531a4fc19e5877b709"

View File

@@ -9,7 +9,7 @@ endif()
if(PLATFORM_MAIXCAM) if(PLATFORM_MAIXCAM)
list(APPEND ADD_INCLUDE "${src_path}/include") list(APPEND ADD_INCLUDE "${src_path}/include")
elseif(PLATFORM_MAIXCAM2) elseif(PLATFORM_MAIXCAM2)
list(APPEND ADD_INCLUDE "${src_path}/include/onnxruntime") list(APPEND ADD_INCLUDE "${src_path}/include")
endif() endif()
# list(APPEND ADD_PRIVATE_INCLUDE "include_private") # list(APPEND ADD_PRIVATE_INCLUDE "include_private")

View File

@@ -18,6 +18,11 @@ namespace maix::sys
} }
} }
void poweroff()
{
log::info("Your platform is linux, poweroff will not execute");
}
void register_default_signal_handle() { void register_default_signal_handle() {
signal(SIGINT, signal_handle); signal(SIGINT, signal_handle);
} }

View File

@@ -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

View File

@@ -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

View File

@@ -2,7 +2,7 @@
* LLM Qwen3VL implementation on MaixCam2 * LLM Qwen3VL implementation on MaixCam2
* @license Apache-2.0 * @license Apache-2.0
* @author lxo@sipeed * @author lxo@sipeed
* @date 2025-011-24 * @date 2025-11-24
*/ */
#include "maix_vlm_qwen3.hpp" #include "maix_vlm_qwen3.hpp"

View File

@@ -1,8 +1,8 @@
/** /**
* LLM SmolVLM implementation on MaixCam2 * LLM SmolVLM implementation on MaixCam2
* @license Apache-2.0 * @license Apache-2.0
* @author neucrack@sipeed * @author lxo@sipeed
* @date 2025-06-03 * @date 2025-11-24
*/ */
#include "maix_vlm_smolvlm.hpp" #include "maix_vlm_smolvlm.hpp"

View File

@@ -17,7 +17,7 @@
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include <fstream> #include <fstream>
#include "onnxruntime_cxx_api.h" #include "onnxruntime/onnxruntime_cxx_api.h"
#include "maix_nn_melotts.hpp" #include "maix_nn_melotts.hpp"
namespace maix::nn namespace maix::nn

View File

@@ -1,5 +1,3 @@
#pragma once
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -252,46 +252,46 @@ namespace maix::peripheral::uart
this->close(); this->close();
} }
static int set_pinmux(uint64_t addr, uint32_t value) // static int set_pinmux(uint64_t addr, uint32_t value)
{ // {
// 假设我们的系统页大小为4KB // // 假设我们的系统页大小为4KB
#define PAGE_SIZE 4096 // #define PAGE_SIZE 4096
#define PAGE_MASK (PAGE_SIZE - 1) // #define PAGE_MASK (PAGE_SIZE - 1)
int fd; // int fd;
void *map_base, *virt_addr; // void *map_base, *virt_addr;
/* 打开 /dev/mem 文件 */ // /* 打开 /dev/mem 文件 */
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) // if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
{ // {
perror("Error opening /dev/mem"); // perror("Error opening /dev/mem");
return -1; // return -1;
} // }
/* 映射需要访问的物理内存页到进程空间 */ // /* 映射需要访问的物理内存页到进程空间 */
map_base = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~PAGE_MASK); // map_base = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr & ~PAGE_MASK);
if (map_base == (void *)-1) // if (map_base == (void *)-1)
{ // {
perror("Error mapping memory"); // perror("Error mapping memory");
close(fd); // close(fd);
return -1; // 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) // if (munmap(map_base, PAGE_SIZE) == -1)
{ // {
perror("Error unmapping memory"); // perror("Error unmapping memory");
} // }
close(fd); // close(fd);
return 0; // return 0;
} // }
err::Err UART::open() err::Err UART::open()
{ {

View File

@@ -1,5 +1,3 @@
#pragma once
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -1,5 +1,3 @@
#pragma once
#include <string> #include <string>
#include <vector> #include <vector>

View File

@@ -1,58 +1,163 @@
#include <iostream>
#include "maix_basic.hpp" #include "maix_basic.hpp"
#include "main.h" #include "maix_err.hpp"
#include <websocketpp/config/asio_no_tls_client.hpp> #include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp> #include <websocketpp/client.hpp>
// 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 <websocketpp/common/thread.hpp>
typedef websocketpp::client<websocketpp::config::asio_client> client; /**
* Define a semi-cross platform helper method that waits/sleeps for a bit.
using websocketpp::lib::placeholders::_1; */
using websocketpp::lib::placeholders::_2; void wait_a_bit() {
using websocketpp::lib::bind; #ifdef WIN32
using namespace maix; Sleep(1000);
#else
sleep(1);
// pull out the type of messages sent by our config #endif
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;
// }
} }
struct send_thread_args{ /**
client *c; * The telemetry client connects to a WebSocket server and sends a message every
websocketpp::connection_hdl hdl; * 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<websocketpp::config::asio_client> client;
typedef websocketpp::lib::lock_guard<websocketpp::lib::mutex> 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[]) { int _main(int argc, char* argv[]) {
// Create a client endpoint telemetry_client c;
client c;
std::string uri = "ws://localhost:9002"; std::string uri = "ws://localhost:9002";
@@ -60,70 +165,13 @@ int _main(int argc, char* argv[]) {
uri = argv[1]; uri = argv[1];
} }
try { c.run(uri);
// 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;
}
return 0; return 0;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
using namespace maix;
// Catch signal and process // Catch signal and process
sys::register_default_signal_handle(); sys::register_default_signal_handle();

View File

@@ -42,9 +42,10 @@ int _main(int argc, char *argv[])
uint64_t t = time::ticks_ms(); uint64_t t = time::ticks_ms();
maix::image::Image *img = cam.read(); maix::image::Image *img = cam.read();
err::check_null_raise(img, "read camera failed"); err::check_null_raise(img, "read camera failed");
std::vector<nn::FaceObject> *result = recognizer.recognize(*img, conf_threshold, iou_threshold); nn::FaceObjects *results = recognizer.recognize(*img, conf_threshold, iou_threshold);
for (auto &r : *result) 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)); 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); 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)); 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); img->draw_keypoints(r.points, image::COLOR_RED, radius > 4 ? 4 : radius);
} }
disp.show(*img); disp.show(*img);
delete result; delete results;
delete img; delete img;
log::info("time: %d ms", time::ticks_ms() - t); log::info("time: %d ms", time::ticks_ms() - t);
} }

View File

@@ -2,6 +2,7 @@
#include "maix_basic.hpp" #include "maix_basic.hpp"
#include "maix_nn_melotts.hpp" #include "maix_nn_melotts.hpp"
#include "main.h" #include "main.h"
#include "maix_image.hpp"
#ifndef PLATFORM_MAIXCAM2 #ifndef PLATFORM_MAIXCAM2
#error "This demo only support maixcam2" #error "This demo only support maixcam2"
#else #else

View File

@@ -14,6 +14,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "queue" #include "queue"
#ifdef PLATFORM_MAIXCAM
#include "sophgo_middleware.hpp" #include "sophgo_middleware.hpp"
#include "rtsp_server.h" #include "rtsp_server.h"
@@ -284,6 +285,14 @@ int _main(int argc, char* argv[])
return 0; 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[]) int main(int argc, char* argv[])
{ {

View File

@@ -1,14 +1,14 @@
#include "maix_basic.hpp" #include "maix_basic.hpp"
#include "main.h" #include "main.h"
#include "maix_ntp.hpp" #include "maix_time.hpp"
using namespace maix; using namespace maix;
int _main(int argc, char* argv[]) int _main(int argc, char* argv[])
{ {
// auto t = maix::ext_dev::ntp::time_with_config("./ntp_config.yaml"); // 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; if (t.empty()) return -1;
maix::log::info("\tNTP response : [ %04d-%02d-%02d %02d:%02d:%02d ]\n", maix::log::info("\tNTP response : [ %04d-%02d-%02d %02d:%02d:%02d ]\n",

View File

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

View File

@@ -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()

View File

@@ -1,4 +0,0 @@
#pragma once
void hello();

View File

@@ -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 <iostream>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
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);
}

View File

@@ -1,35 +0,0 @@
#include <iostream>
#include <cmath>
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;
}

View File

@@ -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 ################# ############ Add source files #################
# list(APPEND ADD_SRCS "src/main.c" # list(APPEND ADD_SRCS "src/main.c"
# "src/test.c" # "src/test.c"

View File

@@ -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{"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{"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{"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{"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{"find_barcode", test_find_barcode});
priv.method_list.push_back(image_method_t{"to_format", test_to_format}); priv.method_list.push_back(image_method_t{"to_format", test_to_format});

View File

@@ -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;
}

View File

@@ -35,7 +35,7 @@ int main(int argc, char* argv[])
// // support default maix communication protol commands // // support default maix communication protol commands
// comm::add_default_comm_listener(); // comm::add_default_comm_listener();
default key action // default key action
peripheral::key::add_default_listener(); peripheral::key::add_default_listener();
// Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // Use CATCH_EXCEPTION_RUN_RETURN to catch exception,

View File

@@ -5,6 +5,7 @@ set -x
platform=$1 platform=$1
need_run=$2 need_run=$2
start_from="$3"
if [ "${need_run}x" == "1x" ]; then if [ "${need_run}x" == "1x" ]; then
run_cmd="maixcdk run" run_cmd="maixcdk run"
else else
@@ -12,7 +13,10 @@ else
fi fi
blacklist=("maixcdk-example") blacklist=("maixcdk-example")
start_test_flag=false
if [ "$start_from" == "" ]; then
start_test_flag=true
fi
function test_script() function test_script()
{ {
set +x set +x
@@ -62,6 +66,18 @@ for dir in */; do
continue continue
fi 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%/}" test_start "${dir%/}"
fi fi
done done