Skip to content

Commit

Permalink
optimize image.compress func and fix lvgl build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed May 13, 2024
1 parent a9851f2 commit d598660
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion components/3rd_party/lvgl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

set(version_str "${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MAJOR}")
set(version_str "${CONFIG_LVGL_VERSION_MAJOR}.${CONFIG_LVGL_VERSION_MINOR}.${CONFIG_LVGL_VERSION_PATCH}")
set(unzip_dir_name "lvgl-${version_str}")

set(unzip_path "${DL_EXTRACTED_PATH}/lvgl_srcs/${unzip_dir_name}")
Expand Down
2 changes: 1 addition & 1 deletion components/3rd_party/lvgl/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def add_file_downloads(confs : dict) -> list:
path = f"lvgl_srcs/lvgl-{version}"
check_file = 'lvgl'
rename = {
'lvgl-{version}': 'lvgl'
f'lvgl-{version}': 'lvgl'
}

return [
Expand Down
2 changes: 1 addition & 1 deletion components/vision/include/maix_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ namespace maix::image
image::Image *midpoint_pool(int x_div, int y_div, double bias = 0.5, bool copy = false);

/**
* @brief JPEG compresses the image in place.
* @brief JPEG compresses the image in place, the same as to_jpeg functioin, it's recommend to use to_jpeg instead.
* @param quality The quality of the compressed image. default is 95.
* @return Returns the compressed JPEG image
* @maixpy maix.image.Image.compress
Expand Down
18 changes: 1 addition & 17 deletions components/vision/src/maix_image_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,7 @@ namespace maix::image {
}

image::Image *Image::compress(int quality) {
if (quality < 0) {
log::warn("compress invalid quality: %d", quality);
return nullptr;
}

quality = quality > 100 ? 100 : quality;

cv::Mat img(_height, _width, CV_8UC((int)image::fmt_size[_format]), _data);
std::vector<uchar> compressed;
std::vector<int> params;
params.push_back(cv::IMWRITE_JPEG_QUALITY);
params.push_back(quality);
cv::imencode(".jpg", img, compressed, params);

int dst_data_size = compressed.size();
image::Image *dst = new image::Image(_width, _height, Format::FMT_JPEG, compressed.data(), dst_data_size, true);
return dst;
return to_jpeg(quality);
}

err::Err image_zero(image::Image &src, image::Image &mask, bool invert) {
Expand Down
2 changes: 2 additions & 0 deletions tools/cmake/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def find_valid_components(components):
depends[name] = []
for r in match:
if r in components:
if name == r:
continue
depends[name].append(r)
# find main depends
def get_depend_recursive(name):
Expand Down

0 comments on commit d598660

Please sign in to comment.