Giter Club home page Giter Club logo

opencamera-for-android's Introduction

OpenCamera

一款具有实时滤镜,美颜功能的相机。内置十几款滤镜,可实现拍照,录像功能。

效果图

实时滤镜 生成mp4

功能

1.实时滤镜

2.拍照

3.录像

目前仅仅实现以上的基本功能,后期还会维护,添加美颜,水印,特效等功能

使用

集成项目

allprojects {
    repositories {
        ...
        maven { url 'https://www.jitpack.io' }
    }
}

dependencies 
        {
	  implementation 'com.github.moo611:OpenCamera:1.0.3'
	}
//注意添加java8支持!!!
android{
...
 compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}
	

添加权限

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

xml布局文件

 <com.atech.glcamera.views.GLCameraView
        app:layout_constraintTop_toTopOf="parent"
        android:id="@+id/glcamera"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

添加滤镜

private List<FilterFactory.FilterType>filters = new ArrayList<>();
  ...
  filters.add(FilterFactory.FilterType.Original);
  filters.add(FilterFactory.FilterType.Sunrise);
  filters.add(FilterFactory.FilterType.Sunset);
  filters.add(FilterFactory.FilterType.BlackWhite);
  filters.add(FilterFactory.FilterType.WhiteCat);
  filters.add(FilterFactory.FilterType.BlackCat);
  filters.add(FilterFactory.FilterType.SkinWhiten);

切换滤镜

 mCameraView.updateFilter(filters.get(pos));

切换镜头

 mCameraView.switchCamera();

拍照

 mCameraView.takePicture(new FilteredBitmapCallback() {
            @Override
            public void onData(Bitmap bitmap) {
                 ...
            }
        });

设置输出mp4文件

 mCameraView.setOuputMP4File(your file);

录制视频

 private boolean mRecordingEnabled = false;  // 录制状态
   ...
       mRecordingEnabled = !mRecordingEnabled;
       mCameraView.changeRecordingState(mRecordingEnabled);

设置mp4录制完成回调

 mCameraView.setrecordFinishedListnener(new FileCallback() {
            @Override
            public void onData(File file) {

                //update the gallery
                sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                        Uri.fromFile(file)));

            }
        });

项目比较

多种滤镜 拍照 录制视频 是否维护
grafika X X X
gpuimage X X
magiccamera X X X
opencamera

首先向前辈们表示尊敬和感谢!项目借鉴了很多前辈们的作品。如果您喜欢我的项目,请给我点个赞,谢谢。

google/grafika

https://github.com/google/grafika

android gpuimage

https://github.com/cats-oss/android-gpuimage

magic camera

https://github.com/wuhaoyu1990/MagicCamera

opencamera-for-android's People

Contributors

moo611 avatar

Watchers

James Cloos avatar

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.