Object detection is a Computer Vision (CV)Technique in which a software system can detect, locate, and trace the object from a given image or video. The special attribute of object detection is that it identifies the class of objects (eg. person, table, chair, etc.) and their location-specific coordinates in the given source.
You want to know how the location of the Object is pointed?
It is very simple. The location is pointed out bydrawing a bounding box around the object. The bounding box may or may not accurately locate the position of the object.
The ability to locate the object inside an image defines the performance of the algorithm used for detection. Face detection is one example of object detection. The object detection algorithms might be pre-trained or can be trained from scratch.
What are classes and why it is important to video surveillance?
I’m going to discuss a few reasons why classes are important in Video Surveillance. Consider a worker who is working in an industry containing hazardous chemicals. They should wear all the safety equipment before he starts working.
Nowadays, many industries use AI systems to detect and alert the workers to wear all the precautionary if not it will raise a voice alert before entering the workspace.
Class Swapping:
In classes, there will be a major issue called Class Swapping. Unwanted or wrong alerts might occur when swapping in classes happens, which also affects the workspace and workers. So always remember, class validation plays a key important role before making any model.
Howto validate automatically by FLANN- based matcher?
The annotation classes may contain 5000+ images in which human validation is not possible. Therefore, we will use a method called Feature Matchingto find the matches with search even in larger datasets.
“Feature matching refers to finding corresponding features from two similar images based on a search distance algorithm. One of the images is considered as the source & the other as target and the feature matching technique is used to either find or derive and transfer attributes from the source to the target image.”
FLANN-based Matcher:
FLANN stands for Fast Library for Approximate Nearest Neighbors. It contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features.
Implementations
To implement this FLANN-based matcher algorithm with our code, follow the below steps.
STEP 1: Create a folder for the demo project.
STEP 2: Place the models inside the demo project folder.
STEP 3: Place the appropriate videos in the same demo project folder.
STEP 4: Refer to this link for implementing object detection with OpenCV.
Output: The sample output is like the image attached below.
STEP 5: To crop the classes, use the below-mentioned function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
STEP 7: Let’s start python code with a FLANN-based matcher.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
STEP 8: To run the code using the below command. And it will check for each class one by one.
Once it is completed the error images will be moved to the error folder within the particular class folder which is swapped with the output file.
Here, the helmet is detected as the safety vest is moved to the error folder so that we can validate and remove or correct the annotated image to fix these swapping issues.
In this blog, we have demonstrated how to work on match features and how to get good accuracy using the FLANN-based method. This can make a big impact in finding the misidentified data in each class which minimizes the manual work time. Similarly, we also have a Brute-Force matcher with ORB/SIFT detector.
Let me explain what Brute-Force matcher with ORB/SIFT detector is all about in my next blog. Until then, keep expecting the best from us as always!
Awesome @Abu