I want to do image processing on frames from Android Camera in real time with OpenCv, but all the OpenCv Android examples provide a preview of the image being captured. I really don't need previews of the frames , is there any way to get the frames without actually showing the preview ?
A quick/naive way would be to make onCameraFrame method returning null and set your CameraBridgeViewBase visibility to SurfaceView.INVISIBLE or SurfaceView.GONE.
I still would like to know if it worked for you, but meanwhile I found the solution that worked for me. As I feel grateful for the guy who wrote it, I'm sharing this (scroll down to answers section) with anyone who will have same problem in future.
In case the link vanished, here's his/her pro-tip:
You can set your preview (in this case a CameraBridgeViewBase)
transparent by setting the alpha value of the view, with 0 being
completely invisible.
mOpenCvCameraView.setAlpha(0);
This should make your preview "disappear".
I wonder how your solution works, because as you can read in the docs:
This method is invoked when delivery of the frame needs to be done.
The returned values - is a modified frame which needs to be displayed
on the screen.
Indeed, in my case it doesn't work but I desperately need such a functionality.
Related
I am using kmagick for resizing gif images in android. It works fine for static but gives incorretc output for gif or animated webp files.
Magick.initialize().use {
val wand = MagickWand()
// getting image
wand.readImage(src)
// resizing image
wand.resizeImage(512,512,FilterType.UndefinedFilter)
// Saving image
wand.writeImage(dst)
promise.resolve("Done at ${dst}")
}
Input: (animated gif having multiple frames)
Output: I think its single frame and that also messed up but resizes according to input for height width.
Whats happening here. How to fix it?
Just want to reference for future, this was already answered in
https://github.com/cherryleafroad/kmagick/issues/3#issuecomment-1068044815
Anyways, to sum up what's going on,
Gifs are able to save the difference between frames to save space.
It's due to the way gif images work. Because the cli uses the api in a certain way, and kmagick bindings are only direct bindings to the c api, if you want to achieve the same results that the cli does, you have to use the api in the same way. (kmagick isn't doing anything to the image, it's imagemagick that's doing it; so it's more relevant to check imagemagick api docs / ask them so you can do it in the same way and get the same results).
I'm not sure what imagemagick api they're using off the top of my head however to achieve those results, but I think that doing something like extracting each frame individually then resizing them one by one would solve it.
I have a list of photos in my activity.
I should render those concurrently. so I find the best way to have 3 TextureView at first and change the position of them on scrolling the list. If I create EGLThread each time, It runs correctly, but it has a little delay to update the texture. so I need to have EGLThreads permanently, but I don't know to change the bitmap of each EGLThread. I try so many codes but I couldn't find the solution.
I solved.
should run code in postRunnable in EGLThread
In Android, I have an ImageReader which emits images onImageAvailable. I'm trying to forward those images to an ImageWriter to preview on a SurfaceView. When I attempt to do so, I receive the error stated above.
java.lang.IllegalStateException: Trying to attach an opaque image into a non-opaque ImageWriter, or vice versa
I looked around and I haven't found anyone else mention this issue. Does anyone know what it is talking about? The error seems to be in native code.
I just ran into this issue when trying to pass an Image from the camera into a Surface using ImageWriter. In my case, I fixed the problem by calling SurfaceHolder.setFormat() and passing in the same format that the camera Image is using.
I need to add to user interface in Android application using Camera API a frame showing ID card position with specific dimension on the screen, when the user is taking a picture.
like this:
Any suggestion?
Thank you.
You will have to make your own camera and process each frame to find and highlight edges.
It's not an easy task :)
https://www.tensorflow.org/ or OpenCV might be of interest to you.
I think you cant use android API (Android.Camera) for doing that. You can use the OpenCV to do anything in your application.
Now a day i am doing a project related to image processing with the fallowing feature
1)Stretch 2)Scale 3)Twist
I am not understand how to achieve it in android.
Here i am putting some screen shot related to this project for makeing more clarity in my question.
The above image is the real image i want to apply image processing over this image for making it like
blow image.
Please me any suggestion,help url ,tutorial and other thinks for achieve this task.
You need to find a function which, when applied to pixel coordinates, outputs new pixel coordinates producing the twist effect you're looking for.
It may help to take a look at some of the functions listed at http://reference.wolfram.com/mathematica/ref/ImageTransformation.html (esp. the section "Neat examples").
Once you have defined the function, you'd need to implement in Android the equivalent of the ImageTransformation command. Basically, for each pixel in the output image, call the function to know where to sample in the input image; use windowing when sampling the input image so that you limit artifacts and get a smoother result.