We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I run this code in ios and I got image like this :
lipstick_filter_ = LipstickFilter::create(); blusher_filter_ = BlusherFilter::create(); beauty_face_filter_ = BeautyFaceFilter::create(); face_reshape_filter_ = FaceReshapeFilter::create(); NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"sample_face" ofType:@"png"]; gpuSourceImage = SourceImage::create([imagePath UTF8String]); gpuSourceImage->RegLandmarkCallback([=](std::vector<float> landmarks) { lipstick_filter_->SetFaceLandmarks(landmarks); blusher_filter_->SetFaceLandmarks(landmarks); face_reshape_filter_->SetFaceLandmarks(landmarks); }); // filter pipline gpuSourceImage->addTarget(lipstick_filter_) ->addTarget(blusher_filter_) ->addTarget(face_reshape_filter_) ->addTarget(beauty_face_filter_); float value = 8.0f; blusher_filter_->setBlendLevel(value/10); lipstick_filter_->setBlendLevel(value/10); face_reshape_filter_->setEyeZoomLevel(value/50); face_reshape_filter_->setFaceSlimLevel(value/100); beauty_face_filter_->setWhite(value/20); beauty_face_filter_->setBlurAlpha(value/10); gpuSourceImage->Render(); unsigned char* res = gpuSourceImage->captureAProcessedFrameData(beauty_face_filter_); int imageWidth = gpuSourceImage->getRotatedFramebufferWidth(); int imageHeight = gpuSourceImage->getRotatedFramebufferHeight(); // gpuSourceImage->getFramebuffer()->active(); // GPUPixelContext::getInstance()->capturedFrameData = // new unsigned char[imageWidth * imageHeight * 4]; // CHECK_GL(glReadPixels(0, 0, imageWidth, imageHeight, GL_RGBA, // GL_UNSIGNED_BYTE, // GPUPixelContext::getInstance()->capturedFrameData)); // gpuSourceImage->getFramebuffer()->inactive(); // // unsigned char* res = GPUPixelContext::getInstance()->capturedFrameData; // for (int i = 0; i < imageWidth*imageHeight*4; i += 4) { // // Swap the red and blue channels // unsigned char temp = res[i]; // R // res[i] = res[i + 2]; // B // res[i + 2] = temp; // Set original R to B // } // // make data provider with data. CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, res, imageWidth*imageHeight*4, NULL); // prep the ingredients int bitsPerComponent = 8; int bitsPerPixel = 32; int bytesPerRow = 4 * imageWidth; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; // make the cgimage CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); // then make the uiimage from that UIImage *image = [UIImage imageWithCGImage:imageRef]; // Save the UIImage as a PNG file in the document directory if (image) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths firstObject]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"saved_image3.png"]; NSData *pngData = UIImagePNGRepresentation(image); if ([pngData writeToFile:filePath atomically:YES]) { NSLog(@"Image saved successfully at %@", filePath); } else { NSLog(@"Failed to save image"); } // Cleanup CGImageRelease(imageRef); CGDataProviderRelease(provider); CGColorSpaceRelease(colorSpaceRef); delete res;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I run this code in ios and I got image like this :
The text was updated successfully, but these errors were encountered: