From 1993e53a565e0168e351b1678b1ef6fd68655987 Mon Sep 17 00:00:00 2001 From: Neucrack Date: Tue, 8 Apr 2025 14:03:44 +0800 Subject: [PATCH] fix compile error --- components/3rd_party/FFmpeg/component.py | 2 +- .../peripheral/port/maixcam/maix_key.cpp | 10 ++++- .../vision/port/maixcam2/maix_uvc_stream.cpp | 44 +++++++++++++++++++ components/vision/src/maix_image.cpp | 5 +++ components/vision_extra/CMakeLists.txt | 12 ++--- .../port/linux/maix_image_qrcode_detector.cpp | 5 ++- .../maixcam2/maix_image_qrcode_detector.cpp | 2 +- 7 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 components/vision/port/maixcam2/maix_uvc_stream.cpp diff --git a/components/3rd_party/FFmpeg/component.py b/components/3rd_party/FFmpeg/component.py index ebdc4e71..158a111f 100644 --- a/components/3rd_party/FFmpeg/component.py +++ b/components/3rd_party/FFmpeg/component.py @@ -42,7 +42,7 @@ def add_file_downloads(confs : dict) -> list: elif version == "6.1.1.1": sha256sum = "a768eef0ab5841d63cb99dc4ee66b0b252b56ecce0bb8d344eb68bb8d6e49735" else: - raise Exception(f"version {version} not support") + raise Exception(f"version {version} not support, please add support in component.py of FFmpeg") sites = ["https://github.com/sipeed/MaixCDK/releases/tag/v0.0.0"] filename = f"ffmpeg_maixcam2_libs_n{version}.tar.xz" path = f"ffmpeg_srcs" diff --git a/components/peripheral/port/maixcam/maix_key.cpp b/components/peripheral/port/maixcam/maix_key.cpp index 76c31782..1403319b 100755 --- a/components/peripheral/port/maixcam/maix_key.cpp +++ b/components/peripheral/port/maixcam/maix_key.cpp @@ -47,7 +47,13 @@ namespace maix::peripheral::key { if(_default_key) return; - _default_key = new Key(on_key, true, KEY_DEVICE0); + try + { + _default_key = new Key(on_key, true, KEY_DEVICE0); + } catch (const std::exception& e) { + log::warn("Initialize Key failed, no key driver, %s", e.what()); + return; + } _key_defult_listener = true; } @@ -353,7 +359,7 @@ namespace maix::peripheral::key err::Err e = this->open(); if (e != err::ERR_NONE) { - throw err::Exception(err::ERR_NOT_FOUND, std::string("Key device") + this->_device + " not found"); + throw err::Exception(err::ERR_NOT_FOUND, std::string("Key device ") + this->_device + " not found"); } } } diff --git a/components/vision/port/maixcam2/maix_uvc_stream.cpp b/components/vision/port/maixcam2/maix_uvc_stream.cpp new file mode 100644 index 00000000..8fff93a2 --- /dev/null +++ b/components/vision/port/maixcam2/maix_uvc_stream.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include +#include +#include +#include + +#include "maix_uvc_stream.hpp" + +extern "C" { + +extern int uvc_main_exist; +extern int uvc_main(int argc, char *argv[]); + +int uvc_video_fill_mjpg_buffer(void *buf, uint32_t *size) { + return -1; +} + +} + +namespace maix::uvc +{ +int helper_fill_mjpg_image(void* buf, uint32_t* size, image::Image *img) { + return -1; +} + +// 静态成员定义 +UvcServer *UvcServer::_instance = nullptr; + +void UvcServer::run() { } + +void UvcServer::stop() { } + +UvcStreamer::UvcStreamer(): _using_jpeg(0) { } + +UvcStreamer::~UvcStreamer() { } + + +err::Err UvcStreamer::show(image::Image *img) { + return err::ERR_NOT_IMPL; +} + +} \ No newline at end of file diff --git a/components/vision/src/maix_image.cpp b/components/vision/src/maix_image.cpp index 0d3d945d..e8badb42 100644 --- a/components/vision/src/maix_image.cpp +++ b/components/vision/src/maix_image.cpp @@ -386,6 +386,11 @@ namespace maix::image if (!_actual_data) throw err::Exception(err::ERR_NO_MEM, "malloc image data failed"); _data = (void *)(((uint64_t)_actual_data + 0x1000) & ~0xFFF); +#if PLATFORM_MAIXCAM + // memset(_data, 0, _data_size); +#else + memset(_data, 0, _data_size); +#endif // log::debug("malloc image data\n"); _is_malloc = true; } diff --git a/components/vision_extra/CMakeLists.txt b/components/vision_extra/CMakeLists.txt index bfc781cd..139bf235 100644 --- a/components/vision_extra/CMakeLists.txt +++ b/components/vision_extra/CMakeLists.txt @@ -36,13 +36,7 @@ endif() ###### Add required/dependent components ###### -if(PLATFORM_LINUX) - list(APPEND ADD_REQUIREMENTS nn) -elseif(PLATFORM_MAIXCAM) - list(APPEND ADD_REQUIREMENTS nn) -elseif(PLATFORM_MAIXCAM2) - list(APPEND ADD_REQUIREMENTS nn) -endif() +list(APPEND ADD_REQUIREMENTS nn) ############################################### ###### Add link search path for requirements/libs ###### @@ -63,8 +57,8 @@ endif() ############################################### #### Add compile option for this component #### -#### Just for this component, won't affect other -#### modules, including component that depend +#### Just for this component, won't affect other +#### modules, including component that depend #### on this component # list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1) diff --git a/components/vision_extra/port/linux/maix_image_qrcode_detector.cpp b/components/vision_extra/port/linux/maix_image_qrcode_detector.cpp index 81136c22..9451e105 100644 --- a/components/vision_extra/port/linux/maix_image_qrcode_detector.cpp +++ b/components/vision_extra/port/linux/maix_image_qrcode_detector.cpp @@ -8,13 +8,14 @@ #include "maix_image.hpp" #include "maix_image_obj.hpp" #include "maix_image_extra.hpp" +#include "maix_basic.hpp" using namespace maix; namespace maix::image { QRCodeDetector::QRCodeDetector() { - + throw err::Exception(err::ERR_NOT_IMPL); } QRCodeDetector::~QRCodeDetector() { @@ -28,4 +29,4 @@ namespace maix::image (void)decoder_type; return std::vector(); } -} \ No newline at end of file +} diff --git a/components/vision_extra/port/maixcam2/maix_image_qrcode_detector.cpp b/components/vision_extra/port/maixcam2/maix_image_qrcode_detector.cpp index 753b0bbe..18322b3c 100644 --- a/components/vision_extra/port/maixcam2/maix_image_qrcode_detector.cpp +++ b/components/vision_extra/port/maixcam2/maix_image_qrcode_detector.cpp @@ -72,4 +72,4 @@ namespace maix::image return out; } -} \ No newline at end of file +}