最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何使用yolov5輸出檢測到的目標(biāo)坐標(biāo)信息

 更新時間:2022年03月28日 09:34:45   作者:一位安分的碼農(nóng)  
YOLOv5是一系列在 COCO 數(shù)據(jù)集上預(yù)訓(xùn)練的對象檢測架構(gòu)和模型,下面這篇文章主要給大家介紹了關(guān)于如何使用yolov5輸出檢測到的目標(biāo)坐標(biāo)信息的相關(guān)資料,需要的朋友可以參考下

找到detect.py,在大概113行,找到plot_one_box

? ? ? ? ? ? ? ? # Write results
? ? ? ? ? ? ? ? for *xyxy, conf, cls in reversed(det):
? ? ? ? ? ? ? ? ? ? if save_txt: ?# Write to file
? ? ? ? ? ? ? ? ? ? ? ? xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() ?# normalized xywh
? ? ? ? ? ? ? ? ? ? ? ? with open(txt_path + '.txt', 'a') as f:
? ? ? ? ? ? ? ? ? ? ? ? ? ? f.write(('%g ' * 5 + '\n') % (cls, *xywh)) ?# label format

? ? ? ? ? ? ? ? ? ? if save_img or view_img: ?# Add bbox to image
? ? ? ? ? ? ? ? ? ? ? ? label = '%s %.2f' % (names[int(cls)], conf)
? ? ? ? ? ? ? ? ? ? ? ? plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=3)

ctr+鼠標(biāo)點擊,進入general.py,并自動定位到plot_one_box函數(shù),修改函數(shù)為

def plot_one_box(x, img, color=None, label=None, line_thickness=None):
    # Plots one bounding box on image img
    tl = line_thickness or round(0.002 * (img.shape[0] + img.shape[1]) / 2) + 1  # line/font thickness
    color = color or [random.randint(0, 255) for _ in range(3)]
    c1, c2 = (int(x[0]), int(x[1])), (int(x[2]), int(x[3]))
    cv2.rectangle(img, c1, c2, color, thickness=tl, lineType=cv2.LINE_AA)
    print("左上點的坐標(biāo)為:(" + str(c1[0]) + "," + str(c1[1]) + "),右下點的坐標(biāo)為(" + str(c2[0]) + "," + str(c2[1]) + ")")

即可輸出目標(biāo)坐標(biāo)信息了

附:python yolov5檢測模型返回坐標(biāo)的方法實例代碼

python yolov5檢測模型返回坐標(biāo)的方法 直接搜索以下代碼替換下 

 if save_img or view_img:  # Add bbox to image
                        label = f'{names[int(cls)]} {conf:.2f}'
                        c1, c2 = (int(xyxy[0]), int(xyxy[1])), (int(xyxy[2]), int(xyxy[3]))
                        print("左上點的坐標(biāo)為:(" + str(c1[0]) + "," + str(c1[1]) + "),右下點的坐標(biāo)為(" + str(c2[0]) + "," + str(c2[1]) + ")")
                        return [c1,c2]
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pt', help='model.pt path(s)')
parser.add_argument('--source', type=str, default='data/images', help='source') # file/folder, 0 for webcam
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--view-img', action='store_true', help='display results')
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
parser.add_argument('--augment', action='store_true', help='augmented inference')
parser.add_argument('--update', action='store_true', help='update all models')
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
parser.add_argument('--name', default='exp', help='save results to project/name')
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
opt = parser.parse_args()

check_requirements(exclude=('pycocotools', 'thop'))

opt.source='data/images/1/'
result=detect()
print('最終檢測結(jié)果:',result);

總結(jié)

到此這篇關(guān)于如何使用yolov5輸出檢測到的目標(biāo)坐標(biāo)信息的文章就介紹到這了,更多相關(guān)yolov5輸出目標(biāo)坐標(biāo)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python3搭建http服務(wù)器的實現(xiàn)代碼

    Python3搭建http服務(wù)器的實現(xiàn)代碼

    這篇文章主要介紹了Python3搭建http服務(wù)器的實現(xiàn)代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • Python利用shutil實現(xiàn)拷貝文件功能

    Python利用shutil實現(xiàn)拷貝文件功能

    shutil?是一個?Python?內(nèi)置模塊,該模塊對文件的復(fù)制、刪除和壓縮等操作都提供了非常方便的支持。本文將利用shutil實現(xiàn)拷貝文件功能,需要的可以參考一下
    2022-07-07
  • 解決Python Matplotlib繪圖數(shù)據(jù)點位置錯亂問題

    解決Python Matplotlib繪圖數(shù)據(jù)點位置錯亂問題

    這篇文章主要介紹了解決Python Matplotlib繪圖數(shù)據(jù)點位置錯亂問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-05-05
  • 實踐Python的爬蟲框架Scrapy來抓取豆瓣電影TOP250

    實踐Python的爬蟲框架Scrapy來抓取豆瓣電影TOP250

    這篇文章主要介紹了實踐Python的爬蟲框架Scrapy來抓取豆瓣電影TOP250的過程,文中的環(huán)境基于Windows操作系統(tǒng),需要的朋友可以參考下
    2016-01-01
  • 在Django中限制已登錄用戶的訪問的方法

    在Django中限制已登錄用戶的訪問的方法

    這篇文章主要介紹了在Django中限制已登錄用戶的訪問的方法,Django是最具人氣的Python開發(fā)框架,需要的朋友可以參考下
    2015-07-07
  • 從numpy數(shù)組中取出滿足條件的元素示例

    從numpy數(shù)組中取出滿足條件的元素示例

    今天小編就為大家分享一篇從numpy數(shù)組中取出滿足條件的元素示例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • python格式化輸出實例(居中、靠右及靠左對齊)

    python格式化輸出實例(居中、靠右及靠左對齊)

    所謂格式化輸出就是數(shù)據(jù)按照某種特殊的格式和要求進行輸出,下面這篇文章主要給大家介紹了關(guān)于python格式化輸出(居中、靠右及靠左對齊)的相關(guān)資料,文中介紹了format方式、其他擴展寫法以及'%'方式,需要的朋友可以參考下
    2022-04-04
  • python實現(xiàn)canny邊緣檢測

    python實現(xiàn)canny邊緣檢測

    本文主要講解了canny邊緣檢測原理:計算梯度幅值和方向、根據(jù)角度對幅值進行非極大值抑制、用雙閾值算法檢測和連接邊緣以及python 實現(xiàn)
    2020-09-09
  • Python中l(wèi)ogging日志的四個等級和使用

    Python中l(wèi)ogging日志的四個等級和使用

    這篇文章主要介紹了Python中l(wèi)ogging日志的四個等級和使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • 盤點20個Python數(shù)據(jù)科學(xué)庫神器打造數(shù)據(jù)魔法世界

    盤點20個Python數(shù)據(jù)科學(xué)庫神器打造數(shù)據(jù)魔法世界

    數(shù)據(jù)科學(xué)家和分析師常常使用?Python?來處理數(shù)據(jù)、進行分析和可視化,Python生態(tài)系統(tǒng)中有許多庫,但有一些庫是數(shù)據(jù)科學(xué)家日常工作中必不可少的,本文將深入介紹20個重要的Python?庫,包括示例代碼和用例
    2024-01-01

最新評論

莎车县| 崇义县| 鹿泉市| 京山县| 峨眉山市| 楚雄市| 连山| 建阳市| 苍山县| 安阳市| 和田市| 逊克县| 黔江区| 阜平县| 本溪| 榆社县| 莱芜市| 肃宁县| 嘉善县| 遵义市| 盈江县| 洛南县| 承德市| 普宁市| 衡阳市| 龙里县| 雷山县| 怀来县| 金沙县| 凭祥市| 麻城市| 万全县| 宣汉县| 松江区| 尖扎县| 宜州市| 东阿县| 沙湾县| 长宁县| 芮城县| 乐清市|