一款具有实时滤镜,美颜功能的相机。内置十几款滤镜,可实现拍照,录像功能。
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
<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) {
...
}
});
mCameraView.setOuputMP4File(your file);
private boolean mRecordingEnabled = false; // 录制状态
...
mRecordingEnabled = !mRecordingEnabled;
mCameraView.changeRecordingState(mRecordingEnabled);
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 | √ | √ | √ | √ |
https://github.com/google/grafika