Welcome to join us to make GPUPixel better by participating discussions, opening issues, submitting PRs.
📢 The face landmark detection has replaced Face++ with VNN starting from v1.2.0; no more Face++ network verification requirements are needed 👏
⛰️ GPUPixel is a real-time, high-performance image and video filter library, extremely easy to compile and integrate with small library size.
🔑 GPUPixel is written in C++11 and is based on OpenGL/ES, incorporating a built-in beauty face filter that achieves commercial-grade beauty effects.
🔌 GPUPixel supports platforms including iOS
, Android
, Mac
, Win
and Linux
. It can theoretically be ported to any platform that supports OpenGL/ES.
Origin | Smooth | White | ThinFace |
---|---|---|---|
BigEye | Lipstick | Blusher | ON-OFF |
This table compares the features supported by GPUPixel and GPUImage and Android-GPUImage:
✅: Supported | ❌: Not supported | ✏️: Planning
GPUPixel | GPUImage | Android-GPUImage | |
---|---|---|---|
📷 Filters: | ✅ | ❌ | ❌ |
Skin Smoothing Filter | ✅ | ❌ | ❌ |
Skin Whitening Filter | ✅ | ❌ | ❌ |
Face Slimming Filter | ✅ | ❌ | ❌ |
Big Eyes Filter | ✅ | ❌ | ❌ |
Lipstick Filter | ✅ | ❌ | ❌ |
Blush Filter | ✅ | ❌ | ❌ |
More Build in Filter | ✅ | ✅ | ✅ |
🎬 Input Formats: | |||
YUV420P(I420) | ✅ | ❌ | ❌ |
RGBA | ✅ | ✅ | ✅ |
JPEG | ✅ | ✅ | ✅ |
PNG | ✅ | ✅ | ✅ |
NV21(for Android) | ✏️ | ❌ | ❌ |
🎥 Output Formats: | |||
RGBA | ✅ | ✅ | ✅ |
YUV420P(I420) | ✏️ | ❌ | ❌ |
💻 Platform: | |||
iOS | ✅ | ✅ | ❌ |
Mac | ✅ | ✅ | ❌ |
Android | ✅ | ❌ | ✅ |
Win | ✅ | ❌ | ❌ |
Linux | ✅ | ❌ | ❌ |
- | iPhone 6P | iPhone 8 | iPhone X | iPhone 11 | iPhone 14 pro |
---|---|---|---|---|---|
CPU | 5% | 5% | 3% | 3% | 3% |
Time Taken | 10ms | 4ms | 3ms | 3ms | 3ms |
- | Xiaomi 10 | Huawei Mate30 | Vivo | SAMSUNG | Google Pixel |
---|---|---|---|---|---|
CPU | 3% | 5% | - | - | - |
Time Taken | 6ms | 5ms | - | - | - |
iOS(.framework) | MacOS(.framework) | Android(.aar) | |
---|---|---|---|
Size | 2.4 MB | 2.6 MB | 2.1 MB |
⭐️ Star us on GitHub, and be instantly notified for new releases!
Compile using CMake frome v1.1.0. Please search for instructions on how to install and configure CMake.
The generated libraries and app will be located in the "output" directory of the project's root folder.
cd src
mkdir build
cd build
# Generate project
## for iOS arm64
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../toolchain/ios.toolchain.cmake -DPLATFORM=OS64 ..
# Build
cmake --build . --config Debug
cd src
mkdir build
cd build
# Generate project
## for Mac Apple Silicon
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../toolchain/ios.toolchain.cmake -DPLATFORM=MAC_ARM64 ..
## for Mac Intel
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=../../toolchain/ios.toolchain.cmake -DPLATFORM=MAC ..
# Build
cmake --build . --config Debug
Open the directory src/android/java
in Android Studio.
You need install and config Cmake and MinGW64 by yourself.
cd src
mkdir build
cd build
# Generate project
cmake -G "MinGW Makefiles" ..
# Build
mingw32-make
# install cmake
sudo apt-get install cmake pkg-config
# install dependent lib
sudo apt-get install mesa-utils libglu1-mesa-dev freeglut3-dev mesa-common-dev libglfw3-dev
# start build
cd src
mkdir build
cd build
# Generate project
cmake ..
# Build
make
Refer to examples/ios
and examples/mac
Refer to examples/android
or src/android/java
Refer to examples/desktop
. The compilation method is the same as compiling the library.
cd examples
mkdir build
cd build
# Generate project
cmake -G "MinGW Makefiles" ..
# Build
mingw32-make
A S D F G H - Increase smooth, white, thin face, big eye, lipstick, blusher level
Z X C V B N - Decrease smooth, white, thin face, big eye, lipstick, blusher level
Declear filters
// video data input
std::shared_ptr<SourceRawDataInput> source_raw_input_;
// beauty filter
std::shared_ptr<BeautyFaceFilter> beauty_face_filter_;
// video data output
std::shared_ptr<TargetRawDataOutput> target_raw_output_;
Create and link filters
gpupixel::GPUPixelContext::getInstance()->runSync([&] {
// Create filter
source_raw_input_ = SourceRawDataInput::create();
target_raw_output_ = TargetRawDataOutput::create();
// Face Beauty Filter
beauty_face_filter_ = BeautyFaceFilter::create();
// Add filter
source_raw_input_->addTarget(beauty_face_filter_)
->addTarget(target_raw_output_);
}
Input YUV420P or RGBA
// ...
// YUVI420
source_raw_input_->uploadBytes(width,
height,
bufferY,
strideY,
bufferU,
strideU,
bufferV,
strideV);
// ...
// bytes: RGBA data
source_raw_input_->uploadBytes(bytes,
width,
height,
stride);
Output Data Callback
// I420 callback
target_raw_output_->setI420Callbck([=](const uint8_t *data,
int width,
int height,
int64_t ts) {
size_t y_size = width * height;
const uint8_t *uData = data + y_size;
const uint8_t *vData = data + y_size + y_size / 4;
// Do something you want
});
// RGBA callback->
target_raw_output_->setPixelsCallbck([=](const uint8_t *data,
int width,
int height,
int64_t ts) {
size_t rgba_size = width * height*4;
// Do something you want
});
// Output data callbck
Welcome to contribute code 👏🏻.
At the same time, please consider supporting GPUPixel by sharing it on social media and at events and conferences.
This repository is available under the MIT License.