pixelFree Beauty SDK

repository·master·Indexed 21 days ago

https://github.com/uu-code007/pixelfreeeffects

A professional-grade, high-performance beauty and special effects SDK for real-time video processing in live streaming, social media, and camera applications. It supports iOS, Android, Windows, HarmonyOS, Flutter, and Linux. Core capabilities include facial beauty and reshaping, makeup application, skin detail enhancement, 2D face stickers, green screen background replacement, and camera color grading via HLS adjustments.

Tokens
48.9K
Snippets
146
Records
191
Agent score
71%

What's inside pixelFree

  1. Overview of pixelFree Beauty SDK

    master

    pixelFree is a lightweight, high-performance beauty and special effects SDK designed for cross-platform use. It is primarily intended for live streaming, short video applications, ID photo processing, photo editing, and camera applications.

    Core Capabilities:

    • Camera color grading (HLS adjustment)
    • Facial beauty and reshaping
    • Makeup application
    • Skin detail enhancement
    • Skin tone modification
    • 2D face stickers
    • Green screen background replacement
  2. Overview of SMBeautyEngine License API

    master

    The SMBeautyEngine License API provides license health checking and management capabilities. It supports configuration management via data tables and allows for file uploading and downloading.

    Base URL: https://localhost:2443
    API Version: v1.0
    Content Type: application/json

    Authentication: Currently, the API requires no authentication, but it is recommended to implement JWT or API Key authentication for production environments.

  3. Overview of SDWebImage features

    master

    SDWebImage is an asynchronous image downloader for Apple platforms with built-in support for memory and disk caching. It provides specialized categories for UIImageView, UIButton, and MKAnnotationView to simplify web image loading and cache management.

    Key capabilities include:

    • Asynchronous Operations: Image downloading, memory/disk caching, and background decompression to prevent main thread blocking.
    • Performance Optimizations: Progressive image loading, thumbnail image decoding for large files, and automatic cache expiration.
    • Extensibility: A coder plugin system for new image formats (WebP, HEIC, AVIF, etc.), customizable cache systems, and custom loaders (e.g., for Photos Library).
    • UI Enhancements: Support for image loading indicators, transition animations, and animated images (GIF/APNG).
  4. Project structure of SMBeautyEngine Linux

    master

    The SMBeautyEngine Linux project is organized into several key directories for building and running the beauty engine:

    • include/: Contains core headers like gl.h, opengl.h, and stb_image.h.
    • pixelfreeLib/: The core library directory containing libPixelFree.so (the Linux dynamic library) and pixelFree_c.hpp (the C++ header interface).
    • Res/: Contains essential runtime resources, including pixelfreeAuth.lic (license file) and filter_model.bundle (filter models).
    • src/: Contains the application source code (main.cpp, opengl.cpp).
    • third_party/: Contains external dependencies like glad, glfw, and stb.
  5. SMBeautyEngine Windows project structure

    master

    The project is organized as follows:

    • include/: Header files (gl.h, opengl.h, opengl_observer.h, stb_image.h).
    • pixelfreeLib/: The core pixelFree library files:
      • Include/pixelFree_c.hpp: C++ header for the library.
      • pixelFree.lib: Windows static library.
      • pixelFree.dll: Windows dynamic library.
    • Res/: Required resource files (pixelfreeAuth.lic for licensing and filter_model.bundle).
    • src/: Source code (main.cpp, opengl.cpp, stb_image.cpp).
    SMBeautyEngine_windows/
    ├── CMakeLists.txt        # CMake构建配置
    ├── include/              # 头文件
    │   ├── gl.h
    │   ├── opengl.h
    │   ├── opengl_observer.h
    │   └── stb_image.h
    ├── pixelfreeLib/         # pixelFree库文件
    │   ├── Include/
    │   │   └── pixelFree_c.hpp
    │   ├── pixelFree.lib     # Windows静态库
    │   └── pixelFree.dll     # Windows动态库
    ├── Res/                  # 资源文件
    │   ├── pixelfreeAuth.lic
    │   └── filter_model.bundle
    ├── src/                  # 源代码
    │   ├── main.cpp
    │   ├── opengl.cpp
    │   └── stb_image.cpp
    └── IMG_2406.png          # 测试图片
  6. Constraint targets: Views, Numbers, and Arrays

    master

    Equality constraints (.equalTo, .lessThanOrEqualTo, .greaterThanOrEqualTo) accept several types of arguments:

    1. MASViewAttribute: Reference another view's attribute (e.g., view2.mas_left).
    2. UIView/NSView: Reference an entire view (e.g., make.left.greaterThanOrEqualTo(label)).
    3. NSNumber/Primitives: Set constant values.
      • For alignment attributes (left, top, etc.), passing a number creates a constraint relative to the superview (e.g., make.left.lessThanOrEqualTo(@10) creates view.left <= superview.left + 10).
      • You can use mas_equalTo with primitives/structs: make.top.mas_equalTo(42);, make.size.mas_equalTo(CGSizeMake(50, 100));, or make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0));.
    4. NSArray: A mixture of the above (e.g., make.left.equalTo(@[view1, @100, view3.right]);).
    // width >= 200 && width <= 400
    make.width.greaterThanOrEqualTo(@200);
    make.width.lessThanOrEqualTo(@400);
    
    // Using primitives
    make.top.mas_equalTo(42);
    make.size.mas_equalTo(CGSizeMake(50, 100));
  7. SDWebImage Ecosystem and Modules

    master

    SDWebImage is modularized to allow for specialized functionality through additional modules and plugins.

    SwiftUI Support

    Use the SDWebImageSwiftUI framework to integrate with SwiftUI. It provides:

    • WebImage and AnimatedImage View structs.
    • ImageIndicator modifier for loading states.
    • ImageManager observable object for data sources.
    • Supports iOS 13+, macOS 10.15+, tvOS 13+, and watchOS 6+.

    Specialized Plugins

    • Coders: Support for WebP, HEIF, BPG, FLIF, AVIF, PDF, SVG, Lottie, and JPEG-XL.
    • Caches: Integration with YYCache (SDWebImageYYPlugin) or PINCache (SDWebImagePINPlugin).
    • Loaders: Loading from Photos (SDWebImagePhotosPlugin) or rich links (SDWebImageLinkPlugin).
    • 3rd Party Integrations: Lottie-iOS, SVGKit, and FLAnimatedImage.
  8. Configure Body Beauty parameters (v2.5.06+)

    master

    Body Beauty is independent of face beauty. It uses the pixelFreeSetBodyBeautyParam method.

    • Key: An integer PFBodyBeautyType ranging from 0 to 22.
    • Value: A float ranging from 0.0 to 1.0, where 0.5 is the neutral/default setting.

    Refer to the platform-specific documentation (api_android.md or api_iOS.md) for the full mapping of PFBodyBeautyType integers to specific body features.

  9. Understand the Client Health Check workflow

    master

    The client application interacts with the License API through a health check process to determine if a license update is required:

    1. Client App calls the Health Check API.
    2. API checks for configuration: If no configuration exists for the app_bundle_id, it returns 'Not Found'.
    3. API checks status: If the configuration exists but the status is not normal (e.g., expired/disabled), it returns the disabled state.
    4. API checks for updates: If the status is normal, the API determines if an update is needed. If an update is required, it returns a Download URL for the new license; otherwise, it returns a 'Normal' status.
  10. Supported image formats and Coder Plugins

    master

    SDWebImage supports standard Apple formats (JPEG, PNG, TIFF, BMP) and animated formats (GIF, APNG). For extended format support, it uses a Coder Plugin System.

    Built-in/System Support

    • JPEG, PNG, TIFF, BMP
    • GIF/APNG: Animated image support.
    • HEIC: Supported via system (iOS 11+) or SDWebImageHEICCoder/SDWebImageHEIFCoder plugins.
    • WebP: Supported via system (iOS 14+) or SDWebImageAWebPCoder/SDWebImageWebPCoder plugins.
    • JPEG-XL: Supported via system (iOS 17+) or SDWebImageJPEGXLCoder plugin.

    Important Note on Animated Formats

    By default (as of v5.19.x), SDWebImage only registers traditional animated formats like GIF/APNG. Modern animated formats like AWebP, HEIC, or AVIF are NOT registered by default even on newer firmware. To use them, you must manually register the appropriate coder plugin with one line of code.

  11. Modify, update, or remove constraints in Masonry

    master

    Masonry provides three primary ways to handle existing constraints when you need to animate, remove, or replace them:

    1. References: Store a reference to a specific constraint using the MASConstraint type. This allows you to call [constraint uninstall] later.
    2. mas_updateConstraints: Use this to update only the constant values (like offsets or multipliers) of existing constraints. This is the Apple-recommended approach within the updateConstraints method.
    3. mas_remakeConstraints: Use this to completely remove all existing constraints on a view and install a new set. This is useful when the layout logic changes significantly (e.g., switching from a top-left alignment to a bottom-right alignment) and you don't want to manage individual references.
    // 1. Using References
    @property (nonatomic, strong) MASConstraint *topConstraint;
    
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top);
    }];
    [self.topConstraint uninstall];
    
    // 2. Using mas_updateConstraints
    [self.growingButton mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(self.buttonSize.width));
    }];
    
    // 3. Using mas_remakeConstraints
    [self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.buttonSize);
    }];
  12. Apply makeup to specific facial parts

    master

    Makeup can be applied using either a .bundle (recommended for performance) or a JSON configuration file. Once loaded, you can adjust the intensity of specific makeup parts using pixelFreeSetMakeupPart:degree:.

    The degree value (0.0 - 1.0) is multiplied by the intensity defined in the configuration.

    Supported Makeup Parts:

    • PFMakeupPartBrow (Eyebrows)
    • PFMakeupPartBlusher (Blusher)
    • PFMakeupPartEyeShadow (Eye shadow)
    • PFMakeupPartEyeLiner (Eyeliner)
    • PFMakeupPartEyeLash (Eyelashes)
    • PFMakeupPartLip (Lipstick)
    • PFMakeupPartHighlight (Highlighter)
    • PFMakeupPartShadow (Contour/Shadow)
    • PFMakeupPartFoundation (Foundation)
    // Adjusting the intensity of lipstick
    [_mPixelFree pixelFreeSetMakeupPart:PFMakeupPartLip degree:0.8f];