Giter Site home page Giter Site logo

wuhaoyu1990 / magiccamera Goto Github PK

View Code? Open in Web Editor NEW
5.4K 222.0 1.6K 17.07 MB

Real-time Filter Camera&VideoRecorder And ImageEditor With Face Beauty For Android---包含美颜等40余种实时滤镜相机,可拍照、录像、图片修改

Makefile 0.04% C++ 3.42% GLSL 19.81% Java 76.72%

magiccamera's Issues

Record audio

How I can also record audio when a video is generate?

录制视频问题

你好,使用这个库录制完视频发现视频不能播放或者没有声音

how to switch to front camera?

Hi you, thanks for you share. I love this very much.
happying when enjoy it, but I cant open front camera, can you show me?
Thanks

把工程导入到Eclipse,运行点击imageView是崩溃

08-05 16:04:48.648: E/AndroidRuntime(11308): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.seu.magiccamera-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]] couldn't find "libMagicSDK.so"

Image Editor For Android Studio

This project is still under coding and will be updated later,only used eclipse because my computer too poor to run AS T-T

My Question :
ImageEditor doesn't work in android studio right now ?

Camera rotation issue in Android Studio Project

Fix these 2 bugs:-
1: When I open camera rear camera opens -> switch to front camera -> go back -> again open camera
now camera preview is rotated from left to right.
2: In Nexus 5 rear camera is rotated to down side.

app crash on Galaxy s3

just try running this app on s3 and it crash but work fine on s4 with 5.0.1. i was figuring out the problem but not successful with that i think so GLES20 make it crash. anyway please try to figure out the problem please thanks!

美颜滤镜背景如何不变得亮白

最低水平的美颜效果都会导致背景也明显亮白,如果是正常和美颜切换时,背景不要那么明显的变化呢,人脸变化就可以了

bug:

Hi,
Error:Error: This fragment should provide a default constructor (a public constructor with no arguments) (com.seu.magiccamera.view.edit.adjust.ImageEditAdjustView) [ValidFragment]?

两个滤镜黑屏出错

在用 美肤 和 美白 这两个滤镜的时候,一只黑屏,下面着两行log重复打印
01-27 18:03:20.934 13044-13122/com.seu.magiccamera W/Adreno-ES20: <core_glVertexAttribPointer:533>: GL_INVALID_VALUE
01-27 18:03:20.967 13044-13122/com.seu.magiccamera W/GLConsumer: [unnamed-13044-0] bindTextureImage: clearing GL error: 0x501
求解决。

关于MagicBeautyFilter中一行代码的问题^_^

我在准备一直iOS的过程中查看MagicBeautyFilter的代码发现在setBeautyLevel 函数中有一句
case 2:
setFloatVec3(mParamsLocation, new float[] {0.8f, 0.9f, 0.2f, 0.2f});
但是在后面的float 数组中给的是四个值。这里是否有错误?因为Vec3 应该只接受三个值吧

ImageView

eclipse版本 ImageView 模块无法启动

前置摄像头相关问题

你好,这个AndroidStudio 版demo中默认打开的是后置摄像头。
如果改为打开前置摄像头(CameraEngine中的cameraID=1;),默认对着人脸,则保存的录像文件图像是倒着的? 这个怎么解决?

shader 有个地方看不懂,望指教!

MagicCamera\Project_eclipse_old\MagicFilter\res\raw\beautify_fragment_low.glsl

vec2 * vec2 结果是?
一般看到的高斯滤镜 是水平,垂直2次滤镜操作的。
你这个一次完成。
singleStepOffset = vec2(0.1, 0.1);
singleStepOffset * vec2(5.0, -8.0) = vec2(0.5, -0.8) 还是其他?

我感觉预期应该是 vec2(0.5, -0.8)吧,但是感觉这个 * 既不是 点乘 又不是 叉乘。看不太懂。

...
uniform vec2 singleStepOffset;
...
void main(){
vec2 blurCoordinates[12];

blurCoordinates[0] = textureCoordinate.xy + singleStepOffset * vec2(5.0, -8.0);

...

请问磨皮效果怎样设置?

在项目演示图片中看到有调节磨皮和美白的效果,但是在下载的demo中没有此操作,代码中也没发现此效果的API,请问我应该在什么地方设置和调节磨皮效果吗?

摘出美颜部分

您好,如果我想摘出美颜功能中gl滤镜部分,是不是从MagicBeautyFilter.java和beautify_fragment.glsl两个文件中找就可以了呢

Error when I run the project and click on "ImageView"

I get this error when I run the project and click on "ImageView"
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.seu.magiccamera-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libMagicSDK.so"

OPENGL与图像数据如何绑定?

你好,我看了一下你的源码,只是知道了滤镜功能是通过openGL实现的,openGL是如何与数据源绑定的?能修改YUV数据吗?

MagicCamera做手机直播

作者你好!我将你的MagicCamera用在手机直播推流端并开源了Yasea项目,您可以用Android Studio跑一个demo试试。当初主要看中了美颜磨皮部分,我尝试用摄像头实时磨皮。将magicfilter目录剥离出来,将MagicBeautyFilter作为滤镜放到CameraInputFilter里,shader使用beauty.glsl文件,实测效果还不错,摄像头预览并不卡。

但原beauty.glsl里对整个图像进行磨皮处理,使得帧率下降比较多,有一种优化方式是只对皮肤进行处理,样板如下:

varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2;
varying highp vec2 textureCoordinate3;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
uniform mediump float smoothDegree;

void main() {
    highp vec4 bilateral = texture2D(inputImageTexture, textureCoordinate);
    highp vec4 canny = texture2D(inputImageTexture2, textureCoordinate2);
    highp vec4 origin = texture2D(inputImageTexture3,textureCoordinate3);
    highp vec4 smooth;
    lowp float r = origin.r;
    lowp float g = origin.g;
    lowp float b = origin.b;
    if (canny.r < 0.2 && r > 0.3725 && g > 0.1568 && b > 0.0784 && r > b && (max(max(r, g), b) - min(min(r, g), b)) > 0.0588 && abs(r-g) > 0.0588) {
        smooth = (1.0 - smoothDegree) * (origin - bilateral) + bilateral;
    } else {
        smooth = origin;
    }
    smooth.r = log(1.0 + 0.2 * smooth.r)/log(1.2);
    smooth.g = log(1.0 + 0.2 * smooth.g)/log(1.2);
    smooth.b = log(1.0 + 0.2 * smooth.b)/log(1.2);
    gl_FragColor = smooth;
}

可惜我对glsl编程不了解,无法将改进的shader移植到MagicCamera,能否帮忙对beauty.glsl改进一下呢?谢谢!

black photos

Photos captured from Magic Camera are completely black after using filters .

Tested on sony xperia D6503 android 6.0.1

onPreviewFrame data + OpenCV 实时处理的问题

你好,我也在相同的东西,除了实时滤镜之外,我还需要用OpenCV 做一些 识别算法,然后再实时GL 渲染。
所以不能用 Shader 直接进行 YUV2RGB的操作。 // 这里我不知道行不行,刚刚接触GL?

目前采用的是 JNI中进行 YUV2RGB 操作,然后进行 内容识别,GLSurfaceView中进行渲染,根据返回的识别的物体 坐标点 实时 进行贴图。 // 这样是否有效率问题?

在进行实时贴图时,与实际坐标有很大偏差,不知道你是否有类似的经验。

Thanks.

Image视图下,如果应用了MagicImageAdjustFilter,在调用MagicDisplay的getBitmapFromGL()后,得到的图片异常

异常表现:
1.小米机型得到的图片--显示字体"完成"镜像
2.其他手机输出的图片为:像素大小为原图大小, 但是有图的区域为GLSurfaceView显示的区域,其余区域为黑色.


请教一下大神,
1.为什么保存图片不直接获取当前GLSurfaceView显示的图片,而是对原图重新绘制?
2.我没有找到获取GLSurfaceView当前显示图片的方法,我用getDrawingCache()方法获取到的是黑色,没有图片,该如何获取呢?

谢谢大神了!

beautify_fragment.glsl文件放到推流库使用时黑屏

你好,无意间发现MagicCamera库,运行了一下,感觉效果非常好。
正好项目中需要用到滤镜,发现美颜滤镜比七牛推流库Android版中的美颜效果要好,尤其是磨皮效果明显,肤质显得更加细腻。
我将beautify_fragment.glsl放入七牛推流库,copy CameraFilterBeauty修改了一个类,无其他修改。

只是修改了这里(将fragment_shader_beauty 替换为 beautify_fragment ;R.raw.vertex_shader 改为 -1。
在GlUtil.createProgram()函数中判断值为 -1 时将对应变量替换为你库中NO_FILTER_VERTEX_SHADER 对应的字符串)

@OverRide protected int createProgram(Context applicationContext) {
return GlUtil.createProgram(applicationContext, -1, R.raw.beautify_fragment);
}

我先将vec4 params直接在.glsl文件中赋值vec4 params = vec4(0.33, 0.63, 0.4, 0.35); 后来经过比对发现,七牛的fragment_shader_beauty.glsl文件除了uniform samplerExternalOES uTexture 与 sampler2D inputImageTexture类型不一致以外,其他都是一样。

但是本人glsl小白一枚,完全不知道该怎么修改。如果有空的话,还请大牛帮忙指导一下,万分感谢!
ps:附上推流库android版地址 https://github.com/pili-engineering/PLDroidCameraStreaming

androidstudio 6.0手机启动出现的异常

Process: com.seu.magiccamera, PID: 3023 Theme: themes:{default=overlay:com.h2os.youlun, iconPack:com.h2os.youlun, fontPkg:com.h2os.youlun, com.android.systemui=overlay:com.h2os.youlun, com.android.systemui.navbar=overlay:com.h2os.youlun} java.lang.RuntimeException: Unable to resume activity {com.seu.magiccamera/com.seu.magiccamera.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3137) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3168) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2515) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5456) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference at com.seu.magicfilter.camera.CameraEngine.getPreviewSize(CameraEngine.java:72) at com.seu.magicfilter.camera.CameraEngine.getCameraInfo(CameraEngine.java:111) at com.seu.magicfilter.widget.MagicCameraView.openCamera(MagicCameraView.java:154) at com.seu.magicfilter.widget.MagicCameraView.onResume(MagicCameraView.java:187) at com.seu.magicfilter.MagicEngine.onResume(MagicEngine.java:32) at com.seu.magiccamera.MainActivity.onResume(MainActivity.java:84) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1259) at android.app.Activity.performResume(Activity.java:6327) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3168)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2515)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5456) 

将shader脚本移到ios里面黑屏

我将cool.glsl里面的算法copy到iOS里面,预览黑屏。能麻烦看看是什么问题吗?我已有的灰度算法是正常的。
const char * const
GlowVideoFilter::pixelKernel() const
{
KERNEL(GL_ES2_3, m_language,
varying highp vec2 textureCoordinate;
precision highp float;

uniform sampler2D inputImageTexture;
uniform sampler2D curve;

void main()
{
lowp vec4 textureColor;
lowp vec4 textureColorOri;

float xCoordinate = textureCoordinate.x;
float yCoordinate = textureCoordinate.y;

highp float redCurveValue;
highp float greenCurveValue;
highp float blueCurveValue;

textureColor = texture2D( inputImageTexture, vec2(xCoordinate, yCoordinate));
textureColorOri = textureColor;
// step1 curve 
redCurveValue = texture2D(curve, vec2(textureColor.r, 0.0)).r;
greenCurveValue = texture2D(curve, vec2(textureColor.g, 0.0)).g;
blueCurveValue = texture2D(curve, vec2(textureColor.b, 0.0)).b;
// step2 level
redCurveValue = texture2D(curve, vec2(redCurveValue, 0.0)).a;
greenCurveValue = texture2D(curve, vec2(greenCurveValue, 0.0)).a;
blueCurveValue = texture2D(curve, vec2(blueCurveValue, 0.0)).a;
// step3 brightness/constrast adjust 
redCurveValue = redCurveValue * 1.25 - 0.12549;
greenCurveValue = greenCurveValue * 1.25 - 0.12549; 
blueCurveValue = blueCurveValue * 1.25 - 0.12549;
//redCurveValue = (((redCurveValue) > (1.0)) ? (1.0) : (((redCurveValue) < (0.0)) ? (0.0) : (redCurveValue)));
//greenCurveValue = (((greenCurveValue) > (1.0)) ? (1.0) : (((greenCurveValue) < (0.0)) ? (0.0) : (greenCurveValue)));
//blueCurveValue = (((blueCurveValue) > (1.0)) ? (1.0) : (((blueCurveValue) < (0.0)) ? (0.0) : (blueCurveValue)));
// step4 normal blending with original
textureColor = vec4(redCurveValue, greenCurveValue, blueCurveValue, 1.0);
textureColor = (textureColorOri - textureColor) * 0.549 + textureColor;

gl_FragColor = vec4(textureColor.r, textureColor.g, textureColor.b, 1.0);

}
)
return nullptr;
}

已有的灰度滤镜:
const char * const
GrayscaleVideoFilter::pixelKernel() const
{

     KERNEL(GL_ES2_3, m_language,
           precision mediump float;
           varying vec2      vCoord;
           uniform sampler2D uTex0;
           void main(void) {
               vec4 color = texture2D(uTex0, vCoord);
               float gray = dot(color.rgb, vec3(0.3, 0.59, 0.11));
               gl_FragColor = vec4(gray, gray, gray, color.a);
           }
    )

    return nullptr;
}

滤镜、编辑功能对图片修改后 返回键进行应用时会导致内存溢出

滤镜、编辑功能对图片修改后 返回键进行应用时会导致内存溢出,
错误信息为:
java.lang.OutOfMemoryError: Failed to allocate a 25958412 byte allocation with 4194304 free bytes and 11MB until OOM
at com.seu.magicfilter.display.MagicDisplay$2.run(MagicDisplay.java:175)
找到对应的行 为:MagicDisplay.java
Bitmap mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
该怎么解决这个问题呀,求解,正在运用你学的项目到我的项目中

编辑功能无法正常使用

在修改图片的透明度,或是饱和度等,返回时提示是否保存,点击保存,然后得不到修改后的图片,反而是得到一张无用的图片。希望大神指点迷津。感谢万分

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.