1. A method for detecting a barcode, comprising: detecting a plurality of blobs from an image; for each detected blob, obtaining imaginary lines bisecting the detected blob perpendicular at the middle of the detected blob; determining at least one cluster of the imaginary lines in a feature space according to slopes and positions of the imaginary lines; and grouping the blobs in one cluster into a rectangular shape corresponding to the barcode.