How to detect an object (x) only when it is within another detected object (y) in computer vision? - opencv

This is the image...license plate within cars
I have used yolo for car detection, also trained another yolo model for license plate detection which detects license plate of all the vehicles. I want to join this two codes which detects licence plates only for cars. The above image detects licence plate for bus, trucks too. Is there any way where i can detect licence plate only if the vehicle detected is car?

You could ... submit the original image to the car detection model. The NMS output would contain the class, confidence, and bounding box coordinates. For the object classes that equal car, use OpenCV to crop the original image based upon the scaled bounding box output and submit the new image(s) to the license plate model. The output from the second model should only contain license plates within the car regions.

Related

How to add sub label to an image to perform object recognition using YOLO?

Please help . I have images of a car, Trucks, bikes. I want to train a YOLO or object detection model on it which can output the car_owner, truck_owner, car_model, truck_model, truck_km, car_km etc. But What I know is we can label the images for YOLO taking just one part of information as label in object detection models. Like We can annotate car's image, truck's image as object within an image and it becomes labels to train the model. But I want my model to output these above mentioned information like owner, model, km etc.
How to do this?
Is there any tool to label the images with information and train YOLO or any other model? (Except Image labeler from Matlab)

I want to detect guns in an image. What is the proper steps to do object detection (for gun) given an image with so many objects in the background?

I am new to object detection and very confused how to start the basic step.I want to do object detection in an image.
Given an image, do I first need to detect all objects in that particular image (that includes car, houses, trees, etc in a background) and if a gun is also detected in that image, we can classify them as gun or not gun?
IF your task is to detect only guns there is no point in training a model in detecting all the other things in the image, you can start with something as simple as harr-cascade or you can take a pretrained model(resnet, Yolo or something else) on imagenet dataset (as it has guns) and fine-tune it on the data set that you have( this is called transfer learning).

Labeling runways for localization and detection using deep learning

Shown above is a sample image of runway that needs to be localized(a bounding box around runway)
i know how image classification is done in tensorflow, My question is how do I label this image for training?
I want model to output 4 numbers to draw bounding box.
In CS231n they say that we use a classifier and a localization head.
but how does my model knows where are the runnway in 400x400 images?
In short How do I LABEL this image for training? So that after training my model detects and localizes(draw bounding box around this runway) runways from input images.
Please feel free to give me links to lectures, videos, github tutorials from where I can learn about this.
**********Not CS231n********** I already took that lecture and couldnt understand how to solve using their approach.
Thanks
If you want to predict bounding boxes, then the labels are also bounding boxes. This is what most object detection systems use for training. You can just have bounding box labels, or if you want to detect multiple object classes, then also class labels for each bounding box would be required.
Collect data from google or any resources that contains only runway photos (From some closer view). I would suggest you to use a pre-trained image classification network (like VGG, Alexnet etc.) and fine tune this network with downloaded runway data.
After building a good image classifier on runway data set you can use any popular algorithm to generate region of proposal from the image.
Now take all regions of proposal and pass them to classification network one by one and check weather this network is classifying given region of proposal as positive or negative. If it classifying as positively then most probably your object(Runway) is present in that region. Otherwise it's not.
If there are a lot of region of proposal in which object is present according to classifier then you can use non maximal suppression algorithms to reduce number of positive proposals.

Extracting Image Attributes

I am doing a project in computer vision and I need some help.
The objective of my project is to extract the attributes of any object - for example if I have a Nike running shoe, I should be able to figure out that it is a shoe in the first place, then figure out that it is a Nike shoe and not an Adidas shoe (possibly because of the Nike tick) and then figure out that it is a running shoe and not football studs.
I have started off by treating this as an image classification problem and I am using the following steps:
I have taken training samples (around 60 each) of say shoes, heels, watches and extracted their features using Dense SIFT.
Creating a vocabulary using k-means clustering (arbitrarily chosen the vocabulary size to be 600).
Creating a Bag-Of-Words representation for the images.
Training an SVM classifier to obtain a bag-of-words (feature vector) for every class (shoe,heel,watch).
For testing, I extracted the feature vector for the test image and found its bag-of-words representation from the already created vocabulary.
I compared the bag-of-words of the test image with that of each class and returned the class which matched closest.
I would like to know how I should proceed from here? Will feature extraction using D-SIFT help me identify the attributes as it only represents the gradient around certain points?
And sometimes, my classification goes wrong, for example if I have trained the classifier with the images of a left shoe, and a watch, a right shoe is classified as a watch. I understand that I have to include right shoes in my training set to solve this problem, but is there any other approach that I should follow?
Also is there any way to understand the shape? For example if I have trained the classifier for watches, and there are watches with both circular and rectangular dials in the training set, can I identify the shape of any new test image? Or do I simply have train it separately for watches with circular and rectangular dials?
Thanks

What kind of feature vector is better to detect whether there is a car in a car park slot ?

My aim is to detect whether a car slot is empty or occupied by a car. Finally, the number of cars will be counted in a car park.
The camera is monitoring the car park as it is seen in the sample pictures. Each car park slot is presented with very less pixels. I select four pixel points to define ROI, and I apply the perspective transformation in the image, please see Image 1.
SVM would be a nice approach to classify the samples and train. Unfortunately, I am not sure about the feature vector.
The challenges:
-Shadow of the cars in the adjacent slots
-A car is one slot is visible partially in another slot.
-Shadow of the big buildings
-Weather changes (sunny, cloudy etc. )
-After the rain, slot color is changed (dry or wet)
-Different slots and perspective changes
What kind of features or feature vectors would be the best for the classification?
Thank you in advance,
A color histogram could already be enough if you have enough training data. You can train with shadowed, partly shadowed, non-shadowed empty spots as well as with different cars. It might be difficult to get enough training data, you could also use synthetic data (render cars and shadows on the images).
So it is not only a question about features, but also about training samples.

Resources