Number Plate Detection with OpenCV and Python

In this tutorial, we will see how to use OpenCV Haar Cascades to detect license/number plates. Haar cascade is a type of machine learning algorithm that is used for object detection. It was first introduced in 2001 by Paul Viola and Michael Jones in the paper Rapid Object Detection using a Boosted Cascade of Simple Features. Now to

How to Resize Images with OpenCV and Python

In this tutorial, I will show you how to resize images using OpenCV’s cv2.resize() function. I will also show you how to resize an image by preserving the aspect ratio so that the resized image doesn’t appear distorted. The following image will be used as an example throughout this tutorial: The image has a shape of (400,

Save and Load Models with TensorFlow

Training a deep neural network can take hours or even days to complete. It is not practical to train such a neural network every time you want to make predictions. In this case, you can save and then later reload your model. When you save a model you can save it after training or save checkpoints at regular intervals

How to Crop Images with OpenCV and Python

In OpenCV, images are simply Numpy arrays. So we can use Numpy array slicing for image cropping and remove the part we are not interested in. The image below will be used as an example throughout this tutorial. Crop an Image Using OpenCV The first dimension of a Numpy array represents the rows of the array

How to Rotate Images with OpenCV and Python

In this tutorial, we will see how to rotate images with OpenCV using some built-in functions. The first one is cv2.getRotationMatrix2D which, as its name suggests, will give us the transformation matrix that we will use to rotate the image. The second function is cv2.warpAffine, this function applies the rotation by using the transformation matrix. Rotate Images with OpenCV

How to Use Django’s Generic Foreign Key

Django provides the contenttypes framework that allows us to create generic relationships between models. This can be useful when you want to implement, for example,  a comment system where you can comment on posts, user profiles, images, and even comments themselves. In this tutorial, we will use the ContentType model, GenericForeignKey field, and GenericRelation to implement a comment system where users