Giter Site home page Giter Site logo

tabiancustomcamera's Introduction

This code is deprecated. See CameraX


Get the course here.

Watch the Course Demo.

What you'll learn:

  1. Android's camera2 API
  2. Making full-screen camera previews
  3. Accommodating different screen sizes
  4. Capturing photos
  5. Drawing on photos
  6. Adding stickers
  7. Saving photos to internal storage

Submitting an Issue

Watch this video to learn about how to properly submit an issue.

Here is an example issue I made so you can get a good idea of what it should look like: Example

Link to the Phone Test: Phone Test

Phones with Known Issues

  1. Redmi 4X (santoni)

    See here for a workaround

tabiancustomcamera's People

Contributors

mitchtabian 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

tabiancustomcamera's Issues

App Crash

Your app crashes when click on the camera

On LG NExus 5x unnecessary padding shows

I am testing ur code on LG nexus 5X. On camera preview it shows black padding (which seems unnecessary). On image capture it stretches to full screen (as expected). How can we fix the preview padding?

Image Captured By Camera (Front & Back ) Is Always A Focused Circle Shape

Everything Is Working Fine But When Image Is Captured ( Either Form Back Or Front Camera), it is always A Focused Circle Shape Image

Take A Look At some Screenshots Taken From The App
ScreenShot 1:
screenshot_2018-10-30-13-39-32

ScreenShot 2:
screenshot_2018-10-30-13-38-32

ScreenShot 3:
screenshot_2018-10-30-13-37-54

// Now I Think The Problem Is in the startManualFocus() Method, I Tried To made Some Changes In It , but it didn't work For Me

------------- Phone Test Reuslts:--------------------
Device Information:
OS Version: 3.10.72(1479799023)
OS API Level: 22
Device: QMobile
Model (and Product): QMobile i6i (QMobile i6i)

Display Properties :
Display Width: 480
Display Height: 854
Aspect Ratio: 1.7791667

Drag and resizing not working

Hey! Looking into getting the course, but I downloaded the project and it seems like the 'Drawing' functionality and the drag and resizing function of the emojis don't work.

Any clue why?

Pixel XL
Android 9

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.util.Size.getWidth()' on a null object reference

06-29 15:19:34.687 19819-19869/codingwithmitch.com.tabiancustomcamera E/AndroidRuntime: FATAL EXCEPTION: CameraBackground
Process: codingwithmitch.com.tabiancustomcamera, PID: 19819
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.util.Size.getWidth()' on a null object reference
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment.createCameraPreviewSession(Camera2Fragment.java:972)
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment.access$1900(Camera2Fragment.java:86)
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment$7.onOpened(Camera2Fragment.java:940)
at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:118)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)

Preview Front and Back Camera is too dark

My camera preview is too dark

take a look at this screenshot

Original Camera Application

Back Camera Front Camera

Custom Camera Application

Back Camera Front Camera

Phone test results:

05-11 07:44:19.319 13643-13652/? I/art: Background sticky concurrent mark sweep GC freed 226547(11MB) AllocSpace objects, 4(72KB) LOS objects, 28% free, 29MB/41MB, paused 5.871ms total 143.860ms
05-11 07:47:05.447 1619-1628/? I/art: Background sticky concurrent mark sweep GC freed 266357(13MB) AllocSpace objects, 40(800KB) LOS objects, 25% free, 42MB/56MB, paused 3.849ms total 123.400ms
05-11 07:47:07.017 1619-1644/? I/art: Explicit concurrent mark sweep GC freed 168985(9MB) AllocSpace objects, 54(1164KB) LOS objects, 28% free, 40MB/56MB, paused 3.144ms total 218.693ms
05-11 07:47:10.504 13672-13682/? I/art: Background sticky concurrent mark sweep GC freed 69382(5MB) AllocSpace objects, 17(856KB) LOS objects, 19% free, 28MB/35MB, paused 2.368ms total 230.571ms
05-11 07:47:10.712 13672-18526/? I/Icing: Usage reports ok 0, Failed Usage reports 0, indexed 0, rejected 0, imm upload false

 OS Version: 3.18.19(19043161495bb)
 OS API Level: 23
 Device: mk6p
 Model (and Product): LG-K220 (mk6p_global_com)

 Display Width: 720
 Display Height: 1193
 Aspect Ratio: 1.6569444

05-11 07:48:12.466 1619-1628/? I/art: Background sticky concurrent mark sweep GC freed 241645(14MB) AllocSpace objects, 12(240KB) LOS objects, 27% free, 40MB/56MB, paused 3.980ms total 145.287ms

int android.util.Size.getWidth()' on a null object reference

Attempt to invoke virtual method 'int android.util.Size.getWidth()' on a null object reference
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment.createCameraPreviewSession(Camera2Fragment.java:1040)
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment.access$1900(Camera2Fragment.java:84)
at codingwithmitch.com.tabiancustomcamera.Camera2Fragment$7.onOpened(Camera2Fragment.java:1008)
at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:148)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)

Issue With Camera Load

on some devices... it appears black, even though I gave the app access camera, storage permission.
Error:
reopenCamera: called.
reopenCamera: no surface is available.

Glide crashes with glide.Registry$NoModelLoaderAvailableException upon taking a picture

NOTE: I have changed nothing to the code. It is as is from the github.
Here is The PhoneTest Result.

----------- Device Information -----------

 OS Version: 3.18.31-perf-ga2421ba(V9.6.5.0.NAMMIFD)
 OS API Level: 25
 Device: santoni
 Model (and Product): Redmi 4X (santoni)

----------- Display Properties -----------

 Display Width: 720
 Display Height: 1280
 Aspect Ratio: 1.7777778

Here is the Error itself..

2018-12-04 15:07:56.490 22394-22600/codingwithmitch.com.tabiancustomcamera E/GlideExecutor: Request threw uncaught throwable
com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: android.media.ImageReader$SurfaceImage@742293a
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:584)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:205)
at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:223)
at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)

It crashes after I take a picture (I have given it all the permissions).
Then I tried to replace glide with UniversalImageLoader (https://github.com/nostra13/Android-Universal-Image-Loader) However, it does not seem to accept an Image Object as input (I am newbie). Thanks

Distorted preview after adjusting for weird screen sizes

Hey Mitch, thanks for the great tutorials.

I'm currently enrolled to your custom camera course and faced with some issues in branch 2.5.

First, here is my phone test (Samsung Galaxy S9):
phone_test

I'm getting a distorted preview like this one after adjusting for weird screen sizes according to your instruction and code from branch 2.5:
distorted_preview_after_branch25

The code from branch 2.4 did not show this distortion (but did have a bottom padding) so I compared the logcat results for branch 2.4 end and 2.5 end. Here are the results:
Branch 2.4
branch24end

Branch 2.5
branch25end

It seems the previewWidth and previewHeight shrink to 256:144 (!?) after adding some new codes from branch 2.5. The first one is the change you mention in your video, which is the configureTransform method in Camera2Fragment :
configuretransform

The second one was not explained in the video, but it is the setAspectRatio in your ScalingTextureView class.
setaspectratio

Do you think the previewWidth and previewHeight were affected here?
How should I make the aspect ratio correct and remove the bottom paddings in my app?
I want to know your thoughts. Thank you!

video feature

can you please provide tap and hold video feature. thanks!!

the preview you see in the room before the shot is deformed, after shot the image is instead well proportioned.

the preview you see in the dispaly before shooting is deformed compared to reality.
after shot the image is instead well proportioned.

Screenshot before shot
Screenshot_2019-04-04-23-59-51

Screenshot after shot
Screenshot_2019-04-05-00-00-02

Phone tets results

04-04 23:46:34.094 3693-3693/codingwithmitch.com.phonetest 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

 OS Version: 3.10.49-1120295(G530FZXXS1BQC2)
 OS API Level: 21
 Device: grandprimelte
 Model (and Product): SM-G530FZ (grandprimeltexx)

 Display Width: 540
 Display Height: 960
 Aspect Ratio: 1.7777778

Example Issue

My camera preview isn't fitting the screen. For some reason there's a space at the bottom.

Take a look at this screen shot:
samsung selfie cutoff

Here's what I think the problem is: ......nlksgnkgnklg

Here's some troubleshooting that I've done: ....f.sdfskbgfskldgkslgk

Phone test results:

06-11 15:07:47.546 5910-5910/? I/app_process: The ClassLoaderContext is a special shared library.

                                          [ 06-11 15:07:47.565  5641: 5641 D/         ]
                                          ----------- Device Information ----------- 
                                          
                                           OS Version: 4.4.78-perf+(1)
                                           OS API Level: 27
                                           Device: OnePlus5
                                           Model (and Product): ONEPLUS A5000 (OnePlus5)
                                          
                                          [ 06-11 15:07:47.565  5641: 5641 D/         ]
                                          ----------- Display Properties ----------- 
                                          
                                           Display Width: 1080
                                           Display Height: 1920
                                           Aspect Ratio: 1.7777778

Crashes when capture picture using back camera and while previewing it.

Issue I found:

  1. Sometimes unable to capture a picture using back camera. Even capture button not responding it seems like.
  2. If able to capture a picture using back camera , the app crashes while previewing that picture.

This is error I am seeing:

2019-02-14 17:04:51.037 10007-10687/codingwithmitch.com.tabiancustomcamera E/GlideExecutor: Request threw uncaught throwable
com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: android.media.ImageReader$SurfaceImage@969c821
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:584)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:205)
at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:223)
at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)


2019-02-14 17:04:51.454 10007-10007/codingwithmitch.com.tabiancustomcamera W/Glide: Load failed for android.media.ImageReader$SurfaceImage@969c821 with size [720x1280]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
com.bumptech.glide.Registry$NoModelLoaderAvailableException(Failed to find any ModelLoaders for model: android.media.ImageReader$SurfaceImage@969c821)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: android.media.ImageReader$SurfaceImage@969c821

Distorted preview just sometimes

Hey Mitch! First of all, thanks for the course and all the code you've done, it's helping me a lot with an university project.

I'm having some problems to get a well proportioned preview before capturing the image.

Here's my phone test (Huawei P8 Lite, ALE-L21):
phoneinfo

Well, the thing is, when I first install the app and open it, the preview is well proportioned as you can see in this screenshot:
okpreview

This is the LogCat the first time I open the app:
firstinstalled

However, if I close the app and open it again, the preview is distorted:
distortedpreview

But the LogCat seems exactly the same:
closedandopened

And the most strange thing is, if now I exit the app (but leaving it in the background, not closing it definitely) and enter again, the preview is OK! And the LogCat I obtain is this:
backgroundandopened

Also, this distortion has nothing to do with the captured image, which is always well proportioned despite the preview is OK or not. This is how the image looks like:
capturedimage

I really don't know where the problem is, but obviously it has something to do with whether I close the app or leave it at the background (although the fact that it works well when I first install it is driving me crazy). In both cases, I think the program takes the same resolutions because of the log messages I obtain, so I don't know which is the difference.

Thanks in advance, it is very important for me to solve it.

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.