• Stars
    star
    187
  • Rank 206,464 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📷 摄像头实时滤镜处理库,自带10多种滤镜,支持滤镜扩展,并且兼容七牛云直播滤镜处理

CameraFilters

Jcenter Build Status API License Author QQ-Group

摄像头实时滤镜处理库,自带10多种滤镜,支持滤镜扩展,并且兼容七牛云直播滤镜处理

Usage

Download

 implementation 'me.jessyan:camerafilters:1.0'

Declare permissions:

 <uses-permission android:name="android.permission.CAMERA"/>

Declare feature:

 <uses-feature 
        android:glEsVersion="0x00020000"
        android:required="true"/>

Step 1

 mFilterManager = FilterManager
                .builder() 
                .context(mApplicationContext)
                .isUseQiniu(false)//是否在qiniu云直播上使用滤镜
                .addExtFilterListener(new onExtFilterListener() {//添加扩展的滤镜,因为滤镜创建必须在render的回调中,所以统一在这里管理滤镜
                    @Override
                    public IFilter onCreateExtFilter(Context context, int index) {
                        switch (index) {
                            case 0://继承于cameraFitlter后可自定义filter,此Filter可任意添加一张图片到界面上
                                return new CameraFilterBlend(context, R.mipmap.
                                        pic_addpic);
                            default:
                                return new CameraFilter(context, false);
                        }
                    }
                })
                .defaultFilter(new FilterInfo(false, 0))//设置默认滤镜(false为使用内置滤镜,角标范围是0-13,0为透明滤镜)
                .build();

Step 2

  • GLSurfaceView.Renderer的三个回调方法中,将参数传给FilterManager对应的方法.
  • onSurfaceCreated ---> FilterManager.initialize();
  • onSurfaceChanged ---> FilterManager.updateSurfaceSize(width, height);
  • onDrawFrame ---> mFilterManager.drawFrame(mTextureId, mSTMatrix, mIncomingWidth, mIncomingHeight);
  • 以上为GLSurfaceView.Renderer 回调和FilterManager方法的对应关系(请参照Demo)
  • 最后在结束时记得调用mFilterManager.release()释放资源

Step 3 ( if you use qiniu see here )

 mCameraStreamingManager.setSurfaceTextureCallback(new SurfaceTextureCallback() {
            @Override
            public void onSurfaceCreated() {
               mFilterManager.initialize();
            }

            @Override
            public void onSurfaceChanged(int i, int i1) {
               mFilterManager.updateSurfaceSize(i, i1);
            }

            @Override
            public void onSurfaceDestroyed() {
                mFilterManager.release();
            }

            @Override
            public int onDrawFrame(int i, int i1, int i2, float[] floats) {
               return mFilterManager.drawFrame(var1, null, var2, var3);
            }
        });
  • 在七牛直播上使用滤镜也非常简单,和第二步相似,记得FilterManager.isUseQiniu(true) & mFilterManager.drawFrame(var1, null, var2, var3);第二个参数一定要传null,七牛视频编码必须为硬编码

FilterInfo structure

使用默认滤镜和切换滤镜需要传入FilterInfo对象

Field Description
isExt 是否使用扩展的滤镜
index     滤镜在对应滤镜列表中的角标,如果isExt为false,则使用内置滤镜列表,为true则对应扩展滤镜列表

Dev tips

具体用法参照Demo,有Opengl基础的可以自定义滤镜

About Me

License

 Copyright 2016, jessyan          
  
   Licensed under the Apache License, Version 2.0 (the "License");  
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

More Repositories

1

AndroidAutoSize

🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).
Java
13,018
star
2

MVPArms

⚔️ A common architecture for Android applications developing based on MVP, integrates many open source projects, to make your developing quicker and easier (一个整合了大量主流开源项目高度可配置化的 Android MVP 快速集成框架).
Java
10,269
star
3

ProgressManager

⏳ Listen the progress of downloading and uploading in Okhttp, compatible Retrofit and Glide (一行代码即可监听 App 中所有网络链接的上传以及下载进度, 包括 Glide 的图片加载进度).
Java
2,612
star
4

RetrofitUrlManager

🔮 Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).
Java
2,114
star
5

ArmsComponent

📦 A complete android componentization solution, powered by MVPArms (MVPArms 官方快速组件化方案).
Java
1,691
star
6

MVPArt

🎨 A new Android MVP architecture (此框架旨在解决传统 MVP 类和接口太多, 并且 Presenter 和 View 通过接口通信过于繁琐, 重用 Presenter 代价太大等问题).
Java
782
star
7

InsGallery

📸 Instagram-like image picker for Android (一款 UI 炫酷高仿 Instagram 的图片、视频选择器)
Java
636
star
8

ArmsComponent-Template

🛠️ 一键搭建 ArmsComponent 快速组件化方案的整体组件架构, 让新手也可以一秒开始组件化项目, 开发神器, 让您一秒起飞, 体验纯傻瓜式的组件化开发, 避免组件化从入门到放弃!
FreeMarker
345
star
9

MVPArms-Module-Template

🛠 一键搭建 MVPArms 的官方架构, 让新手一秒即可开启 MVPArms 的世界, 免于项目繁琐配置的烦恼
FreeMarker
244
star
10

LifecycleModel

📬 The LifecycleModel class is designed to store and manage UI-related data in a lifecycle conscious way, the LifecycleModel class allows data to survive configuration changes such as screen rotations, it also handles the communication of the Activity / Fragment with the rest of the application, base on https://developer.android.google.cn/topic/libraries/architecture/viewmodel.html
Java
229
star
11

RxErrorHandler

🗑 Error Handle Of Rxjava
Java
164
star
12

MobileSafe

🛡 下载过三万并且非常适合初学者学习的一个项目(没错就是黑马手机卫士)
Java
159
star
13

WideEyes

👁️ 源于{开眼视频},架构使用Mvp+Dagger2+Retrofit+Rxjava的一款内外兼得的学习项目
Java
70
star
14

AudioManagerSDK

智播项目(应用场景)专门用于处理录音逻辑的SDK
Java
56
star
15

RaiseManagerSDK

智播项目,教育类应用场景之举手发言
12
star
16

JessYanCoding

3
star