Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add: Merge to free #920

Merged
merged 9 commits into from
May 18, 2023
Merged

Conversation

Hitbee-dev
Copy link
Contributor

Hello! I am a developer who is working on various projects using EasyOCR.

I am sending a PR to suggest a function that would be helpful to many people after doing several experiments.

During detection, data with incorrectly configured coordinate vector values is free_list, The horizontal_list has been confirmed to go to data consisting of exact coordinate vector values.

However, this comes as horizontal_list + free_list when receiving the result, so if you need to check the data sequentially, you need to compare the pixels directly and see where they are recognized.

ezgif com-gif-maker

ezgif com-gif-maker (1)

The gif uploaded above is an image that shows that when recognized using EasyOCR directly, the data comes in sequentially and 2 and 4 come in last.

Untitled

This means that the free_list is not sorted at the end and is merged as it is.

Untitled1

This is difficult to see at a glance even when detail=0 is inserted into the detail parameter.

Untitled2

So I developed a function that makes it easier to see by aligning the horizontal_list and free_list together when free_merge is inserted into the output_format parameter.

ezgif com-gif-maker (2)

The gif uploaded above is an image that returns the result value sequentially after adding the function to EasyOCR.

result = reader.readtext(image, output_format='free_merge')
for r in result:
	print(r)

If you enter as above, you want it to be an EasyOCR that returns the results sequentially as follows.

([[90, 72], [162, 72], [162, 172], [90, 172]], '1', 0.9979992393730299)
([[299, 53], [387, 53], [387, 185], [299, 185]], '2', 1.0)
([[522, 44], [598, 44], [598, 172], [522, 172]], '3', 0.9944517558838641)
([[745, 53], [831, 53], [831, 169], [745, 169]], '4', 0.9790806838048891)
([[968, 52], [1042, 52], [1042, 174], [968, 174]], '5', 1.0)
([[1188, 54], [1266, 54], [1266, 172], [1188, 172]], '6', 0.9999949932161059)
([[1415, 77], [1475, 77], [1475, 169], [1415, 169]], '7', 0.9960819788421169)
([[1626, 54], [1706, 54], [1706, 174], [1626, 174]], '8', 1.0)
([[1848, 64], [1920, 64], [1920, 174], [1848, 174]], '9', 0.9999967813517721)
([[2027, 43], [2185, 43], [2185, 184], [2027, 184]], '10', 0.9999989884757856)
([[77.2879532910169, 230.02821146681296], [151.37898588609144, 239.7842872259749], [132.7120467089831, 373.971788533187], [58.62101411390856, 364.2157127740251]], '2', 0.9868415024810453)
([[281, 199], [391, 199], [391, 365], [281, 365]], '2', 0.9980995156509067)
([[526, 236], [574, 236], [574, 350], [526, 350]], '1', 0.3553702823128333)
([[738, 226], [836, 226], [836, 372], [738, 372]], '4', 1.0)
([[872, 282], [904, 282], [904, 358], [872, 358]], '1', 0.46445868490119224)
([[920.8651368309256, 237.1345809643125], [1041.2936593026684, 188.84521212806337], [1093.1348631690744, 349.86541903568747], [972.7063406973315, 398.15478787193666]], '4', 1.0)
([[1162, 224], [1266, 224], [1266, 384], [1162, 384]], '3', 0.9999594692522464)
([[1365, 213], [1497, 213], [1497, 407], [1365, 407]], '5', 0.9986469557185416)
([[1588, 200], [1714, 200], [1714, 394], [1588, 394]], '6', 0.3138604097965505)
([[1853, 255], [1893, 255], [1893, 365], [1853, 365]], '1', 0.9972939940858829)
([[2075, 239], [2117, 239], [2117, 339], [2075, 339]], '1', 0.9854363293399651)
([[47, 439], [199, 439], [199, 575], [47, 575]], '11', 0.9999839842351304)
([[264, 434], [422, 434], [422, 578], [264, 578]], '12', 0.9999954481433951)
([[489, 437], [639, 437], [639, 577], [489, 577]], '13', 0.9999845742882926)
([[709, 437], [865, 437], [865, 577], [709, 577]], '14', 0.9997981225645103)
([[929, 441], [1083, 441], [1083, 579], [929, 579]], '15', 0.9425667175676142)
([[1151, 445], [1303, 445], [1303, 579], [1151, 579]], '16', 0.9999962910793456)
([[1368, 445], [1516, 445], [1516, 579], [1368, 579]], '17', 0.999997049721879)
([[1589, 445], [1741, 445], [1741, 579], [1589, 579]], '18', 0.9999982298328214)
([[1809, 447], [1961, 447], [1961, 585], [1809, 585]], '19', 0.9999972183091315)
([[2031, 445], [2183, 445], [2183, 581], [2031, 581]], '20', 0.9999991570631338)
([[50, 630], [172, 630], [172, 794], [50, 794]], '4', 1.0)
([[260, 622], [428, 622], [428, 798], [260, 798]], '4', 0.9993658331357935)
([[494, 618], [598, 618], [598, 782], [494, 782]], '3', 0.9969145055207527)
([[719, 621], [831, 621], [831, 781], [719, 781]], '5', 0.999999880790714)
([[949, 623], [1041, 623], [1041, 773], [949, 773]], '2', 0.9640018726844447)
([[1173, 655], [1239, 655], [1239, 753], [1173, 753]], '1', 0.9843721660900542)
([[1405, 633], [1471, 633], [1471, 767], [1405, 767]], '1', 0.99952905955627)
([[1606, 628], [1704, 628], [1704, 784], [1606, 784]], '2', 0.9996682680632638)
([[2039, 623], [2151, 623], [2151, 801], [2039, 801]], '2', 0.31963881498015567)
([[43, 845], [196, 845], [196, 979], [43, 979]], '21', 0.9999989041821146)
([[264, 841], [416, 841], [416, 981], [264, 981]], '22', 0.9999998314126102)
([[487, 843], [635, 843], [635, 981], [487, 981]], '23', 0.9999978083645809)
([[707, 841], [863, 841], [863, 981], [707, 981]], '24', 0.9999994942378553)
([[928, 840], [1082, 840], [1082, 984], [928, 984]], '25', 0.9999996628252286)
([[1152, 848], [1300, 848], [1300, 976], [1152, 976]], '26', 0.9864728654305385)
([[1369, 843], [1517, 843], [1517, 981], [1369, 981]], '27', 0.6750208001814506)
([[1589, 847], [1741, 847], [1741, 983], [1589, 983]], '28', 0.9999988299663297)
([[1811, 849], [1961, 849], [1961, 987], [1811, 987]], '29', 0.9999996628252286)
([[2032, 852], [2180, 852], [2180, 980], [2032, 980]], '30', 0.9999972183091315)
([[47, 1021], [183, 1021], [183, 1193], [47, 1193]], '5', 0.9999997615814351)
([[275, 1033], [385, 1033], [385, 1191], [275, 1191]], '2', 0.9999992847443906)
([[488, 1028], [610, 1028], [610, 1198], [488, 1198]], '5', 0.999989390401371)
([[724, 1022], [820, 1022], [820, 1174], [724, 1174]], '3', 0.16538231022019545)
([[927, 1013], [1043, 1013], [1043, 1191], [927, 1191]], '3', 0.9998320411641579)
([[1812, 1030], [1986, 1030], [1986, 1180], [1812, 1180]], '4', 0.9999662640555904)
([[2025, 1031], [2163, 1031], [2163, 1173], [2025, 1173]], '4', 1.0)

Originally, I added this feature to use, but I'm sure it'll be a necessary feature for someone.

Thank you for reading the long article.

@Hitbee-dev
Copy link
Contributor Author

Bugfix

if not free_list:
    return merge_result

Fixed a bug that occurred when the free_list was empty.

@JaidedTeam JaidedTeam merged commit 850d387 into JaidedAI:master May 18, 2023
thuc-moreh pushed a commit to moreh-dev/EasyOCR that referenced this pull request Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants