Android About Region and Touch - java

I'm developing an image-processing program. And i'm stuck here.
I have an image like this:
I drew a closed line (path) by finger. Now, I want to get all points in the closed-region cut out from the image. Is there any algorithm or method?

How to create a circular ImageView in Android?
this may help you.
it user drawCircle() to crop a circle, maybe drawPath() can crop a region...

Related

How to detect what the content on the display is?

I have an app that rotates other apps. It uses an accessibility service so I have the ability to retrieve screen content.
Say I'm rotating a game called Geometry Dash to the portrait direction. Sometimes it will rotate correctly and look like this:
But other times it incorrectly appears like this:
Is it possible to detect when half the screen is black like in the second pic?
Perhaps using AccessibilityNodeInfo is the key since that class gives information about what's on the screen?
You could do it easily be loading the content of the screen into a bitmap then you can split the bitmap in two parts.
Check if one of them is only black.

How to detect upside down text in image / upside down image using OpenCV and Java

I face this problem for a while and still cannot figure it out.
I'm using OpenCV and Java to detect the card from image and crop it then transfrom, every thing goes fine if the original image is in correct orientation. The task for now is: How to rotate image in 180 degrees? Or how to detect the text is upside down then we can rotate it to right orientation.
The result i get from OpenCV in Java is the Mat object contains the cropped cards.
Does anyone faced and solved this before or have any idea please direct me to the right solution.
Thanks in advance.
Here is sample images i cropped from originals
Sample 1
Sample 2
Just run your code, and if it finds nothing on the first pass then you can just rotate the image and try again? Or you could try scanning a small portion of the card only, and then you can determine if the card is the right way up or not.
It will pay to sit down and think it through for yourself on how this might be done best.
As for rotating images, have you tried looking it up? Because if you are using a buffered image then rotating can be done with a simple AffineTransform:
AffineTransform at = AffineTransform.getRotateInstance(Math.PI, image.getWidth()/2, image.getHeight()/2.0);
BufferedImage myRotatedImage = createTransformed(image, at);
Edit: For rotating a Mat object you can use:
Imgproc.warpAffine(Mat source, Mat dest, Mat M, Size size)
Taken from: http://docs.opencv.org/java/3.0.0/

Image recognition and sort of automatic calibration

I am not sure how to describe my questions headline to point out my question in one sentence (english is not my native language so please do not flame me for it)
I have the following szenario.
An image is displayed on a computer display. a camera (webcam or similar) is pointed towards the disolay so the image observed will cover nearly the whole video frame, but might be a bit disorted.
How can i calibrate/detect the bounds of the image?
For calibration purposes i could display a test picture. The camera and displayed image will NOT change its position after calibration!
My only idea would be to click some reference points with my mouse. Automatic detection like in QR code would be preferred/perfect.
You can use a calibration points similarly to QR code. Place three black squires in the calibration image corners. As the result you'll obtain an area (inside a rectangle, set by calibration points) that can be used as a boundary for all further images.

Java texture png modificaiton

I'm trying to make a simple java game.
I have some png file that i want to draw, but first i want to make some modification on that png. I would like to take a png, and delete to background some parts of it and add some colored lines..
For my game im using libgdx.
I dont know what to use for this, so i can search on google about it and learn.
Few hints, about what functions i should use could be awesome, Ty.
P.S. I tryed to search on internet before post here, but i didnt find something that could help me, probably idk what to search.v
Edit:
I found Pixmap from libgdx, but i can delete to background. Any advices ?
Edit2:
i want to load this texture
multiplicate when needed (no problem here)
and delete some parts of it, to background, so it will take this shape:
by using pixmap, when im drawing background over it, nothing is happen, because its draw over, not instead of.
What i could make, was using pixmap to draw the top part, that i want to delete, and manualy delete it using external programs:
I think you might want to look at a "mask" image. There are some approaches listed here: https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Masking
Alternatively, you could use create a mesh that encodes the "ground" (with the bump) and then texture it. OpenGL would take care of truncating the edge of the mesh. Try: Drawing textured polygons with libgdx
Another approach is to just draw the dirt texture on the full screen, and then draw the "background" over it. You will need to make pixels in the "background" image transparent so the dirt will show through. Whatever pixel editor you are using should be able to do that. Alternatively, pick a "key" color and convert those pixels to transparent when you load the image as a pixmap.
I don't know if this question is serious, but you cannot do what you're asking in Java. You need a photo editing software such as Photoshop or GIMP.

How to crop an image in between four points on Android [duplicate]

This question already has answers here:
How to capture an image in android with coordinates
(3 answers)
Closed 9 years ago.
Am new to work on bitmaps in android, and am unable to crop the image between four point ( clearly its not a rectangle in shape).
I convert the image into bitmap and set as background to layout.
now i have four different points(p0,p1,p2,p3)
I have the values of these points .
Now its time to crop the image between these region and show as rectangle shaped bitmap..(ie, as background to another layout.).
Am again mention clearly ,, crop the image between only these points..
ie, inside the region only.
Which way i can solve this problem,? can i use any third-party tool.. the suggest me which those ones.........
Thanks to #all
Here is a solution how to crop image if need a circle.
Based on that code, you can play a bit with Graphics and you will be able to crop your shape.
I will not write code ready for copy paste.
I hope it helps!
Edit:
Maybe Here is your solution!
At first select rectangle region with Bitmap.getPixels
Then avaluate lines which bound your shape.
Change evry pixel in pixels[] which is outsidebounds and set it to 0 (or other value, it will be background of image)
And recreate you image from new dataset.
EDIT: try to use clipping technics http://www.zetcode.com/gfx/java2d/clipping/ or http://www.roseindia.net/java/example/java/swing/graphics2D/clip-area.shtml in example rectangle was used but thos methodics allows any region

Categories