I aim to detect all the on per line basis. I saw many solutions using contouring the image and then generating the highlights, but I want it per line. Like for this image below

I aim to detect all the on per line basis. I saw many solutions using contouring the image and then generating the highlights, but I want it per line. Like for this image below

Not a fully worked answer, but hopefully enough to get you started. Look at the following diagram:
You can use Numpy's np.sum(... axis=1) or np.mean(... axis=1) to sum the pixels across the rows of your image. You can now find the spaces between your lines of text by looking for runs of white in the column of row-totals.