GithubHelp home page GithubHelp logo

memfis19 / annca Goto Github PK

View Code? Open in Web Editor NEW
167.0 8.0 51.0 12.08 MB

Android library to simplify work with camera for video and photo with using different camera apis.

License: MIT License

Java 100.00%
android camera camera-api camera-recorder camera-image photos video camera-control square-camera square

annca's Introduction

Annca

Download Android Arsenal Build Status API

Android solution to simplify work with different camera apis. Include video and photo capturing features with possibility to select quality for appropriate media action etc. In current solution were used some approaches from Grafika project and Google camera samples.

Forks

Some Annca's forks that can be useful if current functionality is not enought:

Example of using

Add Annca activities to the your app manifest file:

<activity
        android:name="io.github.memfis19.annca.internal.ui.camera.Camera1Activity"
        android:screenOrientation="portrait"
        android:theme="@style/ThemeFullscreen" />
<activity
        android:name="io.github.memfis19.annca.internal.ui.camera2.Camera2Activity"
        android:screenOrientation="portrait"
        android:theme="@style/ThemeFullscreen" />
<activity
        android:name="io.github.memfis19.annca.internal.ui.preview.PreviewActivity"
        android:screenOrientation="portrait"
        android:theme="@style/ThemeFullscreen" />

Please note that android:screenOrientation="portrait" is mandatory. In current implementation device rotation is detecting via sensor.

Don't forget to put permissions or request them:

<uses-permission android:name="android.permission.CAMERA" />
<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" />

A code example of the most simple using:

 AnncaConfiguration.Builder builder = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA);
 new Annca(builder.build()).launchCamera();

and thats it. You can use more extended settings i.e.:

 AnncaConfiguration.Builder videoLimited = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA);
 videoLimited.setMediaAction(AnncaConfiguration.MEDIA_ACTION_VIDEO);
 videoLimited.setMediaQuality(AnncaConfiguration.MEDIA_QUALITY_AUTO);
 videoLimited.setVideoFileSize(5 * 1024 * 1024);
 videoLimited.setMinimumVideoDuration(5 * 60 * 1000);
 new Annca(videoLimited.build()).launchCamera();

in this example you request video capturing which is limited by file size for 5Mb and predefined minimum video duration for 5 min. To achieve this result Annca will decrease video bit rate, so use it carefully to avoid unexpected result (i.e. low quality).

How to get result?
 @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == CAPTURE_MEDIA && resultCode == RESULT_OK) {
          String filePath = data.getStringExtra(AnncaConfiguration.Arguments.FILE_PATH);
      }
   }

How to add to your project?

compile 'io.github.memfis19:annca:0.3.7'

How to customize camera?

By customizing I mean change all avaliable camera controls(not camera preview) to take photos, video recording, quality settings and more in future. To be able to customize camera view you should create activity and extend it via AnncaCameraActivity<T>, where T is camera id type (due to that in camera 1 api camera ids represent as int values and in camera 2 api as string values). You should implement all requested methods. For more details please look at BaseAnncaActivity at library project. In future I will provide more detailed instructions how to do it, but anyway it is quite easy task. In case if you gave some troubles or questions, please use GitHub Issues.

Short summary:

-Extend your activity from AnncaCameraActivity<T>;

-Declare it in the manifest only in Portrait mode.

-Override all methods;
-For method createCameraController use Camera1Controller or Camera2Controller respectively;
-If you want to rotate your views do it inside onScreenRotation(int degrees) method;
-For setting your camera contol layout use method getUserContentView();
-If you pass some parameters to your camera via bundle please use method onProcessBundle(Bundle savedInstanceState) which will be called before getUserContentView();
-In case you need to retrieve some data from camera controller or manager use in or after method onCameraControllerReady() was called.

Square camera

Sample app contains example of using square camera. Few words about it:

  1. Before appearing MediaCodec and MediaMuxer there were no ways to record video from specific surface (at least with native tools) that's why in current example I'm using view resizing to achieve square preview. Look at updateCameraPreview method within SquareCameraActivity.
  2. To make square photo I'm cropping origin, please look at onPhotoTaken method within SquareCameraActivity.
  3. To make square video I'm cropping origin with ffmpeg library, please look at onVideoRecordStop method within SquareCameraActivity. Conclusion: Becasue of some android limitations at least before API level 18 it is not possible to record square video. That's why to make solution more less generic I'm using crop outputs approach. In future I'll implement separate solution for API level 18+ to make possible apply more custom settings for camera (shaders, custom photo/preview/video sizes without cropping etc.).

Know issue

Library has not release yet, so it contains some issues.

Roadmap

-Improve determinig camera quality settings;
-Extend annca configuration settings;
-Add fragments supporting;
-Add opengl supporting.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

MIT License
Copyright (c) 2016 Rodion Surzhenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

annca's People

Contributors

memfis19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

annca's Issues

Hi!How to differentiate type of action within onActivityResult?

HI!
this is not issue, i think it already exist.
How can I understand Photo or Video was captured? (of course I can check uri extension but...)

And also can I set Video settings without 'setMediaAction'? I mean that by default Photo mode will be shown , but when I select Video mode - restrictions will be applied. is it possible?

Camera Preview Orientation issue

When I start recording, camera preview orientation is changed into the landscape . how to fix to have it portrait mode, the issue is occurring on Mi 4 device while its working fine on Samsung j5

onPhotoTaken not called on Camera2

Camera is not giving any output sometimes on button click. takePhoto() is called but onPhotoTaken() is not getting called. Do u have any suggestions to resolve the issue.
Phone : Samsung S8

Foucs on touch

Awesome time working on your library, great work really.
But it would be so much useful if a feature of focus on touch is added in the library.
I tried myself but could not get a way around to successfully implement the feature.

camera control design

I want to modify camera control layout design camera control button position and design. How can i do it.

The audio play but the images do not move

After exporting to mp4, you open mp4 file in File Explorer : the audio plays but the images do not move, after a period of time the audio stops playing and the picture starts to move. Display time is also not normal (video about 10s but time show about >2h).

Demo:
https://chatnhanh.blob.core.windows.net/chat/5a1e55d59b53e9324027f49e/158852/89313aeb-2124-4832-9543-5622c67154b7/vid_2018_07_13_17_08_33.mp4

Code:
AnncaConfiguration.Builder builder = new AnncaConfiguration.Builder (context, CAPTURE_MEDIA);
builder.setMediaQuality (AnncaConfiguration.MEDIA_QUALITY_LOW);
builder.setMediaResultBehaviour (AnncaConfiguration.PREVIEW);
builder.setVideoDuration (2 * 60 * 1000);
new Annca (builder.build ()) launchCamera ();

Thanks!

Flashmode on automatic is flashes once ,instead of two

taking photo at night is very painfull as the flash light in automode flashes once , initial for the focusing the view , but not when the actual camera takePhoto is called , thus require a second flashes , i realise it pass to android, to take care of this , but help would be appreciated .

Flash button

flash button not showing how can i enable it.

Zoom photo preview

Trying to add slider zoomer to Camera for photos.
Added to CameraController:

float getCurrentZoom();
void setCurrentZoom(float zoom);
float getMaxZoom();

Added to Camera1Controller

@Override
    public float getCurrentZoom() {
        return cameraManager.getCurrentZoom();
    }
    @Override
    public float getMaxZoom() {
        return cameraManager.getMaxZoom();
    }
    @Override
    public void setCurrentZoom(float zoom) {
        cameraManager.setCurrentZoom(zoom);
    }

Added to Camera2Controller

      @Override
    public float getCurrentZoom() {
        return camera2Manager.getCurrentZoom();
    }
    @Override
    public float getMaxZoom() {
        return camera2Manager.getMaxZoom();
    }
    @Override
    public void setCurrentZoom(float zoom) {
        camera2Manager.setCurrentZoom(zoom);
    }

Added to CameraManager

    float getCurrentZoom();
    void setCurrentZoom(float zoom);
    float getMaxZoom();

Added to AnncaCameraActivity

protected float getCurrentZoom() {
        return getCameraController().getCurrentZoom();
    }
    protected float getMaxZoom() {
        return getCameraController().getMaxZoom();
    }
    protected void setCurrentZoom(float zoom) {
        getCameraController().setCurrentZoom(zoom);
    }

I'm getting value of it by max zoom of camera1

Camera.Parameters parameter = camera.getParameters();
        if(parameter.isZoomSupported()) {
            return parameter.getMaxZoom();
        }

and camera2

(manager.getCameraCharacteristics(this.currentCameraId).get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM))*10

SeekBar impementation:

minZoom = getMinZoom();
        maxZoom = getMaxZoom() - 1;
        final int step = 1;
        seekBarBottom.setMax(Math.round(maxZoom - minZoom));
        seekBarBottom.setOnSeekBarChangeListener(
                new SeekBar.OnSeekBarChangeListener()
                {
                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {}
                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {}
                    @Override
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {                        
                        setCurrentZoom(Math.round(minZoom + (progress * step)));
                    }
                }
        );

I've added to Camera1Manager

public void setCurrentZoom(float zoom) {
        Camera.Parameters parameter = camera.getParameters();
        if(getCurrentZoom() < getMaxZoom()) {
            parameter.setZoom(Math.round(zoom));
            camera.setParameters(parameter);
        }
    }

Works fine.

I've added to Camera2Manager

protected int zoomLevel = 1;
public void setCurrentZoom(float zoomLevel) {
        try {
            CameraCharacteristics characteristics = manager.getCameraCharacteristics(this.currentCameraId);
            float maxZoom = (characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM))*10;
            Rect m = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
            if((zoomLevel <= maxZoom) && (zoomLevel > 1)) {
                int minW = (int) (m.width() / maxZoom);
                int minH = (int) (m.height() / maxZoom);
                int difW = m.width() - minW;
                int difH = m.height() - minH;
                int cropW = difW / 100 * (int) zoomLevel;
                int cropH = difH / 100 * (int) zoomLevel;
                cropW -= cropW & 3;
                cropH -= cropH & 3;
                Rect zoom = new Rect(cropW, cropH, m.width() - cropW, m.height() - cropH);
                try {
                    previewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoom);
                    captureSession.capture(previewRequestBuilder.build(), captureCallback, backgroundHandler);
                } catch (Exception e) {
                    Log.e(TAG, "Error updating preview: ", e);
                }
                this.zoomLevel = (int) zoomLevel;
            }
        } catch (Exception e) {
            Log.e(TAG, "Error during camera init");
        }
    }

It zooms but immediately returns to normal state. Is there some listener that changes its state back?

Custom layout: sample app crashes

Hello!
Sample app crashes when you tap "Take photo" on custom layout again:
Process: io.github.memfis19.sample, PID: 14415
java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1833)
at android.hardware.Camera.takePicture(Camera.java:1778)
at io.github.memfis19.annca.internal.manager.impl.Camera1Manager$3.run(Camera1Manager.java:128)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)

HDR - high quality photo for camera

been using the library in test app for a while, am noticing on samsung phone , the quality doesnt match the phone capability , during onTake photo ,image is clear but on preview ,it at a lower resolution than expected always using lower resolution

Would appreciate any help. Thank You.

Error capturing video

Hi, I'm trying to record video but app crash.
This is the log:

12-27 17:32:01.052 6327-6327/io.github.memfis19.sample W/System: ClassLoader referenced unknown path: /data/app/io.github.memfis19.sample-1/lib/x86_64
12-27 17:32:01.070 6327-6327/io.github.memfis19.sample I/InstantRun: Instant Run Runtime started. Android package is io.github.memfis19.sample, real application class is null.
                                                                     
                                                                     [ 12-27 17:32:01.072  1541: 1562 D/         ]
                                                                     HostConnection::get() New Host Connection established 0x7bdee161e960, tid 1562
12-27 17:32:01.532 6327-6327/io.github.memfis19.sample W/System: ClassLoader referenced unknown path: /data/app/io.github.memfis19.sample-1/lib/x86_64
12-27 17:32:01.801 6327-6327/io.github.memfis19.sample W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
12-27 17:32:02.335 6327-6355/io.github.memfis19.sample I/OpenGLRenderer: Initialized EGL, version 1.4
12-27 17:32:02.335 6327-6355/io.github.memfis19.sample D/OpenGLRenderer: Swap behavior 1
12-27 17:32:02.477 6327-6355/io.github.memfis19.sample E/EGL_emulation: tid 6355: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
12-27 17:32:02.477 6327-6355/io.github.memfis19.sample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7bdee667f100, error=EGL_BAD_MATCH
12-27 17:32:04.360 6327-6327/io.github.memfis19.sample I/CameraManagerGlobal: Connecting to camera service
12-27 17:32:04.517 6327-6355/io.github.memfis19.sample E/EGL_emulation: tid 6355: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
12-27 17:32:04.517 6327-6355/io.github.memfis19.sample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7bdee667f280, error=EGL_BAD_MATCH
12-27 17:32:04.632 6327-6355/io.github.memfis19.sample E/EGL_emulation: tid 6355: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
12-27 17:32:04.632 6327-6355/io.github.memfis19.sample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7bdee667f280, error=EGL_BAD_MATCH
12-27 17:32:04.736 6327-6355/io.github.memfis19.sample D/OpenGLRenderer: endAllActiveAnimators on 0x7bdee66bf400 (RippleDrawable) with handle 0x7bdee5b2e0a0
12-27 17:32:08.550 6327-6453/io.github.memfis19.sample E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
12-27 17:32:08.555 6327-6454/io.github.memfis19.sample I/OMXClient: MuxOMX ctor
12-27 17:32:08.579 6327-6387/io.github.memfis19.sample I/MediaRecorderJNI: prepare: surface=0x7bdefd853e00
12-27 17:32:08.598 6327-6387/io.github.memfis19.sample E/MediaRecorder: start failed: -2147483648
12-27 17:32:08.599 6327-6387/io.github.memfis19.sample E/AndroidRuntime: FATAL EXCEPTION: BaseCameraManager
                                                                         Process: io.github.memfis19.sample, PID: 6327
                                                                         java.lang.RuntimeException: start failed.
                                                                             at android.media.MediaRecorder.start(Native Method)
                                                                             at io.github.memfis19.annca.internal.manager.impl.Camera1Manager$4.run(Camera1Manager.java:143)
                                                                             at android.os.Handler.handleCallback(Handler.java:751)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                             at android.os.Looper.loop(Looper.java:154)
                                                                             at android.os.HandlerThread.run(HandlerThread.java:61)
12-27 17:32:08.614 6327-6464/io.github.memfis19.sample I/OMXClient: MuxOMX ctor
12-27 17:32:08.650 6327-6355/io.github.memfis19.sample E/EGL_emulation: tid 6355: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
12-27 17:32:08.650 6327-6355/io.github.memfis19.sample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7bdee667f2c0, error=EGL_BAD_MATCH
12-27 17:32:08.716 6327-6327/io.github.memfis19.sample W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount 16808

How to change outfile path?

HI,can we change the path of photo?I see the method 'getoutputfile' is private.How to change the target floder?
Thanks.

Change Focus Camera

Hi,
I am using your library. I want to change the camera's focus in CustomCameraActivity. Can you help me??

Camera Preview Aspect-Ration problem

Dear All

i faced a problem when using the CameraFagment Library on Samsung Tab 9",
the problem is when preview the camera before take photo or record video the aspect ratio is fine, but the preview not full the screen,
but when record video, while recording the aspect-ratio is stretched, but the saved video is fine

Best,

Directly start video recorder

Hello,

its a great library to record videos. I want to start video recorder directly when user click on buttton, I want to open full screen view which will record video, user can stop video by pressing stop button. Can you suggest if i can do it with this library ?

Camera Full Screen Problem on some devices

Hi,
Thanks for this library!
I am using your library and most of devices that i have tried camera is full screen but on Samsung Galaxy Note5 camera is square screen. I want to use camera full screen all devices. How can i do this?

It would be nice to hear from you.
Merve

onActiviyResult

when i call this code by fragment

AnncaConfiguration.Builder videoLimited = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA);
videoLimited.setMediaAction(AnncaConfiguration.MEDIA_ACTION_VIDEO);
videoLimited.setMediaQuality(AnncaConfiguration.MEDIA_QUALITY_AUTO);
videoLimited.setVideoFileSize(5 * 1024 * 1024);
videoLimited.setMinimumVideoDuration(1 * 30 * 1000);
videoLimited.setVideoDuration(1 * 30 * 1000);

           new Annca(videoLimited.build()).launchCamera();

onActivityResult method not calling in fragment

Preview Size

Привет, никак не могу понять как задать камере previewSize не переписывая библиотечный мотод. Есть какой нибудь способ?

Flash light in video

  1. Flash light not working when video captured
  2. In some devices flash not working for photo capture, it will not give preview screen after photo capture

AspectRatio

why is it that if i should make targetAspectRatio = 1.0; then, while trying to capture a video, the width looks so long??? @memfis19 @memfis19

Image can be seen here

Change filename

hello, is there any way to change the filename result of video and photo?

add autofocus on view on click -- require camera instance ,but cant find where to start

hi awesome library , but current autofocus take too long on samsung tested on s6 , tried adding the autofocus on code using a a viewOnclickListener , on the main baseAnncaActivity , but it i can grab Camera instance , and also i realise it uses surfaceview and base camera for camera2,camera1 currently this code is for camera1 , where i assume Camera instance is available

code is as follows

private Camera mCamera;
mIsAutoFocusing =false; // can be used as a flag , autofocus is already implemented
 
  @Override // onviewClicklistener
    public void onClick(View view) {
            if (mCamera == null || mIsAutoFocusing) return;
            try {
                mIsAutoFocusing = true;
                mCamera.cancelAutoFocus();
                mCamera.autoFocus(new Camera.AutoFocusCallback() {
                    @Override
                    public void onAutoFocus(boolean success, Camera camera) {
                        mIsAutoFocusing = false;
                        if (!success)
                            Toast.makeText(getActivity(), "Unable to auto-focus!", Toast.LENGTH_SHORT).show();
                    }
                });
            } catch (Throwable t) {
                t.printStackTrace();
            }
        } else {
            super.onClick(view);
        }
    }

Provide custom locales

Hi there,
first - thanks for providing this library to everyone it'll save me a lot of time.

I am using your library and currently it provides english and I assume danish locales only. Is there any way to change/add locales e.g. for the different textViews within activity_preview or for the dialog you create within onSettingsClick(...)?
Currently I get your library via Gradle and actually I don't want to import it manually and modify it myself.

It would be nice to hear from you.
Alex

Rotation Camera2 error

I'm not sure that that;s really a bug. Maybe that's only on my device. After saving of picture I get it by file path. I using the function for getting image orientation from it's properties

public static int getRotation(String filePath, String title, Context context) {
        int rotation =-1;
        Cursor mediaCursor = context.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String[] {MediaStore.Images.ImageColumns.ORIENTATION, MediaStore.MediaColumns.SIZE },
                MediaStore.MediaColumns.DATE_ADDED + ">=?",
                new String[]{title},
                MediaStore.MediaColumns.DATE_ADDED + " desc");
        try {
            if (mediaCursor != null && mediaCursor.getCount() != 0) {
                while (mediaCursor.moveToNext()){
                    rotation = mediaCursor.getInt(0);
                    break;
                }
            } else {
                rotation = getExifOrientationAttribute(filePath);
            }
            return rotation;
        }
        finally {
            try {
                mediaCursor.close();
            } catch (NullPointerException e) {

            }
        }
    }

In camera1 it returns correct value of picture orientation to rotate. But when I'm using camera2, this function always returns 0. Try it. Maybe you should set orientation property or rotate bitmap before it's saving in camera2.

That's why I'm using the function:

private int getAdditionalCamera2Rotation() {
        if(isCamera2) {
            int angle;
            if(degrees == 0) {
                angle = 90;
            } else if(degrees == 270) {
                angle = 180;
            } else if(degrees == 180) {
                angle = 270;
            } else {
                angle = 0;
            }
            return angle;
        } else {
            return 0;
        }
    }

Not correct sizing of Camera2

about this part of code in Camera2Manager

if (configurationProvider.getMediaAction() == AnncaConfiguration.MEDIA_ACTION_PHOTO
                    || configurationProvider.getMediaAction() == AnncaConfiguration.MEDIA_ACTION_UNSPECIFIED) {
                if (windowSize.getHeight() * windowSize.getWidth() > photoSize.getWidth() * photoSize.getHeight()) {
                    previewSize = CameraHelper.
                            getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), photoSize.getWidth(), photoSize.getHeight());
                } else {
                    previewSize = CameraHelper.
                            getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), windowSize.getWidth(), windowSize.getHeight());
                }
                if (previewSize == null)
                    previewSize = CameraHelper.chooseOptimalSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), windowSize.getWidth(), windowSize.getHeight(), photoSize);

            } else {
                if (windowSize.getHeight() * windowSize.getWidth() > videoSize.getWidth() * videoSize.getHeight()) {
                    previewSize = CameraHelper.getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), videoSize.getWidth(), videoSize.getHeight());
                } else {
                    previewSize = CameraHelper.getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), windowSize.getWidth(), windowSize.getHeight());
                }

                if (previewSize == null)
                    previewSize = CameraHelper.getSizeWithClosestRatio(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), videoSize.getWidth(), videoSize.getHeight());
            }

It cuts the left and right parts of picture that will be created.
It will be better to live only

if (configurationProvider.getMediaAction() == AnncaConfiguration.MEDIA_ACTION_PHOTO
                    || configurationProvider.getMediaAction() == AnncaConfiguration.MEDIA_ACTION_UNSPECIFIED) {
                previewSize = CameraHelper.
                            getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), photoSize.getWidth(), photoSize.getHeight());

            } else {
                previewSize = CameraHelper.getOptimalPreviewSize(Size.fromArray2(map.getOutputSizes(SurfaceTexture.class)), videoSize.getWidth(), videoSize.getHeight());
            }

Flash not working by default settings FLASH_MODE_ON

Hi,

Thanks for the the nice library.
We're facing issue with Flash when taking photo.
We set Flash mode ON, as below code. But not see Flash when taking photo.
AnncaConfiguration.Builder builder = new AnncaConfiguration.Builder(activity, CAPTURE_MEDIA); builder.setFlashMode(AnncaConfiguration.FLASH_MODE_ON); builder.setMediaResultBehaviour(AnncaConfiguration.CONTINUE); new Annca(builder.build()).launchCamera();

Flash working only when click on Flash button on Screen to turn it ON. Then It works only for first photo. And then it wont flash again later even its kept still ON, unless we click on button again to turn it ON.

I try to analyze the code to fix it, but couldn't able fix it. Could you please let us know how to fix this issue.

Thank you.

Nexus 7 - open front camera

Hello.

Is it possible to open front camera if back camera is not available?

Currently there is error:

I/CameraManagerGlobal: getCameraService: Reconnecting to camera service
12-20 07:59:05.316 18385-22627/mobilepic.cvs_mobile.com.mobilepic D/Camera1Manager: Can't open camera: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference

thank you

Preview Callback

Hi there, thanks alot for your work =)
I am newbie, is there any way to setPreviewCallback ?

Camera screen size

Hello sir when i select auto , 19201080 or 720480 in setting then camera screen not cover full size and when i select 1280*720 camera screen cover full screen so i want full screen in auto size how it possible.

Image Location Enable ?

Is there any way that image captured by this lib to store location information like stock camera app ?

Error during preparing MediaRecorder: setAudioSource failed.

I'm trying to use Annca in my own app.
Taking photo work well. When I try to take video I ear sound, button change in stop but no timer showed and getting following error:
E/Camera1Manager: Error during preparing MediaRecorder: setAudioSource failed.

Samsung SM-J500FN running android 5.1.1.
I'm launching Annca with:
AnncaConfiguration.Builder builder = new AnncaConfiguration.Builder(this, CAPTURE_MEDIA);
builder.setMediaAction(AnncaConfiguration.MEDIA_ACTION_UNSPECIFIED);
new Annca(builder.build()).launchCamera();

Edit: sorry RECORD_AUDIO permission was missing

Flash is not working in Video mode

Hello,

Thanks for providing this awesome code,
Sir, I need flash in video mode. In this code flash is only enable in camera, but when i switch to the videoCapture mode flash icon is not visible. Please guide me or provide a code snippet to enable flash while capturing video.

Thanks

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.