sketch effect or cartoon effect to camera in android - android

I saw an app called Cartoon Camera .
https://play.google.com/store/apps/details?id=com.fingersoft.cartooncamera
I was wondering how to add effect to camera directly. I know how to add effect after the picture is taken or to a bitmap. But how to do it in real time camera.
I have no idea on how to start this. Please give me some ideas so I can start the project.

Android OS delivers a built in native filters, their official names are ColorEffects and you an set them easily. The drawback is that you need to implement your own camera in order to use it(Or download android camera from git).
If you just want to use external camera you can find out if the camera broadcast supports color effect.
Then, you can get all the color effects of the camera by doing:
mParameters.getSupportedColorEffects();
It will return a list of supported color effect, but be aware that also some of the effects are exist in this list - you cannot select them because they are being used as part of a scene so in order to apply them you need also to set the exposure, saturation and more.
The ColorEffects that doesn't based on a scene can be easily apply by the following lines of code:
mParameters.setColorEffect(effect);
try {
mCameraDevice.setParameters(mParameters);
} catch (Exception e) {
}

Related

Does mirroring the (front) camera affect MLKit with CameraX?

You might consider this question a sequel to this other one I've recently asked. I have a custom device with a front camera that is mirrored by default and I would like it to always behave like it was flipped horizontally. Note that the end goal of my app is to perform face, barcode and facemask detection (the last one with a custom .tflite model), and I'm trying to understand if it's possible with the current state of CameraX and the quirks of the device I'm using.
For the preview, I can force PreviewView to use a TextureView by calling PreviewView#implementationMode = PreviewView.ImplementationMode.COMPATIBLE so I can just call PreviewView#setScaleX(-1) and it gets displayed like I want.
For taking pictures, I haven't tried yet but I know I can pass setReversedHorizontal(true) to the ImageCapture.OutputFileOptions used in the ImageCapture.Builder, so the image should be saved in reverse.
For image analysis I really don't know. If the input image is taken directly from the preview stream, then it should still be in its default state because PreviewView#setScaleX(-1) only flips the View on screen, right? So in my Analyzer's analyze() I would need to convert the ImageProxy#image to bitmap, then flip it and pass the result to InputImage.fromBitmap().
Is this everything I need? Is there a better way to do this?

How to get Custom Camera view with out using SurfaceView

I want to develop customize camera application like Snap chat!, with out using Surface view.
First i used surface view to develop the app,but i am unable get quality image and also i am unable to get all features what default camera app is providing, like Zoom, focus,face reorganization etc. Please provide me any solution to achieve this
sorry for my english
github/xplodwild/android_packages_apps_Focal
github/almalence/OpenCamera
github/troop/FreeDCam
github/rexstjohn/UltimateAndroidCameraGuide
maybe one those might help

Android blur surfaceview used in camera

I have a camera preview in my android app. As you all probably know it is implemented by a surfaceview in android.
In my photo app, which allows users to take pictures, I want to blur the camera preview (the surface view) if the user has not logged in yet if the user is logged in, I will display the normal preview (without blur)
Blur as something like
But there seems to be no way to do it
Couple things come to mind but I am not sure how to achieve it
use a blur overlay and place it on top of the surface view, but how do u create such blur overlay?
another approach is to change the attribute of the window, but I can't do it to surfaceview,
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
So can we create a window overlay the surfaceview and set the flag like that? I don't think so
can someone tell me how to blur a camera preview, which is a surface view
note: I am trying to blur an area which is the output from camera preview, so it is not like I am blurring a static image, the blur area will change depending on where you point your phone camera
The best way to do this is to take a screen shot of the control, apply a blur to it, and then show that image over the top of the original control. This is how the yahoo weather app does it and its how google suggest you do things like this.
Render script does bluring fast. I've also got some code, but it's not currently at hand right now.
These might help:
http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android
http://docs.xamarin.com/recipes/android/other_ux/drawing/blur_an_image_with_renderscript/
I've also read that there are methods built into Android that do this, but the API isn't public so we cannot use it... which sucks.
Although your 2nd option is losing support in later versions of the Android OS, it may be a good option. I would think to bring a window IN FRONT of your surfaceview, and use the blur_behind property of your now new IN FRONT window.
Android API documentation
"
This constant was deprecated in API level 14.
Blurring is no longer supported.
Window flag: blur everything behind this window.
Constant Value: 4 (0x00000004)"
I do have to admit, Im not 100% sure this would work, but its definitely worth a try.
You have to change the camera parameters; in this case with Camera.Parameters.setPictureSize().
The basic workflow here is :
Camera.Parameters cp = mCamera.getParameters(); // get the current params
cp.set...(); // change something
mCamera.setParameters(cp); // write the params back
Make sure that every resolution that you set via this function is supported. You can get a list of the resolutions that are supported on a device via Camera.Parameters.getSupportedPictureSizes(). and check this Camera documentation.

Realistic Camera in Android

I'm doing a color detector with the Android Camara and need a good parameters configuration that show me a realistic color. For example, I focus in a black shirt, but the camara take the light and change the color to light gray and i don't want it.
If someone knows how to make a good configuration I would appreciate it.
I can't say I have done it myself but I think you would need to have an Activity whose sole purpose would be to do calibration. You would be getting a live Camera feed and prompt the user to press + or - if the shirt is the black they want. The +/- would be augmenting a Color matrix filter applied to the camera view. It might be simpler to take a picture and work with the captured bitmap than it would be for the live camera feed.

Android toggle camera flash

I use the android camera and allow the user to take stills, but I would also like to also allow the user to toggle the ability to use flash. From off/on/auto
This button will be overlayed on the camera just like in the default android camera application. But I do not want to use that application.
How would I do this? I understand Camera.Parameters, but if I added a button on the layout that added key/value pairs to camera.parameters, would I need to refresh the camera? I will eventually try this (sometimes just typing out problems helps me come up with ideas), but any insight would be appreciated!
You can change the Camera parameters at any time (after you have your camera object).
http://developer.android.com/reference/android/hardware/Camera.Parameters.html
Use whatever settings you want, and attach them to whatever you want your buttons to look like. It's 100% straight forward.
here's a sample from something I did...
Camera.Parameters cp = mCamera.getParameters();
cp.setJpegQuality(100);
cp.setColorEffect(Parameters.SCENE_MODE_PORTRAIT);
cp.setFlashMode(Parameters.FLASH_MODE_ON);
cp.setColorEffect(Parameters.EFFECT_MONO);
setPictureSize(cp);
mCamera.setParameters(cp);
You can call setParameters at any time, and they will take effect immediately.

Categories

Resources