All Projects → FrangSierra → RxCamera2

FrangSierra / RxCamera2

Licence: other
Rx Java 2 wrapper for Camera2 google API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RxCamera2

Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (+1785.19%)
Mutual labels:  wrapper, rxjava, rxjava2
Cameraview
📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
Stars: ✭ 4,137 (+15222.22%)
Mutual labels:  camera, camera-api, camera2-api
Custom-Software-For-Xiaomi-Dafang
API and panel site for Xiaomi Dafang
Stars: ✭ 36 (+33.33%)
Mutual labels:  camera, camera-api
Rxpaparazzo
RxJava extension for Android to take images using camera and gallery and pick files up
Stars: ✭ 467 (+1629.63%)
Mutual labels:  camera, rxjava
Camerakit Android
Library for Android Camera 1 and 2 APIs. Massively increase stability and reliability of photo and video capture on all Android devices.
Stars: ✭ 5,131 (+18903.7%)
Mutual labels:  camera, camera-api
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+744.44%)
Mutual labels:  rxjava, rxjava2
Android Mvvm Architecture
This repository contains a detailed sample app that implements MVVM architecture using Dagger2, Room, RxJava2, FastAndroidNetworking and PlaceholderView
Stars: ✭ 2,720 (+9974.07%)
Mutual labels:  rxjava, rxjava2
Rxble
使用 RxJava 封装的低功耗蓝牙类库
Stars: ✭ 203 (+651.85%)
Mutual labels:  rxjava, rxjava2
CameraXDemo
CameraXDemo - Demonstrate CameraX APIs like Preview, Capture and Analysis.
Stars: ✭ 17 (-37.04%)
Mutual labels:  camera, camera2-api
iMoney
iMoney 金融项目
Stars: ✭ 55 (+103.7%)
Mutual labels:  rxjava, rxjava2
RxHttp
基于RxJava2+Retrofit+OkHttp4.x封装的网络请求类库,亮点多多,完美兼容MVVM(ViewModel,LiveData),天生支持网络请求和生命周期绑定,天生支持多BaseUrl,支持文件上传下载进度监听,支持断点下载,支持Glide和网络请求公用一个OkHttpClient⭐⭐⭐
Stars: ✭ 25 (-7.41%)
Mutual labels:  rxjava, rxjava2
Reactivenetwork
Android library listening network connection state and Internet connectivity with RxJava Observables
Stars: ✭ 2,484 (+9100%)
Mutual labels:  rxjava, rxjava2
Rxfit
🏃Reactive Fitness API Library for Android and RxJava
Stars: ✭ 218 (+707.41%)
Mutual labels:  rxjava, rxjava2
Kpermissions
A Kotlin library which helps to request runtime permissions in Android.
Stars: ✭ 253 (+837.04%)
Mutual labels:  rxjava, rxjava2
Rxjava3 Android Examples
RxJava 3 Android Examples - Migration From RxJava 2 to RxJava 3 - How to use RxJava 3 in Android
Stars: ✭ 213 (+688.89%)
Mutual labels:  rxjava, rxjava2
ReactiveConnectivity
ReactiveConnectivity - a library for Listen Connectivity Change on Android
Stars: ✭ 22 (-18.52%)
Mutual labels:  rxjava, rxjava2
Androidbasemvp
🚀一个快速搭建MVP+RxJava2+Retrofit 基础框架,主要是封装有Http网络请求、日志、缓存、加载等待、toast、页面状态布局管理、权限、RxBus、Glide图片加载等组件,方便快速开发新项目、减少开发成本。
Stars: ✭ 184 (+581.48%)
Mutual labels:  rxjava, rxjava2
Reactivewifi
Android library listening available WiFi Access Points and related information with RxJava Observables
Stars: ✭ 186 (+588.89%)
Mutual labels:  rxjava, rxjava2
MJMediaPicker
A Custom Class to select media from camera ,video or photo library by just adding a single file
Stars: ✭ 15 (-44.44%)
Mutual labels:  camera, capture-photo
RxAnimator
An RxJava2 binding for android Animator
Stars: ✭ 80 (+196.3%)
Mutual labels:  rxjava, rxjava2

RxCamera2

Rxjava 2.0 wrapper for Camera2 google API. Based android.hardware.camera2

Download

Gradle:
dependencies {
     compile 'com.github.FrangSierra:RxCamera2:0.5'
}
allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Basic Usage

First of all you will need a RxCameraManager item to start to work. You can get it in the next way:

 this.cameraManager = new RxCameraManager((CameraManager) app.getSystemService(Context.CAMERA_SERVICE));

You will need to do is open your camera for that you will need to call the method openCamera from RxCameraManager:

cameraManager.openCamera(selectedCameraId,backgroundHandler)
                     .doOnTerminate(releaseCamera())
                     .subscribe(openCameraEvent -> {
                         switch (openCameraEvent.eventType){
                             case OPENED:
                             /** Manage your OpenCameraEvent which contains a CameraDevice object 
                              *  and a TAG to check if the event as been suscessful
                              */
                                 this.deviceManager = openCameraEvent.cameraDevice;
                                 break;
                             case DISCONNECTED:
                                 Log.d(TAG, "Camera disconnected: %s", openCameraEvent.cameraDevice.getCameraDevice().getId());
                                 break;
                             case ERROR:
                                 break;
                         }
                     });

Creating a Session

To create a Session you first need to generate a CaptureRequest to add the target of your preview Surface, and all the different surfaces that you will use during the lyfecicle of the current session.

 cameraState.cameraDevice
 .createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
 .subscribe(builder -> this.builder = builder);

After that, you can create your CaptureSession :

cameraState.cameraDevice
.createCaptureSession(Collections.singletonList(cameraState.previewSurface), builder, backgroundHandler)
.susbscribe(configureSessionEvent -> {
 RxConfigureSessionEvent rxConfigureSessionEvent = configureSessionEvent;
 switch (rxConfigureSessionEvent.eventType) {
                     case CONFIGURE:
                        try {
                           rxConfigureSessionEvent.session.getCaptureSession().getInputSurface();
                           //This call is irrelevant,
                           //however session might have closed and this will throw an IllegalStateException.
                           //This happens if another camera app (or this one in another PID) takes control
                           //of the camera while its opening
                        } catch (IllegalStateException e) {
                           Log.e("Another process took control of the camera while creating the session, aborting!");
                        }
                        this.rxCameraCaptureSession = rxConfigureSessionEvent.session;
                        rxConfigureSessionEvent.session.setRepeatingRequest(builder.build(), backgroundHandler).subscribe();
                        break;
 
                     case CONFIGURE_FAILED:
                         Log.e("On configure failed");
                        break;
                  }
                  //Now we are opening                 
               });

Capturing photos

Finally you can start to capturing photos using the different methods of your current RxCameraCaptureSession object. Let's see an example using the capture method:

capture(captureRequest,handler)
.subscribe(captureCallbackEvent -> {
           switch (captureCallbackEvent.eventType){
               case STARTED:
                   //Your capture as started, do what you want with your session,
                   // captureRequest, timestamp and frameNumber values.
                   break;
               case PROGRESSED:
                   //Your capture is in progress, check some conditions with your session,
                   // captureRequest,  or the different values from your partialResult.
                   break;
               case COMPLETED:
                   //Your capture as been completed. You will recieve the session, the used
                   // captureRequest and the exact CaptureResult values from your picture.
                   break;
               case FAILED:
                   //Your capture as failed, manage your error.
                   break;
               case SEQUENCE_COMPLETED:
                  // This method is called independently of the others in CaptureCallback,
                   // when a capture sequence finishes and all CaptureResult or
                   // CaptureFailure for it have been returned via this listener.
                   break;
               case SEQUENCE_ABORTED:
                   //This is called independently of the others in CaptureCallback,
                   // when a capture sequence aborts before any CaptureResult or
                   // CaptureFailure for it have been returned via this listener.
                   break;
               case BUFFER_LOST:
                   //API24 
                   //This method is called if a single buffer for a capture could
                   // not be sent to its destination surface.
                   break;
           }
        });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].