Object Detection (PART-II)

 The most fundamental computer technology related to Computer vision and Image Processing is Object Detection. It deals with detecting the semantic object of a certain class in digital images and videos. In the previous post, I have shown you how to detect object very easily with less than 15 lines of code. But our concern is about the FPS(Frames Per Second). Check out the Object Detection (PART-I)  if you have not seen yet. 

object detection

In this post, we are going to optimize the previous post so that we can improve the FPS. In this case also we are gong to use YOLO model again. There are 80 different classes that can be detected using YOLO model. such as- 

    person,   bicycle,   car,   motorcycle,   airplane,
    bus,   train,   truck,   boat,   traffic light,   fire hydrant,   stop_sign,
    parking meter,   bench,   bird,   cat,   dog,   horse,   sheep,   cow,   elephant,   bear,   zebra,
    giraffe,   backpack,   umbrella,   handbag,   tie,   suitcase,   frisbee,   skis,   snowboard,
    sports ball,   kite,   baseball bat,   baseball glove,   skateboard,   surfboard,   tennis racket,
    bottle,   wine glass,   cup,   fork,   knife,   spoon,   bowl,   banana,   apple,   sandwich,   orange,
    broccoli,   carrot,   hot dog,   pizza,   do_not,   cake,   chair,   couch,   potted plant,   bed,
    dining table,   toilet,   tv,   laptop,   mouse,   remote,   keyboard,   cell phone,   microwave,
    oven,   toaster,   sink,   refrigerator,   book,   clock,   vase,   scissors,   teddy bear,   hair dryer,
    toothbrush.

You can download the the names of the class and the configuration file. just click on the links.

Python code for Object Detect

I am providing the code bellow. Then I will discuss some key points regarding to this code.
python code
python code

Key points to be Noted:

  • First, you have to read the network that is already created (YOLO)
  • Then, create a list of all the classes that it can detect.
  • Most importantly, the model can not read the image directly captured by the webcam. For that reason, we have to make a blob type from the image using cv2.dnn.blobFromImage()
  • In the code, findbox() will find the rectangular box around the object and print a name of that object with confidence level.

Output of the Python code

Conclusion

In this post we have learnt how to optimize the previous Object Detection (PART-I) 


    Comments

    Popular posts from this blog

    Distance measurement using opencv

    Object Detection (Part I)

    Invisible Cloak using OpenCV