How to combine TensorFlow target detection API and OpenCV to analyze football videos

Editor's note: Priya Dwivedi, a deep learning consultant, demonstrated how to combine TensorFlow target detection API and OpenCV to analyze football videos.

Introduction

This World Cup is upset, who would have thought that Germany, the favorite to win the championship, would be out of the group stage? :(

As data scientists, we can do some analysis on football video clips. Using deep learning and opencv we can extract interesting insights from video clips. The following shows an example, Australia vs. Peru, we can identify all the players, referees, footballs, and determine the player's belonging based on the team uniform. All of this can be done in real time.

The related code of this article can be found on GitHub: priya-dwivedi/Deep-Learning/soccerteamprediction/

Step overview

Using Tensorflow's target detection API, you can quickly build a target detection model. If you are not familiar with this set of APIs, you can take a look at the blog post I wrote before introducing the Tensorflow target detection API and how to use the API to build a custom model.

API provides a target detection model pre-trained on the COCO data set. The COCO data set contains 90 common targets.

Part of the COCO target classification

In this example, the categories we care about are people and football, and the COCO dataset contains these two goals.

The API supports many models:

Partial model

These models have different trade-offs between speed and accuracy. Since I am interested in real-time analysis, I chose SSDLite mobilenet v2.

After the player is identified using the target detection API, the OpenCV image processing library can be used to determine the team to which they belong. If you haven't touched OpenCV, you can read the OpenCV tutorial first.

OpenCV can identify the mask of a specific color, and we can use it to identify players in red and yellow. The following figure is an example of OpenCV detecting red.

Detect red

The main steps

Please read it against the corresponding Python code:

Load SSDLite mobilenet model and classification list.

Use cv2.VideoCapture() to open the video and read it frame by frame.

The target is detected on every frame.

The result returned by SSDLite is the recognized classification and corresponding confidence, and bounding box prediction. The confidence threshold is 0.6. Then we cut out the recognizers whose confidence is greater than the threshold.

After extracting each player, we need to read the color of their jersey and predict their belonging. We first define the color range of red and yellow. Then use cv2.inRange and cv2.bitwise to create a color mask. Count the number of detected red and yellow pixels and the percentage of total pixels in the cropped image to detect the team.

Finally, integrate the code and use cv2.imshow to display the results.

Conclusion

well. Now you can see that a simple combination of deep learning and OpenCV can produce interesting results. After target detection and team classification, further analysis can be carried out, such as:

When the camera is in the Australian goal area, you can calculate the ratio of the number of Peruvian and Australian players in the area.

You can draw a heat map of the footprints for each team-for example, showing the area occupied by the Peruvian team.

You can draw the path of the goalkeeper.

The object detection API provides some more accurate but slower models. You can also try them.

If you like this article, please add ❤️ :) I hope you pull the code from GitHub and try it yourself.

In addition, I provide deep learning consultation and like to solve interesting problems. I helped some startup companies deploy innovative AI solutions. If you have a project that requires collaboration, please contact me through my website deeplearninganalytics.org or my email priya.

10 Inches Tablet PC

10-inch tablet devices have greatly surpassed netbooks in terms of entertainment, including reading, games, and audio-visual enjoyment. In other respects, the basic operation of the 10-inch tablet computer built on the touch screen ensures that the application of the tablet computer can be well realized, and its operation performance is closer to that of a smartphone.

1.In appearance, the 10-inches tablet computer looks like a large-screen mobile phone, or more like a separate LCD screen.

2.In terms of hardware configuration, the 10-inches tablet computer has all the hardware devices of a traditional computer, and has its own unique operating system, compatible with a variety of applications, and has a complete set of computer functions.

3.The 10-inches tablet computer is a miniaturized computer. Compared with traditional desktop computers, tablet computers are mobile and flexible. Compared with Laptops, tablets are smaller and more portable

4.The 10-inches tablet is a digital notebook with digital ink function. In daily use, you can use the tablet computer like an ordinary notebook, take notes anytime and anywhere, and leave your own notes in electronic texts and documents.

10 Inches Tablet Pc,Tablet Pc Android,10 Inch Quad Core Tablet,Tablet 10 Inch

Jingjiang Gisen Technology Co.,Ltd , https://www.jsgisengroup.com