‫Hello, my friends.
‫We are going to write the CAPTCHA image method codes.
‫So first of all, let's understand what will this method will function?
‫One behave.
‫We have two buttons, the snap button and the detect button.
‫The user will click on snap button, allows him to go to the to the camera and take an image.
‫And then this button, this detect button will call the detects detect text, which allows us to detect
‫the text inside the captured image.
‫So let's start making them first by step by step.
‫So intent take picture
‫equal new intent and we will use the media store, dot action, image capture and then if take picture
‫dot resolve activity get package manager does not equal to none.
‫Then what we will do, we will start the activity for a result, activity for result.
‫And we use as the first parameter.
‫We take picture and request image capture.
‫Now.
‫The second thing that we are going to make is the on request permission result and the on activity result.
‫So let's first of all allow the user to grant the permission and then we are going to to direct him
‫to capture the image.
‫So the function, the main usage of this method will be done by clicking on the captured image or if
‫the user request the permission, then he will direct it to capture the image.
‫So on request permission result, I will override this method and I will start making this check.
‫So if the grant result dot length greater than zero, it will result for us a boolean camera permission
‫equal to grant result which is an array at index zero will be equal equal to package manager.
‫Dot permission.
‫Granted.
‫If camera permission is through, then those an image for us passing the context as this and permission
‫granted.
‫And then we are going to call the capture image method.
‫You see guys here we have called the capture image also.
‫LS it will display for us if the user refuses to grant the image, the image and the capturing image.
‫Permission and the camera permission.
‫Get application context and we will display for it permission denied.
‫This is our own request.
‫Permission result.
‫Method one.
‫Another method that I'm going to override before moving to detect text.
‫Method is the on activity result.
‫So these are built in methods.
‫We are going to override them and here we are going to check if the request code equal equal to request
‫image capture and the and end this.
‫This is a boolean expression.
‫This would be true and this part also would be true.
‫Result code, request code and the result code equals equal to result.
‫So there is a code would be equal to minus one or the result and the request code would be equal to
‫request image capture then bundle extras equal to data do get extras and here image bitmap equal to
‫to be casted as bitmap and extras dot get and we get the data t.
‫CAPTCHA i i've set image bitmap.
‫To this image bitmap.
‫And this is very simple.
‫We have done using the image, capturing functionality.
‫So we have created this capture image method.
‫We have called it on the on click for the snap button and request permission and granted that the user
‫have been requested the permission correctly and granted it and the own activity result will result
‫in a bitmap that will be displayed into the image view that we have.