日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

opencv 运动追踪_足球运动员追踪-使用OpenCV根据运动员的球衣颜色识别运动员的球队

發(fā)布時(shí)間:2023/12/15 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencv 运动追踪_足球运动员追踪-使用OpenCV根据运动员的球衣颜色识别运动员的球队 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

opencv 運(yùn)動(dòng)追蹤

介紹 (Introduction)

In my previous work, I used pre-trained Yolov3 model to detect and used SORT (simple online and realtime tracking) to track football players from video. Then I used OpenCV’s getPerspectiveTransform function to convert the video to bird’s-eye view.

在我以前的工作中,我使用了預(yù)先訓(xùn)練的Yolov3模型來檢測(cè)并使用SORT(簡(jiǎn)單的在線和實(shí)時(shí)跟蹤)從視頻中跟蹤足球運(yùn)動(dòng)員。 然后,我使用OpenCVgetPerspectiveTransform函數(shù)將視頻轉(zhuǎn)換為鳥瞰圖。

One of the problems of this work is that the model cannot tell the difference between teams. It will be good if the program is able to identify players’ team instead of just detecting ‘person’. To further improve this, I wish to include a function which tells the difference based on the colors of players’ jersey.

這項(xiàng)工作的問題之一是模型無法區(qū)分團(tuán)隊(duì)之間的差異。 如果程序能夠識(shí)別玩家的團(tuán)隊(duì)而不僅僅是檢測(cè)“人”,那將是很好的。 為了進(jìn)一步改善這一點(diǎn),我希望包含一個(gè)功能,該功能根據(jù)球員球衣的顏色來區(qū)分差異。

Two approaches I can think of now to this problem.

我現(xiàn)在可以想到兩種解決這個(gè)問題的方法。

  • Train an object detection model using custom dataset containing 3 classes — the players of two teams and referees. This approach might not be practical for real application because one has to train a specific model before every match.

    使用包含3個(gè)類的自定義數(shù)據(jù)集訓(xùn)練對(duì)象檢測(cè)模型-兩個(gè)團(tuán)隊(duì)的球員和裁判。 這種方法對(duì)于實(shí)際應(yīng)用可能不切實(shí)際,因?yàn)楸仨氃诿看伪荣愔坝?xùn)練一種特定的模型。
  • Use to current object detection model and extract the color information from the detections. Based on that I can identify the color of players’ jersey.

    用于當(dāng)前物體檢測(cè)模型并從檢測(cè)中提取顏色信息。 基于此,我可以識(shí)別球員球衣的顏色。
  • I decided to try approach 2 using OpenCV.

    我決定嘗試使用OpenCV方法2。

    足球視頻 (Football video)

    The stationary football video is downloaded from here.

    固定式足球視頻可從此處下載。

    “T. D’Orazio, M.Leo, N. Mosca, P.Spagnolo, P.L.Mazzeo A Semi-Automatic System for Ground Truth Generation of Soccer Video Sequences, 6th IEEE International Conference on Advanced Video and Signal Surveillance, Genoa, Italy September 2–4 2009”

    “T。 D'Orazio,M.Leo,N.Mosca,P.Spagnolo,PLMazzeo,用于足球視頻序列地面真相生成的半自動(dòng)系統(tǒng),第六屆IEEE國(guó)際高級(jí)視頻和信號(hào)監(jiān)視國(guó)際會(huì)議,意大利熱那亞,2009年9月2日至4日”

    彩色面膜由OpenCV (Color Mask By OpenCV)

    The major difference among teams and referee is jersey color — one team is white, the other is blue and the referee is red. I want to determine the player’s team based on the jersey color.

    球隊(duì)和裁判之間的主要區(qū)別是球衣顏色-一個(gè)隊(duì)是白色,另一隊(duì)是藍(lán)色,而裁判是紅色。 我想根據(jù)球衣顏色確定球員的球隊(duì)。

    One frame from the video.視頻一幀。

    First I identified the range for the three colors.

    首先,我確定了三種顏色的范圍。

    color_list=['red','blue','white']boundaries = [
    ([17, 15, 75], [50, 56, 200]), #red
    ([43, 31, 4], [250, 88, 50]), #blue
    ([187,169,112],[255,255,255]) #white
    ]

    Then I applied OpenCV’s inRange function to create masks for three colors.

    然后,我使用OpenCVinRange函數(shù)為三種顏色創(chuàng)建蒙版。

    mask = cv2.inRange(image, lower, upper)

    Then use bitwise_and to apply masks to the frame.

    然后使用bitwise_and將遮罩應(yīng)用于幀。

    output = cv2.bitwise_and(image, image, mask = mask)

    Three colors are extracted now

    現(xiàn)在提取三種顏色

    Red, blue and white masks applied to the image.紅色,藍(lán)色和白色蒙版應(yīng)用于圖像。

    Now we need to apply these mask to the detection. I cropped the image based on the bounding box detected then applied the masks.

    現(xiàn)在我們需要將這些蒙版應(yīng)用于檢測(cè)。 我根據(jù)檢測(cè)到的邊界框裁剪圖像,然后應(yīng)用蒙版。

    crop_img = frame[ymin:ymax, xmin:xmax]Masks applied on the detection. The jersey is identified as blue based on the non-black/total pixel ratio.口罩應(yīng)用于檢測(cè)。 根據(jù)非黑色/總像素比率,將球衣標(biāo)識(shí)為藍(lán)色。

    The way I identify the color is to count the non-black pixels and calculated the ratio (non-black/total pixel) for the output images of the three colors. The highest ratio is the color of the jersey. For the example above, the blue has highest ratio, so the jersey is identified as blue.

    我識(shí)別顏色的方法是對(duì)非黑色像素進(jìn)行計(jì)數(shù),并計(jì)算三種顏色的輸出圖像的比率(非黑色/總像素)。 比例最高的是球衣的顏色。 對(duì)于上面的示例,藍(lán)色的比率最高,因此球衣被識(shí)別為藍(lán)色。

    Now I integrated this function to the player detection script, here are some examples of the masks and player detections.

    現(xiàn)在,我將此功能集成到播放器檢測(cè)腳本中,以下是一些遮罩和播放器檢測(cè)的示例。

    Samples of detections檢測(cè)樣本

    Based on the results of jersey color, I can draw the bounding boxes with different colors.

    根據(jù)球衣顏色的結(jié)果,我可以繪制不同顏色的邊界框。

    Football players tracking. Color of the bounding box represents the color of jersey.足球運(yùn)動(dòng)員跟蹤。 邊界框的顏色代表球衣的顏色。

    Then similar to my previous post, by using Opencv’s getPerspectiveTransform, I obtained the bird’s-eye view as shown in the beginning.

    然后類似于我以前的文章,通過使用Opencv的getPerspectiveTransform ,我獲得了如開始所示的鳥瞰圖。

    結(jié)論 (Conclusion)

    There are still some problems:

    仍然存在一些問題:

  • Some players were not detected at some frames, and also some non-player people were detected. It might be improved by training an object detection model specifically for football players instead of using the pre-trained model. It would be interesting to also track the ball, even through the ball is really small, it is possible to try it or other object detection architecture.

    在某些幀處未檢測(cè)到某些玩家,還檢測(cè)到一些非玩家人員。 通過訓(xùn)練專門針對(duì)足球運(yùn)動(dòng)員的對(duì)象檢測(cè)模型而不是使用預(yù)先訓(xùn)練的模型,可以改進(jìn)它。 跟蹤球也很有趣,即使通過的球真的很小,也可以嘗試使用它或其他物體檢測(cè)體系結(jié)構(gòu)。
  • ID changed when there are player occlusion. Might be helpful to try other tracking algorithm like DeepSort.

    發(fā)生玩家遮擋時(shí),ID發(fā)生了變化。 嘗試其他跟蹤算法(例如DeepSort)可能會(huì)有所幫助。
  • Some applications for this kind of tracking:

    這種跟蹤的一些應(yīng)用程序:

  • Track the players and calculate for their speed and distance.

    跟蹤玩家并計(jì)算他們的速度和距離。
  • Get the heatmap for the players’ path for both teams

    獲取雙方球隊(duì)球員路線的熱圖
  • and more

    和更多
  • Thanks for reading, suggestions and feedback are welcome.

    感謝您的閱讀,歡迎提出建議和反饋。

    翻譯自: https://towardsdatascience.com/football-players-tracking-identifying-players-team-based-on-their-jersey-colors-using-opencv-7eed1b8a1095

    opencv 運(yùn)動(dòng)追蹤

    總結(jié)

    以上是生活随笔為你收集整理的opencv 运动追踪_足球运动员追踪-使用OpenCV根据运动员的球衣颜色识别运动员的球队的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。