Introduction to the

What is photo tagging? It is well known that machine learning is supported by data. For example, if you want a machine to recognize a cat in a picture, you have to show the machine a lot of pictures that already have answers, just like we do with examples. And the picture annotation is to add the answer to the picture. For example, we want to frame the cat in the picture, and finally pack the coordinates and the original picture as a learning sample, which can be used for the model to eat. This control does just that, allowing you to frame, adjust, label, etc., and the box is not limited to rectangles, but can be expanded.

Results the preview

You can preview the effect drawing on my project home page. There is a limit on the size of the picture, and the effect is not good if it is compressed. You can also directly clone the entire project and run the sample to check the effect.

Add to your project

At the end of your root project’s Build. gradle repository add:

allprojects {
    repositories{... maven { url'https://jitpack.io'}}}Copy the code

The second step is to add dependencies

dependencies {
    implementation 'com.github.SirLYC:ImageLabelView:{latest version}'
}
Copy the code

Use in code

You can start by looking at sample Code

The first step is to add to your layout

Step 2: Set an image (via bitmap)

Similar to the CenterInside representation of ImageView. The Bitmap can be empty, but will empty all previous labels.

valbitmap: Bitmap? =...// download or read from disk
label.setBitmap(bitmap);
Copy the code

The third step is to complete the work in four modes

  • PREVIEW This is the default mode. This mode changes every time you set up a new bitmap. In this mode, you can move or zoom in and out of pictures.
  • DRAW can DRAW frames in this mode. Like a rectangle, the diagonal is where you press and lift. When the finger is lifted, this box will be selected to enter SELECT mode.
  • UPDATE in this mode can change the size or position of the box. You can drag a corner or an edge to resize it, or press into the center of a label to move it.
  • SELECT in this mode you can SELECT a label by clicking or holding down. The tag can be obtained with the following code:
label.selectingLabel()
Copy the code

This mode is typically used to process input to the Messaege attribute or to delete it.

Step4: export data

Get a reference to a Label and call its getData() method and message property to get the information.

Pending/Repair

  • The status is lost when the configuration information changes
  • The circular box
  • Triangular frame
  • Other polygons…

Thank you for your support! Paste the project address again

Github.com/SirLYC/Imag…