In this paper, we proposed a computer vision based approach to detect corrosion in water, oil and gas pipelines. For this, we created a dataset containing more than 140,000 optical images of pipelines with different levels of corrosion. A custom designed convolutional neural network (CNN) was applied to classify the images of pipelines based on their corrosion level. This in-house fabricated CNN has very few parameters to be learned in comparison with the existing CNN classifiers. However, it produced significantly higher classification accuracy (98.8%) with an ability to discriminate between images of corroded pipelines and images without corrosion but having patterns similar to corroded pipelines. The proposed network surpassed most of the state-of-the-art classifiers in its performance. In addition, we proposed a localisation algorithm based on a recursive region-based method, to selectively identify the corroded regions in a given image with higher precision. The proposed deep learning approach effectively wards off the need for manual inspection and other non-vision based non-destructive evaluation techniques for pipeline corrosion which are cost ineffective and interrupts the functioning of pipelines.