Code Monkey home page Code Monkey logo

cameraview-3's Introduction

CameraView

An Android CameraView

###使用方法:

引入:

compile 'cn.bertsir.Cameralibary:cameralibary:2.0.0'

布局:

    <cn.bertsir.cameralibary.CameraView
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:direction="BACK"
        ></cn.bertsir.cameralibary.CameraView>

代码:

 cv = (CameraView) findViewById(R.id.cv);
 cv.open(MainActivity.this);

OK,就这么简单,一个摄像头View就创建好了

支持的功能:

/**
 * 关闭相机
 * @param mActivity
 */
public void close(Activity mActivity)

/**
 * 切换摄像头(相反切换)
 */
public void ChangeCamera()

/**
 * 切换摄像头(指定切换)
 */
public void ChangeCamera(int direction)
/**
 * 拍照
 * @param mTakeSuccess
 * @return
 */
public Bitmap takePhoto(CameraHelper.takeSuccess mTakeSuccess)

/**
 * 拍照并添加水印
 * @param waterMask
 * @param paddingLeft
 * @param paddingTop
 * @return
 */
public void takePhotoAddWaterMask(final Bitmap waterMask, final int paddingLeft, final int paddingTop,
                                  final WaterImageListener mWaterImageListener
  /**
 * 判断当前相机是否是前置摄像头
 * @return
 */
public Boolean currentCameraIsFront()

2017.11.29 更新

新增摄像头高斯模糊功能

布局新增:

<cn.bertsir.cameralibary.view.BlurPreviewView
     android:id="@+id/bpv"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
</cn.bertsir.cameralibary.view.CameraView>

代码:

			CameraBlurUtils.getInstance().init(this);//初始化高斯模糊工具
            cv.setPreviewFrameListener(new PreviewFrameListener() {
                @Override
                public void onPreviewFrameListener(byte[] data, Camera camera) {
                    bpv.setBlurFrame(CameraBlurUtils.getInstance().blur(data,camera,15f));
                }
            });

项目build.gradle中新增

defaultConfig {
    .......

    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true
}

具体使用方法参考Demo

2018.02.08 更新

优化了摄像头高斯模糊的卡顿,如丝般顺滑

cameraview-3's People

Contributors

bertsir 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.