diff --git a/components/nn/include/maix_nn_object.hpp b/components/nn/include/maix_nn_object.hpp index 5fd7124b..fb37d6c5 100644 --- a/components/nn/include/maix_nn_object.hpp +++ b/components/nn/include/maix_nn_object.hpp @@ -259,7 +259,7 @@ namespace maix::nn /** * Get object item - * @maixpy maix.nn.Objects.__item__ + * @maixpy maix.nn.Objects.__getitem__ * @maixcdk maix.nn.Objects.[] */ nn::Object &operator[](int idx) diff --git a/components/nn/include/maix_nn_ocr_object.hpp b/components/nn/include/maix_nn_ocr_object.hpp index c25f96d3..e9f39664 100644 --- a/components/nn/include/maix_nn_ocr_object.hpp +++ b/components/nn/include/maix_nn_ocr_object.hpp @@ -261,7 +261,7 @@ namespace maix::nn /** * Get object item - * @maixpy maix.nn.OCR_Objects.__item__ + * @maixpy maix.nn.OCR_Objects.__getitem__ * @maixcdk maix.nn.OCR_Objects.[] */ nn::OCR_Object &operator[](int idx) diff --git a/components/nn/include/maix_nn_yolo11.hpp b/components/nn/include/maix_nn_yolo11.hpp index 36a95de3..bd3121b3 100644 --- a/components/nn/include/maix_nn_yolo11.hpp +++ b/components/nn/include/maix_nn_yolo11.hpp @@ -346,12 +346,12 @@ namespace maix::nn int y2 = points[pos[i * 2 + 1] * 2 + 1]; if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) continue; - img.draw_line(x1, y1, x2, y2, image::COLOR_RED, 2); + img.draw_line(x1, y1, x2, y2, color, 2); } int x = (points[5 * 2] + points[6 * 2]) / 2; int y = (points[5 * 2 + 1] + points[6 * 2 + 1]) / 2; if (!(points[5 * 2] < 0 || points[5 * 2 + 1] < 0 || points[6 * 2] < 0 || points[6 * 2 + 1] < 0 || x < 0 || y < 0 || points[0] < 0 || points[1] < 0)) - img.draw_line(points[0], points[1], x, y, image::COLOR_RED, 2); + img.draw_line(points[0], points[1], x, y, color, 2); } for (size_t i = 0; i < points.size() / 2; ++i) { diff --git a/components/vision/include/maix_display.hpp b/components/vision/include/maix_display.hpp index 2ae4dc09..793ed0ba 100644 --- a/components/vision/include/maix_display.hpp +++ b/components/vision/include/maix_display.hpp @@ -202,4 +202,11 @@ namespace maix::display * @maixpy maix.display.send_to_maixvision */ void send_to_maixvision(image::Image &img); + + /** + * Set image transport quality(only for JPEG) + * @param quality default 95, value from 51 ~ 100 + * @maixpy maix.display.set_trans_image_quality + */ + void set_trans_image_quality(const int value); } diff --git a/components/vision/include_private/maix_image_trans.hpp b/components/vision/include_private/maix_image_trans.hpp index 368e7145..305f7082 100644 --- a/components/vision/include_private/maix_image_trans.hpp +++ b/components/vision/include_private/maix_image_trans.hpp @@ -16,6 +16,7 @@ namespace maix err::Err send_image(image::Image &img); err::Err set_format(image::Format fmt, int quality = 95); image::Format get_format() { return _fmt; } + void set_quality(const int quality) { _quality = quality; } private: void *_handle; diff --git a/components/vision/src/maix_display.cpp b/components/vision/src/maix_display.cpp index 1da27d8b..acba8b51 100644 --- a/components/vision/src/maix_display.cpp +++ b/components/vision/src/maix_display.cpp @@ -276,4 +276,10 @@ namespace maix::display } + void set_trans_image_quality(const int value) + { + if(img_trans) + img_trans->set_quality(value); + } + } // namespace maix::display diff --git a/components/vision/src/maix_image_trans.cpp b/components/vision/src/maix_image_trans.cpp index a23ea898..71a06605 100644 --- a/components/vision/src/maix_image_trans.cpp +++ b/components/vision/src/maix_image_trans.cpp @@ -34,6 +34,8 @@ using websocketpp::lib::placeholders::_2; #define IMG_ENCODE_JPEG 1 #define IMG_ENCODE_PNG 2 +static int jpeg_quality = 95; + enum ImageTransFmt { IMG_TRANS_FMT_NONE = 0, // pause trans @@ -454,7 +456,14 @@ namespace maix // compress image to jpeg if (img.format() != _fmt) { - compressed = img.to_format(_fmt); + if(_fmt == image::FMT_JPEG) + { + compressed = img.to_jpeg(this->_quality); + } + else + { + compressed = img.to_format(_fmt); + } if (compressed == nullptr) { log::error("compress image failed\n");