Android Studio Tutorial - Camera 2 API FULL

  Рет қаралды 152,462

EDMT Dev

EDMT Dev

Күн бұрын

Пікірлер: 482
@pembatamang8233
@pembatamang8233 7 жыл бұрын
Talented developer....wide range of tutorials!!
@eddydn71
@eddydn71 7 жыл бұрын
You are welcome my dear
@wassaufkhalid8593
@wassaufkhalid8593 7 жыл бұрын
your videos are really helpful. It would be better if you record your videos with your voice.
@eddydn71
@eddydn71 7 жыл бұрын
Yes , in next month i will my dear :D
@raremajor
@raremajor 6 жыл бұрын
The image is not getting saved on my phone :(. Also, I want only a small portion of the image which lies inside the rectangle (kind of crosshair one) that is present in the texture view, how can I do this?
@LegoBuilderAJH
@LegoBuilderAJH 6 жыл бұрын
love the very little explanation on what anything is or how it works or the fact that the link to the source code is so infested by ads you can't actually get to it. The fact that half of the variables he's typing in aren't initialized prior to making them for example textureView, view or .getId and the list goes on wich results in a few paragraphs of code that more holes in it than a peg board but hey on the bright side it's better than the legit android developer website that just provides a basic explanation that you can't fully understand because there's so many technical terms it makes your head spin and when you try to find out what they mean it sends you down a rabbit hole that takes hours to figure out. and if you try to get the online coding classes from google udacity it's so outdated it provides little to no help especially with something like this. it's not this dudes fault just as a new guy to the world of coding it's really frustrating
@noaxin
@noaxin 5 жыл бұрын
I'm with you.... had to implment a custom camera and couldn't find anything online that could properly explain what's going on... hope everything went well with you
@gtechhacks765
@gtechhacks765 6 жыл бұрын
you have the best tut thumbs app , adding the voice will make it super extra
@eddydn71
@eddydn71 6 жыл бұрын
:( My English too bad my bro :( But i will try to improve it
@gtechhacks765
@gtechhacks765 6 жыл бұрын
hahaha its ok though not that bad
@ИльяБулахов-ъ8т
@ИльяБулахов-ъ8т 3 жыл бұрын
Hello! I have some problem. When I start the app, thows exception - NullPointerException in this row textureView.setSurfaceTextureListener(textureListener);(index of row - 108). Can are you help me pls?
@eddydn71
@eddydn71 3 жыл бұрын
Check your textureView, it is null, my bro
@joelepping3202
@joelepping3202 7 жыл бұрын
works perfect! thanks.. sir .. can you make an example recording video by this way please
@eddydn71
@eddydn71 7 жыл бұрын
I will try my dear :D
@rachitsingh8304
@rachitsingh8304 4 жыл бұрын
hey there great tutorial camera is working shows me a path of saved image but cant access it any idea where i could get that shows path - storage/emulated/210040430.jpg
@eddydn71
@eddydn71 4 жыл бұрын
It save on your local phone storage, my bro :)
@nome26
@nome26 3 жыл бұрын
@@eddydn71 how to save the photo in the gallery? thanks
@parasmyname784
@parasmyname784 6 жыл бұрын
Nice Work sir. What if we want this camera to open after we click a specific button on the screen, rather than launching as soon as the app starts,because i want to create option for open camera in my app
@eddydn71
@eddydn71 6 жыл бұрын
Just do same my tutorial but put all code open camera to button my dear
@Ami_mation
@Ami_mation 3 жыл бұрын
thank you so much, this video is really helpful
@haykmkrtchyan7093
@haykmkrtchyan7093 6 жыл бұрын
Hi. Can you recommend me what to use. Relative layout or Constraint layout? You used here relative, but what you think, what's better?
@eddydn71
@eddydn71 6 жыл бұрын
I want use Relative layout for simple layout design :)
@haykmkrtchyan7093
@haykmkrtchyan7093 6 жыл бұрын
But if i'm creating a full application, may i use relative? Or i need constraint? Thanks.
@haykmkrtchyan7093
@haykmkrtchyan7093 6 жыл бұрын
I'm using relative, but sometimes my application freezes. Example i have drawer layout with items. When i click on item, than opens fragment and closes the drawer. The drawer close part freezes a little.
@idedhica
@idedhica 5 жыл бұрын
i try to send the bitmap image from another activity using intent.. but it crashed. and the method onCaptureCompleted() doesn't run. but when i erase the intent, onCaptureCompleted() running.. here is the code btnCapture.setOnClickListener(new View.OnClickListener() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void onClick(View v) { Log.d(TAG, "onClick: launch camera."); Log.d(TAG, "onClick: starting camera."); takePicture(); try{ Log.d(TAG, "onActivityResult: received new bitmap from camera: "+bitmap); Intent intent = new Intent(getActivity(), NextActivity.class); intent.putExtra(getString(R.string.selected_bitmap), bitmap); startActivity(intent); getActivity().finish(); } catch (NullPointerException e){ Log.d(TAG, "onActivityResult: NullPointerException: "+e.getMessage()); } } }); this is the final CameraCaptureSession.CaptureCallback captureListener = new CameraCaptureSession.CaptureCallback(){ @Override public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { super.onCaptureCompleted(session, request, result); Toast.makeText(getActivity(), "Saved "+file, Toast.LENGTH_SHORT).show(); Log.d(TAG, "onCaptureCompleted: saved "+file); filePath = file.getPath(); bitmap = BitmapFactory.decodeFile(filePath); BitmapHelper.getInstance().setBitmap(bitmap); createCameraPreview(); } };
@SercanSavranOfficial
@SercanSavranOfficial 4 жыл бұрын
Donated via PayPal (Y). Thank you mate, you'd helped me a lot with this!
@eddydn71
@eddydn71 4 жыл бұрын
You're welcome my bro
@AjaiKumar97
@AjaiKumar97 6 жыл бұрын
When camera is in light it should not flash and I want to keep flash always on when camera goes dark. what is the API for that ?
@ericsiu0420
@ericsiu0420 4 жыл бұрын
I am having an issue "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.hardware.camera2.CameraDevice.getId()' on a null object reference" after I comment the if statement of null cameraDevice in the method takePicture(), which seems that my cameraDevice is null. May I kindly get some help? Thank you.
@eddydn71
@eddydn71 4 жыл бұрын
Your CameraDevice object is null my dear ! Please check your code :D
@ericsiu0420
@ericsiu0420 4 жыл бұрын
@@eddydn71 Dear, thanks a lot I found that I did not put back the openCamera function.:D
@AgonizedCupid
@AgonizedCupid 4 жыл бұрын
Hi, Thanks for your beautiful tutorial that helps me a lot. I have one question for you, How can flash work in there? It will be a great help
@eddydn71
@eddydn71 4 жыл бұрын
stackoverflow.com/questions/38695149/turning-on-off-flash-with-android-camera2-api-not-working I hope it can help you :D
@AgonizedCupid
@AgonizedCupid 4 жыл бұрын
@@eddydn71 Thanks for this. I have applied it before but doesn't work properly. on the other hand, if I use the volume down button to capture an image it crashes. can you please help me with that? By the way thanks for your cooperation.
@etzumahkaya9583
@etzumahkaya9583 3 жыл бұрын
thanks fot his tutorial, i helpme full, i donate in your paypal
@eddydn71
@eddydn71 3 жыл бұрын
Thank you my bro
@ragnarokbananas2623
@ragnarokbananas2623 6 жыл бұрын
Hi EDMT I seem to be getting an error without fail when I use a copy of your code Failed to create capture session; configuration failed I'm not sure what exactly is happening. it doesn't give a more detailed error so its hard to see whats wrong further testing seems to say that it happens on this line // cameraDevice.createCaptureSession(outputSurface, new CameraCaptureSession.StateCallback() // in the takePicture method it also says that it has an unsupported set of inputs/outputs provided just before that in the log but I can't see anything wrong with the outputSurface initialization. Please help
@eddydn71
@eddydn71 6 жыл бұрын
Try watch my tutorial kindly and do step by step my dear
@pdjeowudjx
@pdjeowudjx 6 жыл бұрын
@EDMT Dev Even trying with your code from github , same thing happens. Something's wrong, not Jacob Smith's fault
@kadernurakpnar8315
@kadernurakpnar8315 4 жыл бұрын
Hi, when we take a picture from this camera, how to send same image to firebase storage.in here, we save to image to phone storage only.
@eddydn71
@eddydn71 4 жыл бұрын
You can save it to phone storage and upload it to Firebase Storage :D
@kadernurakpnar8315
@kadernurakpnar8315 4 жыл бұрын
@@eddydn71 thanks 😉
@jeffm6651
@jeffm6651 6 жыл бұрын
This seems to be the one relatively least complicated example I can find. Though it's very code dense for the latest and greatest support for cameras. Has Google posted any official guides or examples on how to use camera2 API? Or any reason as to why so much code is involved to use it?
@eddydn71
@eddydn71 6 жыл бұрын
smartfilming.blog/2017/06/17/what-the-hell-is-camera2-api-and-why-should-i-know-about-it/ Try read it my dear :D
@duynguyenmanh4848
@duynguyenmanh4848 4 жыл бұрын
Dear sir, I am trying to create live camera wallpaper. But in WallpaperService engine, it only has surface (not textureview or sufaceview), so I can't setDefaultBufferSize for surface and camera preview seem to be false ratio. Can you give some suggest in that case? Thank you, sir
@studywithease1804
@studywithease1804 6 жыл бұрын
i have used front camera in the above code but the image is not storing to the sd card and the camera preview is stretched and dark
@eddydn71
@eddydn71 6 жыл бұрын
IN this tutorial is just capture image and show in activity ^^ Not save my bro
@erenhistoria3693
@erenhistoria3693 5 жыл бұрын
please sir! can you tell me what did you change in the code for use the front camera???
@ConlaLuffy
@ConlaLuffy 6 жыл бұрын
thank you very much! your videos are readlly helpfull. i want show grid lines on camera Can you tell me how to do it?
@eddydn71
@eddydn71 6 жыл бұрын
12down voteaccepted If you want to draw the lines dynamically as per your screen size then you should use the following code in your camera preview class. @Override protected void onDraw(Canvas canvas) { if(grid){ // Find Screen size first DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); int screenWidth = metrics.widthPixels; int screenHeight = (int) (metrics.heightPixels*0.9); // Set paint options paint.setAntiAlias(true); paint.setStrokeWidth(3); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.argb(255, 255, 255, 255)); canvas.drawLine((screenWidth/3)*2,0,(screenWidth/3)*2,screenHeight,paint); canvas.drawLine((screenWidth/3),0,(screenWidth/3),screenHeight,paint); canvas.drawLine(0,(screenHeight/3)*2,screenWidth,(screenHeight/3)*2,paint); canvas.drawLine(0,(screenHeight/3),screenWidth,(screenHeight/3),paint); } } You also need to add the following line in the constructor of your camera preview class:this.setWillNotDraw(false);
@ConlaLuffy
@ConlaLuffy 6 жыл бұрын
Thank you for your reply! i will try
@adoapp1385
@adoapp1385 6 жыл бұрын
thank a lot sir..great tutorial..you saved my day
@eddydn71
@eddydn71 6 жыл бұрын
You're welcome my dear
@wess_eletronica
@wess_eletronica 4 жыл бұрын
It would be like zoom control, wb, iso with bluetooth communication?? Do an update with these examples zoom control, wb, iso with bluetooth! How do I make my smartphone screen not dim while the app is on? Thanks
@eddydn71
@eddydn71 4 жыл бұрын
I will try in new version, my bro
@wess_eletronica
@wess_eletronica 4 жыл бұрын
@@eddydn71 when will you make this new video ???
@yoela7331
@yoela7331 5 жыл бұрын
is this mean than we have to use sd card for external storage ?
@bianca-patriciagabur9083
@bianca-patriciagabur9083 5 жыл бұрын
Hello! Is there any way that I can display the image after capture? I followed your tutorial and managed to capture and save images, but I cannot find a way to display it. Thanks
@cartermason8985
@cartermason8985 5 жыл бұрын
Hi there ! I guess you can use an ImageView to display the picture you just took
@bianca-patriciagabur9083
@bianca-patriciagabur9083 5 жыл бұрын
It wouldn't display it, in the same activity, I don't really know why, but I created a new activity and transfered the bitmap over and displayed it there.
@cartermason8985
@cartermason8985 5 жыл бұрын
@@bianca-patriciagabur9083 It wouldn't display you say ? I see. Would you mind if I suggested you a video that I saw yesterday where the developer shows how to display the image you just took in the same activity ? It's in Java though, I don't know if it's gonna help 🤔
@bianca-patriciagabur9083
@bianca-patriciagabur9083 5 жыл бұрын
Yes, I wouldn't mind. Anyway I have to develop further the application, in order to enhance the captured images. So any optimization would help
@cartermason8985
@cartermason8985 5 жыл бұрын
@@bianca-patriciagabur9083 kzbin.info/www/bejne/pZ_HdJinoaaqe6s There it is ! If the link doesn't work, the title of the video is : "Android Studio Tutorial - Take picture with Camera" Have a great day of coding, I hope I helped you out ;-)
@deadstone91
@deadstone91 5 жыл бұрын
Is there a code listing? every time i go to the link in the description, it takes me basically malware, and downloads that i don't want
@eddydn71
@eddydn71 5 жыл бұрын
No no trust me , this link is just shortes link with ADS , not have malware :)
@md.rejaulkarim3315
@md.rejaulkarim3315 5 жыл бұрын
@@eddydn71 Yes brother, I have tested the code. It works. Thanks dude.
@badrussamsi3942
@badrussamsi3942 4 жыл бұрын
great tutorial sir. Is possible using camera 2 API with surfaceview?
@eddydn71
@eddydn71 4 жыл бұрын
I think not, just try, i'm not sure :(
@abiespinal9544
@abiespinal9544 6 жыл бұрын
I tried separating the code from my MainActivity.class .. instead I wrote it in a different class but when running the app and pressing the button to open the camera it crashes my app... any idea why?? HELP PLEASE!!!
@eddydn71
@eddydn71 6 жыл бұрын
Show me your log cat my dear
@yudikarma1434
@yudikarma1434 5 жыл бұрын
please set camera in landscape then go lock screen with password then unlock screen and will go back to camera activity in landscape. do you have error in thats ? i get error in redmi note 3 running android v 22
@moeez351
@moeez351 4 жыл бұрын
do you have camera api 1 lecture please tell?
@eddydn71
@eddydn71 4 жыл бұрын
No i don't, sorry about that :D
@PGMAGESH
@PGMAGESH 4 жыл бұрын
I have recreated the code that you have given here...however, I am getting an error createCameraPreview function in the line where you specify cameraCaptureSession = cameraCaptureSession. Later you change that to cameraCaptureSessions. When I do that the cameraCaptureSession after =, becomes an unresolved variable. Also the same variable inside takePicture method also throws an error. Not able to compile.
@eddydn71
@eddydn71 4 жыл бұрын
Dear, source code has been release by link at description
@jaycelila6258
@jaycelila6258 6 жыл бұрын
Sir as always awesome. How can you remember all the code and type like you already know that?? practice repeatedly? our tutor sucks I don't know how to learn Android studio effectively. Can you suggest some ways?
@eddydn71
@eddydn71 6 жыл бұрын
;) You can remember small code , and your IDE will suggest you :D
@pratzsss
@pratzsss 6 жыл бұрын
Great video. It helped a lot. I had one question. How to open the image you clicked immediately after you captured it from the app. In a new activity i believe. But i tried using Intent on btnCapture. The app just hangs and quits. (Using Android Virtual Device API 27)
@eddydn71
@eddydn71 6 жыл бұрын
You are right to use Intent and start new activity , you can show me your logcat when your app is close
@pratzsss
@pratzsss 6 жыл бұрын
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); textureView = (TextureView)findViewById(R.id.textureView); //From Java 1.4, you can use keyword 'assert' to check expression true or false assert textureView!=null; textureView.setSurfaceTextureListener(textureListener); btnCapture = (Button)findViewById(R.id.btnCapture); btnCapture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { takePicture(); openPictureActivity(); finish(); } }); } private void openPictureActivity() { Intent i = new Intent(this, PictureActivity.class); startActivity(i); }
@pratzsss
@pratzsss 6 жыл бұрын
I fixed my previous issue. Now the issue is, when i use the above code (add aditional activity), the image does not save. And also how to make camera2 brighter. The image is too dark
@eddydn71
@eddydn71 6 жыл бұрын
You're welcome my dear
@idedhica
@idedhica 5 жыл бұрын
@@pratzsss how you fixed it? please share .. i have same issue
@cordisdie2882
@cordisdie2882 6 жыл бұрын
it works good, however, i have a problem with the resolution, it uses only 240x320. Is there anything i am doing wrong?
@kristoferh.9815
@kristoferh.9815 7 жыл бұрын
is it possible to have this with just the camera on and when it finds an object lets say (barcode) can it scan it automatically?
@eddydn71
@eddydn71 7 жыл бұрын
Hmm i will research this proplem my dear
@kristoferh.9815
@kristoferh.9815 7 жыл бұрын
thanks
@upasnabatra6496
@upasnabatra6496 4 жыл бұрын
Hiiiiii sir.. how can i add two textureview in one layout and open camera view in both?
@eddydn71
@eddydn71 4 жыл бұрын
Sorry i don't understand :(
@upasnabatra6496
@upasnabatra6496 4 жыл бұрын
@@eddydn71 sir i asked how can i show camera in atleast two parts like in this we used one texture view so i want to atleast two texture view to capture the different different image .one texture view on left side and another one on right side so how can i do this. And inflate camera in both?and capture two different views
@upasnabatra6496
@upasnabatra6496 4 жыл бұрын
@@eddydn71 please help me sir
@imrualice
@imrualice 4 жыл бұрын
Hey need a help if you can ! I am working on a project where i need to implement timestamp on images clicked by camera.. Clicking images and saving to DB part has been done. Plz help how to timestamp ? Great work.. keep going
@eddydn71
@eddydn71 4 жыл бұрын
stackoverflow.com/questions/54269572/how-to-add-timestamp-over-an-capture-image I hope it can help you
@barbaracorsetti5097
@barbaracorsetti5097 6 жыл бұрын
Is it posible by this tutorial save the photo on the internal storage (not sd)? Thank you so much!
@eddydn71
@eddydn71 6 жыл бұрын
You can write code to save to internal storage my dear
@barbaracorsetti5097
@barbaracorsetti5097 6 жыл бұрын
Can you suggest me some tutorial?
@uckhainguyen5921
@uckhainguyen5921 4 жыл бұрын
Hello, I cloned your project with a little bit change. In my project, I force orientation to landscape. But in preview screen, the orientation of camera is rotated 90 degrees. I searched a lots on google, added configuration function but it didn't work, please help
@eddydn71
@eddydn71 4 жыл бұрын
Have you check with real device ?
@uckhainguyen5921
@uckhainguyen5921 4 жыл бұрын
@@eddydn71 Yes, I have. that's an Xiaomi device with Android 7.0
@binhlam9877
@binhlam9877 5 жыл бұрын
hi anh, em đang có 1 bài toán là có 1 rectangle ở center của textureview, em muốn khi ấn chụp sẽ crop ảnh chỉ lấy nội dung trong rectangle đó. hiện tại em sử dụng camera api nhưng ở mỗi điện thoại khác nhau lại hiển thị preview khác nhau không được đồng bộ. Ở một số máy còn bị méo ảnh dẫn đến việt crop nội dung không được 9 xác. Anh có thể hướng dẫn em hoặc làm 1 video để hướng dẫn về bài toán nói trên được không?
@eddydn71
@eddydn71 5 жыл бұрын
stackoverflow.com/questions/36329188/need-to-capture-images-inside-the-rectangular-view-using-camera-in-android Here you are my der :D
@cactusme2544
@cactusme2544 5 жыл бұрын
Thank you for video.This is great. How can I make the picture be high quality? And How I send the image after click capture to another activity?
@eddydn71
@eddydn71 5 жыл бұрын
You can use Intent to send it :D Try google "Send data with Intent in android"
@BilalBaloch-tl2bp
@BilalBaloch-tl2bp 7 жыл бұрын
nice tutorial as always. Can you make a tutorial about integrating google fit api in app ? thanks
@eddydn71
@eddydn71 7 жыл бұрын
Ya i will try my bro :D
@adityabansal1168
@adityabansal1168 4 жыл бұрын
Sir I want to click images and show in a queue and then after clicking a tick button I want to show them in another activity in a grid view please help.
@eddydn71
@eddydn71 4 жыл бұрын
I will try create tutorial :D
@adityabansal1168
@adityabansal1168 4 жыл бұрын
@@eddydn71 Thank you
@michadobiosz563
@michadobiosz563 7 жыл бұрын
Hi I have a question: so I write an app and it works fine but if the screen is off it's still working in background , how can I solve the problem?
@anindyapal9705
@anindyapal9705 7 жыл бұрын
I used your codes and changed the camera ID to open the front camera but the image saving is getting rotated in diffrent phones diffrently. How to solve this?
@eddydn71
@eddydn71 7 жыл бұрын
Im my real device it have same proplem my dear ! I'm trying to solve
@anindyapal9705
@anindyapal9705 7 жыл бұрын
Sir, I needed that for one project so please do update the repository when you solve that. It will help a lot. Thanks again.
@emulus7871
@emulus7871 7 жыл бұрын
Did you get it solved?
@anindyapal9705
@anindyapal9705 7 жыл бұрын
No man, have you?
@royhetteagapito5295
@royhetteagapito5295 6 жыл бұрын
Did you get it solved? please contact me on mga email :( royhette.agapito@gmail.com
@andikaputra3306
@andikaputra3306 6 жыл бұрын
Great Tutorial.. Can you help me how to make an application like palmistry using camera activity? Thank you.
@eddydn71
@eddydn71 6 жыл бұрын
I will try
@kanwalkhan9569
@kanwalkhan9569 4 жыл бұрын
Sir I want to use usb camera in webview can I achieve this purpose by using this api ?
@eddydn71
@eddydn71 4 жыл бұрын
I don't known, webview is just view, i don't think we can embed camera view into it
@kevinadriansyah688
@kevinadriansyah688 5 жыл бұрын
can i get a bitmap uri when captured the picture, then move to other fragment/activity, if i can, how?? (sorry for my bad English, greet from Indonesia, you help me so much)
@eddydn71
@eddydn71 5 жыл бұрын
stackoverflow.com/questions/42951837/using-camera2-api-to-get-single-image-and-display-it-with-imageview I hope it can help you
@kevinadriansyah688
@kevinadriansyah688 5 жыл бұрын
@@eddydn71 thanks for your help, i wish it can help me
@amolasg
@amolasg 6 жыл бұрын
Please make video on how to add watermark including (date time and name) in camera app ? Hit like who's want video on this topic
@eddydn71
@eddydn71 6 жыл бұрын
I will try update my dear
@emulus7871
@emulus7871 7 жыл бұрын
I'm getting a couple of errors that I can't seem to resolve. On the line 'manager.openCamera(cameraId, stateCallBack, null) in the openCamera() method, I'm getting the error 'Unreachable statement'. Also, in the line 'final ImageReader reader = new ImageReader()......' in the 'takePicture() method, I'm getting an error on 'new ImageReader' that says ''ImageReader()' is not public in 'android.media.ImageReader'. Cannot be accessed from outside package'. Can anyone help me these?
@eddydn71
@eddydn71 7 жыл бұрын
Please watch my tutorial kindly my bro. Unreachable statement mean you have wrong syntax somewhere
@emulus7871
@emulus7871 7 жыл бұрын
I've managed to get it working and taking a picture but I can't for the life of me find the actual picture that I took on my phone. Where does it store it exactly?
@wize_coder
@wize_coder 6 жыл бұрын
emulus7871 did you find the solution to this problem?
@mrmelvin2059
@mrmelvin2059 4 жыл бұрын
Sir, the app is working fine in android 6 and save the image in external storage, but when the same is using in android 10, it shows as saved but no images will be in external storage
@eddydn71
@eddydn71 4 жыл бұрын
Okay ! I will check this and update tutorial on Android 10 :D My bro
@joelvarghese3370
@joelvarghese3370 4 жыл бұрын
Android 10 has a different way to store files. Please take a look at stackoverflow.com/questions/57788878/android-10-what-are-my-options-to-save-files-on-external-storage-into-a-directo#:~:text=Save%20your%20files%20using%20getExternalFilesDir,Use%20the%20method%20getPrimaryStorageVolume().
@ModernTech10
@ModernTech10 6 жыл бұрын
Hello.. I exactly copied your code...... ..everything works fine. Only problem is that I cannot see what I am capturing.. I mean Camera doesn't open. But when I go to the SD card, I can see the captured image. .... So I want to know how can I call this activity from another activity so that I can see people or the scenarios behind the camera. But I cannot see what image I am clicking. The screen comes plain white. However, the image gets stored. Thank You.
@eddydn71
@eddydn71 6 жыл бұрын
All you need is : Capture image by intent :D Just search google about this topic
@ralphlaurenalcantara6304
@ralphlaurenalcantara6304 6 жыл бұрын
is it possible to make a camera API where you can add another button for flashlight and you're the one who can decide whether you want to turn it on or off? I mean an application that can turn on or off flashlight while the camera is running. I look for this kind of application released on google but I haven't seen one.
@eddydn71
@eddydn71 6 жыл бұрын
I will try my dear
@ralphlaurenalcantara6304
@ralphlaurenalcantara6304 6 жыл бұрын
thanks for the reply sir. I just want to know if it is possible?? because we have tried it before. when I open the camera and click for the flashlight button that we create, the flashlight did not open.
@eddydn71
@eddydn71 6 жыл бұрын
stackoverflow.com/questions/38695149/turning-on-off-flash-with-android-camera2-api-not-working Here you arre
@ralphlaurenalcantara6304
@ralphlaurenalcantara6304 6 жыл бұрын
thanks for the reply sir :) you help me a lot for my thesis project.
@sanjivanishinde4482
@sanjivanishinde4482 6 жыл бұрын
We have an error in openCamera() Method manager.openCamera(cameraId,stateCallback,null); it is showing error as unreachable statement
@eddydn71
@eddydn71 6 жыл бұрын
"unreachable statement" like you write a line code but compiler will never find it , maybe it is outside of function or it is inside condition never happen , like if(1
@hamzahafeez6901
@hamzahafeez6901 5 жыл бұрын
same error,.. Could you please help ASAP!
@miyawakizones
@miyawakizones 6 жыл бұрын
I'm having problems with the line: if(ActivityCompat.chekSelfPermission(thid,Manifest.permission. CAMERA) != PackageManager.PERMISSION_GRANTED) The permission on Manifest.permission.CAMERA is red. Please help.
@eddydn71
@eddydn71 6 жыл бұрын
try add "android" before like : android.Manifest.permission.CAMERA
@miyawakizones
@miyawakizones 6 жыл бұрын
EDMT Dev Yep! I tried it earlier :)
@miyawakizones
@miyawakizones 6 жыл бұрын
EDMT Dev Can you help me with my problem? I want my MainActivity to be just a button only, then when I click it, that's the only time the camera will open. It would be a great help :)
@eddydn71
@eddydn71 6 жыл бұрын
watch my tutorial and move code display camera into your button my dear
@miyawakizones
@miyawakizones 6 жыл бұрын
I did watch the whole video! Thanks for the tip :)
@youssefa.8313
@youssefa.8313 5 жыл бұрын
hi thanks for this video , do you know a alternative for getExternalStorageDirectory() beacause now its deprecated
@eddydn71
@eddydn71 5 жыл бұрын
I will try to update my dear
@youssah600
@youssah600 5 жыл бұрын
@@eddydn71 oh that's nice of you
@eddydn71
@eddydn71 5 жыл бұрын
You're welcome my bro
@leeloi1014
@leeloi1014 3 жыл бұрын
Sir, is Camera2 suitable for OCR also? If yes, is there any source code or tutorial?
@eddydn71
@eddydn71 3 жыл бұрын
No, you must implement some tech like Google Vision on your project to enable OCR
@ismeetsingh8586
@ismeetsingh8586 5 жыл бұрын
Does this app show location and time when the picture is clicked....??
@arvindthakor2782
@arvindthakor2782 7 жыл бұрын
You Always Great Sir......Thank U Sir For This One.......
@eddydn71
@eddydn71 7 жыл бұрын
You're welcome my buddy
@muhammadasyraf7456
@muhammadasyraf7456 4 жыл бұрын
it called save on my toast. but theres no image saved in my gallery. please help me.
@eddydn71
@eddydn71 4 жыл бұрын
Please watch my tutorial step by step , my dear
@muhammadasyraf7456
@muhammadasyraf7456 4 жыл бұрын
@@eddydn71 i follow all the step. but i dnt know, it say "'open failed: EACCES (Permission denied)' on Android" . i run itu on API 29. samsung galaxy A70 android 10. i alread add manifest permisson, also permission programmaticly on java file. i think there is an adjustment on android 10/ API 29. maybe u know ? please help.
@eddydn71
@eddydn71 4 жыл бұрын
@@muhammadasyraf7456 Please declare CAMERA permission and request runtime permission for your app
@umm-e-nafay1408
@umm-e-nafay1408 4 жыл бұрын
my app keep stopping in line 110 code is same as you but i don't know why its keep stopping " Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.TextureView.setSurfaceTextureListener(android.view.TextureView$SurfaceTextureListener)' on a null object reference at com.example.project.Camera.onCreate(Camera.java:110) "
@eddydn71
@eddydn71 4 жыл бұрын
Your TextureView is null, please check my bro
@felipemmaiaa
@felipemmaiaa 6 жыл бұрын
Please can you supplement with landscape preview camera?
@eddydn71
@eddydn71 6 жыл бұрын
Just switch mode to landscape and preview mode will auto change my dear :D
@miyawakizones
@miyawakizones 7 жыл бұрын
I want my camera to be opened via button. Can I use Intent then?
@eddydn71
@eddydn71 7 жыл бұрын
sure , String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss"); destination = new File(Environment .getExternalStorageDirectory(), name + ".jpg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(destination)); startActivityForResult(intent, PICK_Camera_IMAGE);
@miyawakizones
@miyawakizones 7 жыл бұрын
EDMT Dev I mean my main activity will be a button only, and when I press it, it will redirect me to a new page which is the camera
@Rashed019
@Rashed019 2 жыл бұрын
Thank you, but there is a simple problem, which is that the image is not saved, why?
@rajughosh6173
@rajughosh6173 7 жыл бұрын
Great sir this means you will be making image editing tutorial soon right..Thanks again
@eddydn71
@eddydn71 7 жыл бұрын
I'll try ! I have many project left :) But i have plan your request :D
@gauravjoshi7685
@gauravjoshi7685 5 жыл бұрын
Hello eddydn, thanks for the video... could you tell us how to improve the resolution of the preview as well as the images stored... awaiting your new Camera2 tutorials...
@eddydn71
@eddydn71 5 жыл бұрын
I will try my dear :D
@gauravjoshi7685
@gauravjoshi7685 5 жыл бұрын
I am trying to open a window from where i can enter the camera by pressing the button... I achieved it and now it works correctly... But i want to return to the previous picture after a single click.... as well as close the cameraDevice and cameraPreview... Could you tell me how to achieve it... i have tried cameraDevice.close(), createCameraPreview.close() but none works....
@eddydn71
@eddydn71 5 жыл бұрын
@@gauravjoshi7685 Source code have available in my description , try to reference :D
@eddydn71
@eddydn71 5 жыл бұрын
@@gauravjoshi7685 Source code have available in my description , try to reference :D
@eddydn71
@eddydn71 5 жыл бұрын
@@gauravjoshi7685 Source code have available in my description , try to reference :D
@tanujkhandal
@tanujkhandal 5 жыл бұрын
how to change the front facing of the camera in this code its urjant
@hummingbird2520
@hummingbird2520 3 жыл бұрын
can you help me how to interface external camera in android project
@talibzaidi9535
@talibzaidi9535 6 жыл бұрын
application is showing preview, but when i click on capture button, preview get stuck, but nothing is saved and toast doesn't show up
@eddydn71
@eddydn71 6 жыл бұрын
Please watch my tutorial step by step my dear :D
@talibzaidi9535
@talibzaidi9535 6 жыл бұрын
well i did that, but i will give it one more try :D btw thanks for replying
@HungVu-dm6xc
@HungVu-dm6xc 5 жыл бұрын
How to use onPreviewFrame in this example? thank you.
@VrhoAirlines
@VrhoAirlines Жыл бұрын
Does this work with usb camera
@vijaygarg8034
@vijaygarg8034 Жыл бұрын
Awesome video!! Is it available in kotlin?
@alokdubey3052
@alokdubey3052 6 жыл бұрын
how can we set shutter speed and iso property on button click in this
@zainabkhan3522
@zainabkhan3522 6 жыл бұрын
error in (CameraManager) in main activity in method takePicture. import class but still error plz help
@eddydn71
@eddydn71 6 жыл бұрын
Show me your error my dear
@mominalomgir7096
@mominalomgir7096 6 жыл бұрын
can u pls explain what "check state orientation of output image" means?
@eddydn71
@eddydn71 6 жыл бұрын
^^ Orientation is have types : portail and landscape , so just check it "
@idedhica
@idedhica 5 жыл бұрын
@@eddydn71 i took picture in portrait, why the result in my phones is landscaoe? please help
@RubabAzim
@RubabAzim 6 жыл бұрын
showing only White screen and by pressing capture button application crash down. :(
@eddydn71
@eddydn71 6 жыл бұрын
Make sure you request runtime permission when you run :D
@RubabAzim
@RubabAzim 6 жыл бұрын
yes i did..but same problem
@khanipoff
@khanipoff 5 жыл бұрын
Since I start app camera doesn't show, but when i lock ant then unlock phone - camera shows. How can I fixed this problem?
@eddydn71
@eddydn71 5 жыл бұрын
Make sure if you run it on android emulator / phone with API over 6.0 (Marshallow and higher) , you should request run-time permission
@flameprincess7313
@flameprincess7313 6 жыл бұрын
"Session has been closed; further changes are illegal." At this part: cameraDevice.createCaptureSession(outputSurface, new CameraCaptureSession.StateCallback() { @Override public void onConfigured(@NonNull CameraCaptureSession session) { try { cameraCaptureSession.capture(captureBuilder.build(), captureCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }... welp? :/
@eddydn71
@eddydn71 6 жыл бұрын
stackoverflow.com/questions/40146485/session-has-been-closed-further-changes-are-illegal Check it my dear
@adityabansal1168
@adityabansal1168 3 жыл бұрын
Bro here i am getting a error of java.lang.IllegalStateException: Session has been closed; here is the code on which i am getting error cameraDevice.createCaptureSession(outputSurface, new CameraCaptureSession.StateCallback() { @Override public void onConfigured(@NonNull CameraCaptureSession session) { try { cameraCaptureSession.capture(captureBuilder.build(),captureListener,mBackgroundHandler);---On this line I am getting error. } catch (CameraAccessException e) { e.printStackTrace(); } } @Override public void onConfigureFailed(@NonNull CameraCaptureSession session) { } },mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); }
@AgonizedCupid
@AgonizedCupid 4 жыл бұрын
Hi, Thanks for your all great tutorials. I was trying to capture an image and set on ImageView using Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } it's working on real device (Android-5) but when I am checking on latest android like Android-9 on emulator it's not working. please give me a solution. my main mative is to take a picture and set it on imageview that's is.
@eddydn71
@eddydn71 4 жыл бұрын
Have you request Camera permission for Android above level 6 ???
@AgonizedCupid
@AgonizedCupid 4 жыл бұрын
EDMT Dev yes I have provided all the permission for runtime. Actually it works if I visualise a thumbnail image from the taken pictures but when I try to set the actual picture that has been taken by camera exactly on image view then it crash latest android and work perfectly on lower android like 5 . Example: I can use image uri directly from onActivityResult and it works for lower android but crash on latest android. If you please make a video on it or please if you have time to check my code that will be great help . It’s a very small code with one activity you know.
@eddydn71
@eddydn71 4 жыл бұрын
@@AgonizedCupid Show me log cat when it crash on latest, my bro
@ssavas06
@ssavas06 6 жыл бұрын
It works on Nexus 5X Emulator (Android 8.0.0 API 26). But It doesn't work on my device.(Android 8.0.0 API 26). What must I do?
@eddydn71
@eddydn71 6 жыл бұрын
You should debug your app , show me your logcat if your app is crash
@yeongytv8168
@yeongytv8168 6 жыл бұрын
Why the image is low quality only 50KB and it's so dark ,how to get high quality image?(same like original camera)
@eddydn71
@eddydn71 6 жыл бұрын
I will try to use other tutorial
@shyamgaikwad7948
@shyamgaikwad7948 6 жыл бұрын
I used the code which you have provided but keeps on showing me "app has stopped " please help me
@eddydn71
@eddydn71 6 жыл бұрын
Show me your log cat when your app is crash my bro
@rajeshb5816
@rajeshb5816 5 жыл бұрын
the same things i how to capture in External camera can you able to help us ?
@eddydn71
@eddydn71 5 жыл бұрын
what you mean about External Camera ?
6 жыл бұрын
How to change camera, from the back to the front? And how to turn on/off flashlight?
@eddydn71
@eddydn71 6 жыл бұрын
I will show more in next tutorial
6 жыл бұрын
Thank you, man, I really appreciate your work.
@najibmoumou2675
@najibmoumou2675 Жыл бұрын
Someone have a tuto to learn multi-camera API
@eddydn71
@eddydn71 Жыл бұрын
Thank you, i will research it
@emulus7871
@emulus7871 6 жыл бұрын
Why can't I find the pictures taken in my gallery? Where is it saving the images?
@gauravjoshi7685
@gauravjoshi7685 5 жыл бұрын
internal storage
@abdulwahid_mohammed
@abdulwahid_mohammed 6 жыл бұрын
Thats too long step. is there easier way to do this or a library help?
@eddydn71
@eddydn71 6 жыл бұрын
^^ Yes , you have :github.com/CameraKit/camerakit-android
@abdulwahid_mohammed
@abdulwahid_mohammed 6 жыл бұрын
@@eddydn71 thanks a lot my bro. You are really great and helpful.
@silongliu2962
@silongliu2962 6 жыл бұрын
Thank you, it helped me a lot.
@sambalsrivastava3285
@sambalsrivastava3285 7 жыл бұрын
Awesome videos man but it would have been really easy to follow if it would have been recorded with voice.
@eddydn71
@eddydn71 7 жыл бұрын
Sorry becuz some video i just record while working at company so i can't record with voice :(
@jestonalastra3543
@jestonalastra3543 6 жыл бұрын
Hi Sir, I followed all the step and check every line, but when I run the project there's no camera display, only the button and there's no error indicate. What should I do..Please help me...Thank you in advance
@eddydn71
@eddydn71 6 жыл бұрын
Make sure you have request runtime permission :)
@jestonalastra3543
@jestonalastra3543 6 жыл бұрын
Thank you Sir! your tutorial is very helpful and I found the error.
@yunli17
@yunli17 6 жыл бұрын
@@jestonalastra3543 I got the same error, can I know where the bug is?
@许居仁
@许居仁 4 жыл бұрын
My app shut down immediately and there is no error jump out. Any help?!
@eddydn71
@eddydn71 4 жыл бұрын
Show me your log cat, filter it by ".java"
@许居仁
@许居仁 4 жыл бұрын
@@eddydn71 Now is opened but still has error when I press take picture button
@许居仁
@许居仁 4 жыл бұрын
@@eddydn71 It throws an exception with CaptureRequest contains unconfigured Input/Output Surface!
@许居仁
@许居仁 4 жыл бұрын
@@eddydn71 2020-03-08 09:10:12.214 6136-6192/com.example.csit321 E/AndroidRuntime: FATAL EXCEPTION: Camera Background Process: com.example.csit321, PID: 6136 java.lang.IllegalArgumentException: CaptureRequest contains unconfigured Input/Output Surface! at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java:738) at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1066) at android.hardware.camera2.impl.CameraDeviceImpl.capture(CameraDeviceImpl.java:927) at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:173) at com.example.csit321.MainActivity$7.onConfigured(MainActivity.java:299) at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0$CallbackProxies$SessionStateCallbackProxy(CallbackProxies.java:53) at android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$soW0qC12Osypoky6AfL3P2-TeDw.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67) This is the logcat
@eddydn71
@eddydn71 4 жыл бұрын
@@许居仁 stackoverflow.com/questions/49533401/getting-an-error-on-android-8-on-a-samsung-device-using-scameracapturesession I hope it can help you
@pomademahal
@pomademahal 3 жыл бұрын
The source code link is not working. Do you mind update the new one?
@eddydn71
@eddydn71 3 жыл бұрын
github.com/eddydn/AndroidCamera2API Here you are
@pomademahal
@pomademahal 3 жыл бұрын
@@eddydn71 noice. Thanks!
@brianngoh4461
@brianngoh4461 6 жыл бұрын
error: no suitable method found for checkSelfPermission(MainActivity,String) method Context.checkSelfPermission(String) is not applicable (actual and formal argument lists differ in length) method ContextWrapper.checkSelfPermission(String) is not applicable (actual and formal argument lists differ in length) Hi sir i got this error, would you mind helping me?
@eddydn71
@eddydn71 6 жыл бұрын
Please watch my tutorial kindly and do step by step my dear
5 жыл бұрын
I reported an error here: cameraCaptureSession.capture (captureBuilder.build (), captureListener, mBackgroundHandler);
@abhijeetgupta2754
@abhijeetgupta2754 7 жыл бұрын
This guy is really awesome. Thank you once again.
@eddydn71
@eddydn71 7 жыл бұрын
You're welcome my dear :D
@zainabkhan3522
@zainabkhan3522 6 жыл бұрын
error is (class require API level 21(current min is 15):android.hardware.camera2.CameraManager) when i cursor on (CameraManager)
@eddydn71
@eddydn71 6 жыл бұрын
Please target your min SDK to 21 my dear ^^
@anuragbhalekar4315
@anuragbhalekar4315 6 жыл бұрын
Hello EDMT Dev,Your tutorial was extremely helpfulThe source code works but with lots of exceptionsthe one troubling me is'Failed to create capture session; configuration failedand the other is'failed to release buffer: Unknown error -1 (1)'if I press recent apps and again open the app only them it saves the captured image and continues to show he preview else it just shows the captured(on button click)preview neither saves it nor continues with the previewAny help is appreciatedThank you
@eddydn71
@eddydn71 6 жыл бұрын
Show me full of your error my dear
@anuragbhalekar4315
@anuragbhalekar4315 6 жыл бұрын
@@eddydn71 Following is the error after pressing the button: 10-14 12:11:40.269 25889-25889/com.example.anurag.myapp1 W/CameraDevice-JV-0: Stream configuration failed due to: endConfigure:380: Camera 0: Unsupported set of inputs/outputs provided 10-14 12:11:40.272 25889-25889/com.example.anurag.myapp1 E/CameraCaptureSession: Session 3: Failed to create capture session; configuration failed
@anuragbhalekar4315
@anuragbhalekar4315 6 жыл бұрын
Ok got the solution as well: In the function takePicture() Comment the following lines in your code: if(jpegSizes != null && jpegSizes.length>0){ width=jpegSizes[0].getWidth(); height=jpegSizes[0].getHeight(); }
@eddydn71
@eddydn71 6 жыл бұрын
You're welcome my dear
@waqarvicky5943
@waqarvicky5943 6 жыл бұрын
Can you please guide me "How to add guide marks in the camera view" .
@eddydn71
@eddydn71 6 жыл бұрын
android-er.blogspot.com/2010/12/add-overlay-on-camera-preview.html I hope it can help you :D
Android Studio Tutorial - Tinder Avatar View edmt dev
16:16
Android Studio Tutorial - Grid Layout and CardView
14:21
EDMT Dev
Рет қаралды 600 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Android Camera2 API by Huyen Tue Dao
47:29
GDG Boulder
Рет қаралды 27 М.
Raycue Dock for 2024 Mac Mini M4 (Review)
8:23
Mr. Brown’s Basement
Рет қаралды 3,6 М.
Android Camera2 API Video App - Part 1 How to add icons using android studio
14:26
Mobile Application Tutorials
Рет қаралды 52 М.
OpenAI's o1 just hacked the system
26:31
AI Search
Рет қаралды 25 М.
Capture picture from camera - Android Studio Tutorial
23:54
The Code City
Рет қаралды 57 М.
Windows Aurora M2 is Completed!
4:58
2021Windows11
Рет қаралды 49
(Custom Camera) API Tutorial  Part 1 (Display Camera)
14:38
Android with Haroon
Рет қаралды 73 М.
Building a Custom Camera on Android
4:35
CodingWithMitch
Рет қаралды 88 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН