Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Merging nearby rectangles(digit recognition)

Hello everyone! I've created a neural network that recognizes handwritten digits and I need to merge two nearby digit rectangles so I can make up the number from recognized digits. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Recognized image image description

I would've expected something like this as the output(just example) [ [ [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51]] , [ [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] ] these two lists represent two digits 123 and 1234 again it's just an example. I hope you got the idea, I just need to split all rectangles by single number somehow.

click to hide/show revision 2
retagged

updated 2020-06-15 12:33:26 -0600

berak gravatar image

Merging nearby rectangles(digit recognition)

Hello everyone! I've created a neural network that recognizes handwritten digits and I need to merge two nearby digit rectangles so I can make up the number from recognized digits. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Recognized image image description

I would've expected something like this as the output(just example) [ [ [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51]] , [ [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] ] these two lists represent two digits 123 and 1234 again it's just an example. I hope you got the idea, I just need to split all rectangles by single number somehow.

click to hide/show revision 3
retagged

updated 2020-06-15 12:33:36 -0600

berak gravatar image

Merging nearby rectangles(digit recognition)

Hello everyone! I've created a neural network that recognizes handwritten digits and I need to merge two nearby digit rectangles so I can make up the number from recognized digits. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Recognized image image description

I would've expected something like this as the output(just example) [ [ [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51]] , [ [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] ] these two lists represent two digits 123 and 1234 again it's just an example. I hope you got the idea, I just need to split all rectangles by single number somehow.

Merging nearby rectangles(digit recognition)

Hello everyone! I've created a neural network that recognizes handwritten digits and I need to merge two every nearby digit rectangles so I can make up the number from recognized digits. there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Recognized image Drawn rectangles image description

I would've expected something like this as the output(just example) [ [ [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51]] , [ [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] ] these two lists represent two digits 123 and 1234 again it's just an example. I hope you got the idea, I just need to split all rectangles by single number somehow.Desired output image description

Merging nearby rectangles(digit recognition)

Hello everyone! I need to merge every nearby digit rectangles there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Drawn rectangles image description Desired output image description

Merging nearby rectangles(digit recognition)rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54], Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels (x,y,w,h) that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54],54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. My question looks like this Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. My question looks like this

Code

Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. I grab contours using findContours cv2.findContours(threshed_img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

My question looks like this

Code

Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. I grab contours using findContours cv2.findContours(threshed_img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

My question looks like is really similar to this

Code

Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description

Merging nearby rectangles(edited)

Hello everyone! I need to merge every nearby digit rectangles so there is should be only 6 rectangles. I've been trying to achieve this for the whole week and I'm soo tired. It would be so nice if anyone could help me. I have a bunch of sorted rectangles from left to right and the task is to split them to separate digits somehow. I grab contours using findContours cv2.findContours(threshed_img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

My question is really similar to this

Code

Code:

import imutils
import cv2

img = cv2.imread('a.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# threshold image
ret, threshed_img = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY_INV)
# find contours and get the external one

#edged = imutils.auto_canny(threshed_img)

ctrz = cv2.findContours(threshed_img, cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(ctrz)
(cnts, boundingBoxes) = contours.sort_contours(cnts, method="left-to-right")
boundingBoxes = list(boundingBoxes)

Example of sorted rectangels that I draw(x,y,w,h) [ [126, 815, 42, 57], [127, 922, 41, 53], [141, 689, 35, 57], [143, 577, 40, 51], [148, 449, 33, 49], [160, 298, 37, 47], [169, 199, 39, 53], [189, 812, 25, 26], [193, 918, 24, 34], [198, 576, 31, 54] ] Drawn rectangles image description Desired output image description