3
   public void draw(Canvas canvas) {
    Log.d(TAG, "on draw text graphic");
    if (element == null) {
        throw new IllegalStateException("Attempting to draw a null text.");
    }

    // Draws the bounding box around the TextBlock.
    RectF rect = new RectF(p,q,r,s);
    canvas.drawRect(rect, rectPaint);

    // Renders the text at the bottom of the box.
    canvas.drawText(text, rect.left, rect.bottom, textPaint);

I have the coordinates in the image (p,q,r,s) and I want to blur this region only, right now I am drawing a rectangle around it. If by using canvas it is possible then it would be great but other methods are also welcomed

I have looked into other articles and everyone refers to RenderScript and blurring the whole image or blurring the textview, I am not using a textview here, rather a GraphicOverlay which dynamically creates rectangles(aim is to blur this part) given the coordinates.

Here is the layout view:

<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

<ImageView
    android:id="@+id/image_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="Select image for text recognition"
    android:scaleType="fitStart"
    app:layout_constraintBottom_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="parent" />

<com.example.sengu.test_1.GraphicOverlay
    android:id="@+id/graphic_overlay"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" />

<Button
    android:id="@+id/capture_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toTopOf="@id/button_text"
    android:text="Capture" />

<Button
    android:id="@+id/button_text"
    android:text="Find text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toLeftOf="@id/button_translate_text"
    app:layout_constraintBottom_toBottomOf="parent"/>

</android.support.constraint.ConstraintLayout>
Shourya
  • 31
  • 2

0 Answers0