Crop multiple portion from one image - android

I have a image from which I need create multiple smaller images by drawing rectangles on the parent image, using opencv I know how to draw a rectangle and cut it from the image using Mat and Rect, but the main problem I am facing is that the image is entered through user input and the user can choose to select any portion he/she wants to crop out, so everything needs to be dynamically operated.
The attached image will clarify things a bit
I am new to opencv with android so any help is appreciated.
also if one can provide solution without using opencv is also welcome.

Related

How to crop an image taking base a rectangle in android?

I'm implementing a custom camera, in the layout I have a rectangle inside the layout, where the user have to put his card, so after take the photo i need crop the picture, taking the reference the rectangle.
Any suggestion of how to do this?
Possibly you can use a library that do this on your behalf.
If you are not fully satisfied and need to understand how it works the process you can read the API. I do not know exact if you mean the selection have to be a rectangle of you are referring to the rectangle of your customer view where the card should fit, in the first case the library from Arthurhub should be enough
if you want to implement from scratch, I guess you need to use Matrix
enter link description here
https://github.com/ArthurHub/Android-Image-Cropper

upload image and draw rectangles using only one ImageView

Can I upload a picture (in a ImageView) and draw rectangles using the canvas in the same ImageView? all the examples I've seen so far used two. I wonder if you can use only one? if so, how?
If you are new to android.
Open android studio, .
File ->New->import Sample ,
search for image.
Choose basic render script, this will give you basics of image handling.
However for your usage, you can simply create a view with border and add imageview inside it.

Image embossing in background of the Captured image

I want to emboss a background image to the captured camera image.
i.e say i click a person's image in office, and pick the persons image and emboss it on the already existing hill background image,
So that the person's final image shows that he captured the image at hill side.
Can someone throw some idea on this or share code snippet to achieve this.
I didn't quite catch the embossing part even after reading the example. Image embossing is normally replacing each pixel of an image with a highlight or a shadow so the image area is raised to multiple levels having different depth.
But what you are asking is complex. If i am right, you want to merge the two images where the person from first image will be present in the hill side image.
The issue you will face here is object detection of a person in some random image. This is going to be really difficult. And moreover it will involve hardcore processing of the image with some math. At the end of the day, you do have to remember that what you are asking is for a mobile and not an desktop.
I suggest you to do some extensive research on object detection before proceeding with what you have in mind.
Here are some useful links
http://en.wikipedia.org/wiki/Outline_of_object_recognition
object detection android opencv
http://opencv.org/android
You can search SO for similar questions like this

Android drag two images on canvas

My end goal here is to be able to add two (or more) images to a view/canvas, then turn that canvas into a single bitmap. I've seen many similar SO posts about dragging images around on a view, however, none of them cover dragging multiple images.
I am currently using the matrix commands to rotate and zoom, which work fine but only for one image. The code I am using is similar to this post. The issue here is that using fill_parent on the image will only allow for one image to be dragged because it is on top of the other image. Using wrap_content will only allow the image to be dragged within the confines of how big the image currently is, producing a cropped looking image.
So, is there anyway to edit this code (or use fresh code) to allow multiple images to be dragged and/or zoomed? As I've mentioned, there are many other SO posts about this but none have any solid answers.
Check out the demo app from the project Android Multitouch Controller, pretty much everything is done for you already. It lets you drag, rotate, and scale many images on a custom View. I've used this in the past for a custom image cropper, and it worked out great.
As for turning the resulting Canvas into a Bitmap, I've got a modified version of the Android Multitouch Controller project to do exactly that. You can see that project on GitHub.

Cropping large background image

I have two situations/projects where I have to use a large bitmap as background activity.
The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.
In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?
Is it possible to crop pictures on Android?
Is it possible to define the part of the picture which is kept?
Is it possible to use this croped pictures as background image or may I encounter performance penalties?
What do you think of this technique? Is it a good idea?
Thanks for your help!
answering your questions:
yes it is possible to crop pictures in Android (I've done so)
you can define wich part of the picture is shown in each activity
with a canvas and only drawing the rect that corresponds to the part
of the image that you want to display (eventough I wouldnt suggest
the approach of having diferent activities with the "same" content)
yes, you can use cropped pictures as background image for whatever
you want. Once you cropped the image use that bitmap and save it in
the device and then you might use it as you wish, and eventought is not recommended to have the whole image as background you can do so.
I suggest that you use a SurfaceView since you will be able to move it (the image) all around the screen without having to create a new activity. Here is a good tutorial to SurfaceView Playing with graphics in Android – Part I and this approach will also work with Tablets.

Categories

Resources