Ultrasound (US) guided biopsy is a medical procedure routinely performed in clinical practice. This task could be performed by robotic systems to improve the precision in the execution and then the safety for the patient. Both robotic and human procedures could greatly benefit from real-time localization of the needle in US images. This information could guide the robot or the specialists to the correct target point avoiding critical structures. Unfortunately US data provide very low quality images of the needle making this task quite complex, even more if you want to perform the localization on-line during the image acquisition. In this work we present a needle localization method able to extract the needle orientation and the tip position in real time from B-mode US images. To evaluate the performance of the algorithm in a precise way we use an optical tracking system to measure the position and the orientation of the needle and the US probe. In such a way the comparison is not human dependent (i.e. there are no radiologists manually selecting the needle tip) and fully repeatable. The results show an improvement in term of localization accuracy compared to previous works in literature.