Ask Your Question
0

How to Crop image after extract text in JAVA

asked 2017-02-06 12:19:46 -0600

Wanipook gravatar image

updated 2017-02-07 05:05:20 -0600

I'm trying to use android-opencv to recognize text in the picture and I want to do something like finding blocks of text in an image and crop them.

After croping image I will get some of text image and I plan to use them to do OCR in the future. For now I can detect the text regien in the image already by useing this algorithm guide from this link stackoverflow.com/questions/34271356/extracting-text-opencv-java

* My problem is I do not know how to Croping image after extracting text in java language. *

In my concept, I will crop the image from top to button and from left to right. After that put all of croped image in an array of MAT (I'm not sure that MAT function can do the array or not)

i.imgur.com/mZfM7H9.jpg [see my concept picture]

I do not know how to deal with them. Could anyone please help me, guide me, or give me some advice please ... Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-10-12 12:12:22 -0600

holger gravatar image

If it is really only about cropping - try this

//crops an image starting on top left with 100pixels width and height
Mat img = imread("myimage.jpg")
Rect roi = new Rect(0, 0 , 100, 100)
Mat cropped = new Mat(img, roi)
imwrite("cropped.jpg", cropped)
edit flag offensive delete link more

Comments

again from 2017...

holger gravatar imageholger ( 2018-10-12 12:13:20 -0600 )edit

... and if you read between the lines, sorting the rects by x,y was the main problem here, imho.

berak gravatar imageberak ( 2018-10-13 01:04:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-06 12:19:46 -0600

Seen: 4,481 times

Last updated: Oct 12 '18