国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

YOLOv5+單目測(cè)距(python)

這篇具有很好參考價(jià)值的文章主要介紹了YOLOv5+單目測(cè)距(python)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

相關(guān)鏈接
1. YOLOV7 + 單目測(cè)距(python)
2. YOLOV5 + 單目跟蹤(python)
3. YOLOV7 + 單目跟蹤(python)
4. YOLOV5 + 雙目測(cè)距(python)
5. YOLOV7 + 雙目測(cè)距(python)
6. 具體實(shí)現(xiàn)效果已在Bilibili發(fā)布,點(diǎn)擊跳轉(zhuǎn)

本篇博文工程源碼下載
鏈接1:https://download.csdn.net/download/qq_45077760/87708260
鏈接2:https://github.com/up-up-up-up/yolov5_Monocular_ranging

更多有關(guān)單目(尺寸測(cè)量,跟蹤、碰撞檢測(cè)等)的文章請(qǐng)見:https://blog.csdn.net/qq_45077760/category_12312107.html文章來源地址http://www.zghlxwxcb.cn/news/detail-453784.html

1. 相關(guān)配置

系統(tǒng):win 10
YOLO版本:yolov5 6.1
拍攝視頻設(shè)備:安卓手機(jī)
電腦顯卡:NVIDIA 2080Ti(CPU也可以跑,GPU只是起到加速推理效果)

2. 測(cè)距原理

單目測(cè)距原理相較于雙目十分簡(jiǎn)單,無需進(jìn)行立體匹配,僅需利用下邊公式線性轉(zhuǎn)換即可:

                                        D = (F*W)/P

其中D是目標(biāo)到攝像機(jī)的距離, F是攝像機(jī)焦距(焦距需要自己進(jìn)行標(biāo)定獲?。? W是目標(biāo)的寬度或者高度(行人檢測(cè)一般以人的身高為基準(zhǔn)), P是指目標(biāo)在圖像中所占據(jù)的像素
YOLOv5+單目測(cè)距(python)
了解基本原理后,下邊就進(jìn)行實(shí)操階段

3. 相機(jī)標(biāo)定

3.1:標(biāo)定方法1

可以參考張學(xué)友標(biāo)定法獲取相機(jī)的焦距

3.2:標(biāo)定方法2

直接使用代碼獲得焦距,需要提前拍攝一個(gè)矩形物體,拍攝時(shí)候相機(jī)固定,距離被拍攝物體自行設(shè)定,并一直保持此距離,背景為純色,不要出現(xiàn)雜物;最后將拍攝的視頻用以下代碼檢測(cè):

import cv2

win_width = 1920
win_height = 1080
mid_width = int(win_width / 2)
mid_height = int(win_height / 2)

foc = 1990.0       # 根據(jù)教程調(diào)試相機(jī)焦距
real_wid = 9.05   # A4紙橫著的時(shí)候的寬度,視頻拍攝A4紙要橫拍,鏡頭橫,A4紙也橫
font = cv2.FONT_HERSHEY_SIMPLEX
w_ok = 1

capture = cv2.VideoCapture('5.mp4')
capture.set(3, win_width)
capture.set(4, win_height)

while (True):
    ret, frame = capture.read()
    # frame = cv2.flip(frame, 1)
    if ret == False:
        break

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    gray = cv2.GaussianBlur(gray, (5, 5), 0)
    ret, binary = cv2.threshold(gray, 140, 200, 60)    # 掃描不到紙張輪廓時(shí),要更改閾值,直到方框緊密框住紙張
    kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
    binary = cv2.dilate(binary, kernel, iterations=2)
    contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    # cv2.drawContours(frame, contours, -1, (0, 255, 0), 2)    # 查看所檢測(cè)到的輪框
    for c in contours:
        if cv2.contourArea(c) < 1000:  # 對(duì)于矩形區(qū)域,只顯示大于給定閾值的輪廓,所以一些微小的變化不會(huì)顯示。對(duì)于光照不變和噪聲低的攝像頭可不設(shè)定輪廓最小尺寸的閾值
            continue

        x, y, w, h = cv2.boundingRect(c)  # 該函數(shù)計(jì)算矩形的邊界框

        if x > mid_width or y > mid_height:
            continue
        if (x + w) < mid_width or (y + h) < mid_height:
            continue
        if h > w:
            continue
        if x == 0 or y == 0:
            continue
        if x == win_width or y == win_height:
            continue

        w_ok = w
        cv2.rectangle(frame, (x + 1, y + 1), (x + w_ok - 1, y + h - 1), (0, 255, 0), 2)

    dis_inch = (real_wid * foc) / (w_ok - 2)
    dis_cm = dis_inch * 2.54
    # os.system("cls")
    # print("Distance : ", dis_cm, "cm")
    frame = cv2.putText(frame, "%.2fcm" % (dis_cm), (5, 25), font, 0.8, (0, 255, 0), 2)
    frame = cv2.putText(frame, "+", (mid_width, mid_height), font, 1.0, (0, 255, 0), 2)

    cv2.namedWindow('res', 0)
    cv2.namedWindow('gray', 0)
    cv2.resizeWindow('res', win_width, win_height)
    cv2.resizeWindow('gray', win_width, win_height)
    cv2.imshow('res', frame)
    cv2.imshow('gray', binary)

    c = cv2.waitKey(40)
    if c == 27:    # 按退出鍵esc關(guān)閉窗口
        break

cv2.destroyAllWindows()

反復(fù)調(diào)節(jié) ret, binary = cv2.threshold(gray, 140, 200, 60)這一行里邊的三個(gè)參數(shù),直到線條緊緊包裹住你所拍攝視頻的物體,然后調(diào)整相機(jī)焦距直到左上角距離和你拍攝視頻時(shí)相機(jī)到物體的距離接近為止
YOLOv5+單目測(cè)距(python)
然后將相機(jī)焦距寫進(jìn)測(cè)距代碼distance.py文件里,這里行人用高度表示,根據(jù)公式 D = (F*W)/P,知道相機(jī)焦距F、行人的高度66.9(單位英寸→170cm/2.54)、像素點(diǎn)距離 h,即可求出相機(jī)到物體距離D。 這里用到h-2是因?yàn)榭虻纳舷逻吔缦袼攸c(diǎn)不接觸物體

foc = 1990.0        # 鏡頭焦距
real_hight_person = 66.9   # 行人高度
real_hight_car = 57.08      # 轎車高度

# 自定義函數(shù),單目測(cè)距
def person_distance(h):
    dis_inch = (real_hight_person * foc) / (h - 2)
    dis_cm = dis_inch * 2.54
    dis_cm = int(dis_cm)
    dis_m = dis_cm/100
    return dis_m

def car_distance(h):
    dis_inch = (real_hight_car * foc) / (h - 2)
    dis_cm = dis_inch * 2.54
    dis_cm = int(dis_cm)
    dis_m = dis_cm/100
    return dis_m

4. 相機(jī)測(cè)距

4.1 測(cè)距添加

主要是把測(cè)距部分加在了畫框附近,首先提取邊框的像素點(diǎn)坐標(biāo),然后計(jì)算邊框像素點(diǎn)高度,在根據(jù) 公式 D = (F*W)/P 計(jì)算目標(biāo)距離

 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
         line = (cls, *xywh, conf) if save_conf else (cls, *xywh)  # label format
         with open(txt_path + '.txt', 'a') as f:
             f.write(('%g ' * len(line)).rstrip() % line + '\n')

     if save_img or save_crop or view_img:  # Add bbox to image
         x1 = int(xyxy[0])   #獲取四個(gè)邊框坐標(biāo)
         y1 = int(xyxy[1])
         x2 = int(xyxy[2])
         y2 = int(xyxy[3])
         h = y2-y1
         if names[int(cls)] == "person":
             c = int(cls)  # integer class  整數(shù)類 1111111111
             label = None if hide_labels else (
                 names[c] if hide_conf else f'{names[c]} {conf:.2f}')  # 111
             dis_m = person_distance(h)   # 調(diào)用函數(shù),計(jì)算行人實(shí)際高度
             label += f'  {dis_m}m'       # 將行人距離顯示寫在標(biāo)簽后
             txt = '{0}'.format(label)
             annotator.box_label(xyxy, txt, color=colors(c, True))
         if names[int(cls)] == "car":
             c = int(cls)  # integer class  整數(shù)類 1111111111
             label = None if hide_labels else (
                 names[c] if hide_conf else f'{names[c]} {conf:.2f}')  # 111
             dis_m = car_distance(h)      # 調(diào)用函數(shù),計(jì)算汽車實(shí)際高度
             label += f'  {dis_m}m'       # 將汽車距離顯示寫在標(biāo)簽后
             txt = '{0}'.format(label)
             annotator.box_label(xyxy, txt, color=colors(c, True))

         if save_crop:
             save_one_box(xyxy, imc, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)

4.2 細(xì)節(jié)修改(可忽略)

到上述步驟就已經(jīng)實(shí)現(xiàn)了單目測(cè)距過程,下邊是一些小細(xì)節(jié)修改,可以不看
為了實(shí)時(shí)顯示畫面,對(duì)運(yùn)行的py文件點(diǎn)擊編輯配置,在形參那里輸入–view-img --save-txt
YOLOv5+單目測(cè)距(python)
但實(shí)時(shí)顯示畫面太大,我們對(duì)顯示部分做了修改,這部分也可以不要,具體是把代碼

if view_img:
      cv2.imshow(str(p), im0)
      cv2.waitKey(1)  # 1 millisecond

替換成

if view_img:
     cv2.namedWindow("Webcam", cv2.WINDOW_NORMAL)
     cv2.resizeWindow("Webcam", 1280, 720)
     cv2.moveWindow("Webcam", 0, 100)
     cv2.imshow("Webcam", im0)
     cv2.waitKey(1)

4.3 主代碼

# YOLOv5 ?? by Ultralytics, GPL-3.0 license
"""
Run inference on images, videos, directories, streams, etc.

Usage - sources:
    $ python path/to/detect.py --weights yolov5s.pt --source 0              # webcam
                                                             img.jpg        # image
                                                             vid.mp4        # video
                                                             path/          # directory
                                                             path/*.jpg     # glob
                                                             'https://youtu.be/Zgi9g1ksQHc'  # YouTube
                                                             'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream

Usage - formats:
    $ python path/to/detect.py --weights yolov5s.pt                 # PyTorch
                                         yolov5s.torchscript        # TorchScript
                                         yolov5s.onnx               # ONNX Runtime or OpenCV DNN with --dnn
                                         yolov5s.xml                # OpenVINO
                                         yolov5s.engine             # TensorRT
                                         yolov5s.mlmodel            # CoreML (MacOS-only)
                                         yolov5s_saved_model        # TensorFlow SavedModel
                                         yolov5s.pb                 # TensorFlow GraphDef
                                         yolov5s.tflite             # TensorFlow Lite
                                         yolov5s_edgetpu.tflite     # TensorFlow Edge TPU
"""

import argparse
import os
import sys
from pathlib import Path

import cv2
import torch
import torch.backends.cudnn as cudnn

FILE = Path(__file__).resolve()
ROOT = FILE.parents[0]  # YOLOv5 root directory
if str(ROOT) not in sys.path:
    sys.path.append(str(ROOT))  # add ROOT to PATH
ROOT = Path(os.path.relpath(ROOT, Path.cwd()))  # relative

from models.common import DetectMultiBackend
from utils.datasets import IMG_FORMATS, VID_FORMATS, LoadImages, LoadStreams
from utils.general import (LOGGER, check_file, check_img_size, check_imshow, check_requirements, colorstr,
                           increment_path, non_max_suppression, print_args, scale_coords, strip_optimizer, xyxy2xywh)
from utils.plots import Annotator, colors, save_one_box
from utils.torch_utils import select_device, time_sync
from distance import person_distance,car_distance

@torch.no_grad()
def run(weights=ROOT / 'yolov5s.pt',  # model.pt path(s)
        source=ROOT / 'data/images',  # file/dir/URL/glob, 0 for webcam
        data=ROOT / 'data/coco128.yaml',  # dataset.yaml path
        imgsz=(640, 640),  # inference size (height, width)
        conf_thres=0.25,  # confidence threshold
        iou_thres=0.45,  # NMS IOU threshold
        max_det=1000,  # maximum detections per image
        device='',  # cuda device, i.e. 0 or 0,1,2,3 or cpu
        view_img=False,  # show results
        save_txt=False,  # save results to *.txt
        save_conf=False,  # save confidences in --save-txt labels
        save_crop=False,  # save cropped prediction boxes
        nosave=False,  # do not save images/videos
        classes=None,  # filter by class: --class 0, or --class 0 2 3
        agnostic_nms=False,  # class-agnostic NMS
        augment=False,  # augmented inference
        visualize=False,  # visualize features
        update=False,  # update all models
        project=ROOT / 'runs/detect',  # save results to project/name
        name='exp',  # save results to project/name
        exist_ok=False,  # existing project/name ok, do not increment
        line_thickness=3,  # bounding box thickness (pixels)
        hide_labels=False,  # hide labels
        hide_conf=False,  # hide confidences
        half=False,  # use FP16 half-precision inference
        dnn=False,  # use OpenCV DNN for ONNX inference
        ):
    source = str(source)
    save_img = not nosave and not source.endswith('.txt')  # save inference images
    is_file = Path(source).suffix[1:] in (IMG_FORMATS + VID_FORMATS)
    is_url = source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://'))
    webcam = source.isnumeric() or source.endswith('.txt') or (is_url and not is_file)
    if is_url and is_file:
        source = check_file(source)  # download

    # Directories
    save_dir = increment_path(Path(project) / name, exist_ok=exist_ok)  # increment run
    (save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True)  # make dir

    # Load model
    device = select_device(device)
    model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data)
    stride, names, pt, jit, onnx, engine = model.stride, model.names, model.pt, model.jit, model.onnx, model.engine
    imgsz = check_img_size(imgsz, s=stride)  # check image size

    # Half
    half &= (pt or jit or onnx or engine) and device.type != 'cpu'  # FP16 supported on limited backends with CUDA
    if pt or jit:
        model.model.half() if half else model.model.float()

    # Dataloader
    if webcam:
        view_img = check_imshow()
        cudnn.benchmark = True  # set True to speed up constant image size inference
        dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt)
        bs = len(dataset)  # batch_size
    else:
        dataset = LoadImages(source, img_size=imgsz, stride=stride, auto=pt)
        bs = 1  # batch_size
    vid_path, vid_writer = [None] * bs, [None] * bs

    # Run inference
    model.warmup(imgsz=(1 if pt else bs, 3, *imgsz), half=half)  # warmup
    dt, seen = [0.0, 0.0, 0.0], 0
    for path, im, im0s, vid_cap, s in dataset:
        t1 = time_sync()
        im = torch.from_numpy(im).to(device)
        im = im.half() if half else im.float()  # uint8 to fp16/32
        im /= 255  # 0 - 255 to 0.0 - 1.0
        if len(im.shape) == 3:
            im = im[None]  # expand for batch dim
        t2 = time_sync()
        dt[0] += t2 - t1

        # Inference
        visualize = increment_path(save_dir / Path(path).stem, mkdir=True) if visualize else False
        pred = model(im, augment=augment, visualize=visualize)
        t3 = time_sync()
        dt[1] += t3 - t2

        # NMS
        pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)
        dt[2] += time_sync() - t3

        # Second-stage classifier (optional)
        # pred = utils.general.apply_classifier(pred, classifier_model, im, im0s)

        # Process predictions
        for i, det in enumerate(pred):  # per image
            seen += 1
            if webcam:  # batch_size >= 1
                p, im0, frame = path[i], im0s[i].copy(), dataset.count
                s += f'{i}: '
            else:
                p, im0, frame = path, im0s.copy(), getattr(dataset, 'frame', 0)

            p = Path(p)  # to Path
            save_path = str(save_dir / p.name)  # im.jpg
            txt_path = str(save_dir / 'labels' / p.stem) + ('' if dataset.mode == 'image' else f'_{frame}')  # im.txt
            s += '%gx%g ' % im.shape[2:]  # print string
            gn = torch.tensor(im0.shape)[[1, 0, 1, 0]]  # normalization gain whwh
            imc = im0.copy() if save_crop else im0  # for save_crop
            annotator = Annotator(im0, line_width=line_thickness, example=str(names))
            if len(det):
                # Rescale boxes from img_size to im0 size
                det[:, :4] = scale_coords(im.shape[2:], det[:, :4], im0.shape).round()

                # Print results
                for c in det[:, -1].unique():
                    n = (det[:, -1] == c).sum()  # detections per class
                    s += f"{n} {names[int(c)]}{'s' * (n > 1)}, "  # add to string

                # 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
                        line = (cls, *xywh, conf) if save_conf else (cls, *xywh)  # label format
                        with open(txt_path + '.txt', 'a') as f:
                            f.write(('%g ' * len(line)).rstrip() % line + '\n')

                    if save_img or save_crop or view_img:  # Add bbox to image
                        x1 = int(xyxy[0])
                        y1 = int(xyxy[1])
                        x2 = int(xyxy[2])
                        y2 = int(xyxy[3])
                        h = y2-y1
                        if names[int(cls)] == "person":
                            c = int(cls)  # integer class  整數(shù)類 1111111111
                            label = None if hide_labels else (
                                names[c] if hide_conf else f'{names[c]} {conf:.2f}')  # 111
                            dis_m = person_distance(h)
                            label += f'  {dis_m}m'
                            txt = '{0}'.format(label)
                            # annotator.box_label(xyxy, txt, color=(255, 0, 255))
                            annotator.box_label(xyxy, txt, color=colors(c, True))
                        if names[int(cls)] == "car":
                            c = int(cls)  # integer class  整數(shù)類 1111111111
                            label = None if hide_labels else (
                                names[c] if hide_conf else f'{names[c]} {conf:.2f}')  # 111
                            dis_m = car_distance(h)
                            label += f'  {dis_m}m'
                            txt = '{0}'.format(label)
                            # annotator.box_label(xyxy, txt, color=(255, 0, 255))
                            annotator.box_label(xyxy, txt, color=colors(c, True))

                        if save_crop:
                            save_one_box(xyxy, imc, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)

            # Stream results
            im0 = annotator.result()
            '''if view_img:
                cv2.imshow(str(p), im0)
                cv2.waitKey(1)  # 1 millisecond'''
            if view_img:
                cv2.namedWindow("Webcam", cv2.WINDOW_NORMAL)
                cv2.resizeWindow("Webcam", 1280, 720)
                cv2.moveWindow("Webcam", 0, 100)
                cv2.imshow("Webcam", im0)
                cv2.waitKey(1)

            # Save results (image with detections)
            if save_img:
                if dataset.mode == 'image':
                    cv2.imwrite(save_path, im0)
                else:  # 'video' or 'stream'
                    if vid_path[i] != save_path:  # new video
                        vid_path[i] = save_path
                        if isinstance(vid_writer[i], cv2.VideoWriter):
                            vid_writer[i].release()  # release previous video writer
                        if vid_cap:  # video
                            fps = vid_cap.get(cv2.CAP_PROP_FPS)
                            w = int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
                            h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
                        else:  # stream
                            fps, w, h = 30, im0.shape[1], im0.shape[0]
                        save_path = str(Path(save_path).with_suffix('.mp4'))  # force *.mp4 suffix on results videos
                        vid_writer[i] = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
                    vid_writer[i].write(im0)

        # Print time (inference-only)
        LOGGER.info(f'{s}Done. ({t3 - t2:.3f}s)')

    # Print results
    t = tuple(x / seen * 1E3 for x in dt)  # speeds per image
    LOGGER.info(f'Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {(1, 3, *imgsz)}' % t)
    if save_txt or save_img:
        s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
        LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}{s}")
    if update:
        strip_optimizer(weights)  # update model (to fix SourceChangeWarning)


def parse_opt():
    parser = argparse.ArgumentParser()
    parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)')
    parser.add_argument('--source', type=str, default=ROOT / 'data/images/1.mp4', help='file/dir/URL/glob, 0 for webcam')
    parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='(optional) dataset.yaml path')
    parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
    parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')
    parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')
    parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image')
    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='show 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('--save-crop', action='store_true', help='save cropped prediction boxes')
    parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
    parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 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('--visualize', action='store_true', help='visualize features')
    parser.add_argument('--update', action='store_true', help='update all models')
    parser.add_argument('--project', default=ROOT / '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')
    parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
    parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
    parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
    parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')
    parser.add_argument('--dnn', action='store_true', help='use OpenCV DNN for ONNX inference')
    opt = parser.parse_args()
    opt.imgsz *= 2 if len(opt.imgsz) == 1 else 1  # expand
    print_args(FILE.stem, opt)
    return opt


def main(opt):
    check_requirements(exclude=('tensorboard', 'thop'))
    run(**vars(opt))


if __name__ == "__main__":
    opt = parse_opt()
    main(opt)

5. 實(shí)驗(yàn)效果

實(shí)驗(yàn)效果如下

更多有關(guān)單目(尺寸測(cè)量,跟蹤、碰撞檢測(cè)等)的文章請(qǐng)見:https://blog.csdn.net/qq_45077760/category_12312107.html

到了這里,關(guān)于YOLOv5+單目測(cè)距(python)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • yolov5車道線檢測(cè)+測(cè)距(碰撞檢測(cè))

    相關(guān)鏈接 1. 基于yolov5的車道線檢測(cè)及安卓部署 2. YOLOv5#

    2024年02月08日
    瀏覽(24)
  • YOLOv5車輛測(cè)距實(shí)踐:利用目標(biāo)檢測(cè)技術(shù)實(shí)現(xiàn)車輛距離估算

    YOLOv5目標(biāo)檢測(cè)技術(shù)進(jìn)行車輛測(cè)距。相信大家對(duì)YOLOv5已經(jīng)有所了解,它是一種快速且準(zhǔn)確的目標(biāo)檢測(cè)算法。接下來,讓我們一起探討如何通過YOLOv5實(shí)現(xiàn)車輛距離估算。這次的實(shí)踐將分為以下幾個(gè)步驟: 安裝所需庫和工具 數(shù)據(jù)準(zhǔn)備 模型訓(xùn)練 距離估算 可視化結(jié)果 優(yōu)化 1. 安裝所需

    2024年02月02日
    瀏覽(21)
  • yolov8/yolov5-車輛測(cè)距+前車碰撞預(yù)警(追尾預(yù)警)+車輛檢測(cè)識(shí)別+車輛跟蹤測(cè)速(算法-畢業(yè)設(shè)計(jì))

    yolov8/yolov5-車輛測(cè)距+前車碰撞預(yù)警(追尾預(yù)警)+車輛檢測(cè)識(shí)別+車輛跟蹤測(cè)速(算法-畢業(yè)設(shè)計(jì))

    本項(xiàng)目效果展示視頻: https://www.bilibili.com/video/BV14d4y177vE/?spm_id_from=333.999.0.0vd_source=8c532ded7c7c9041f04e35940d11fdae 1、本項(xiàng)目通過yolov8/yolov7/yolov5和deepsort實(shí)現(xiàn)了一個(gè)自動(dòng)駕駛領(lǐng)域的追尾前車碰撞預(yù)警系統(tǒng),可為一些同學(xué)的課設(shè)、大作業(yè)等提供參考。分別實(shí)現(xiàn)了自行車、汽車、摩托車

    2024年02月06日
    瀏覽(31)
  • 單目相機(jī)測(cè)距(3米范圍內(nèi))二維碼實(shí)現(xiàn)方案(python代碼 僅僅依賴opencv)

    單目相機(jī)測(cè)距(3米范圍內(nèi))二維碼實(shí)現(xiàn)方案(python代碼 僅僅依賴opencv)

    總體思路:先通過opencv 識(shí)別二維碼的的四個(gè)像素角位置,然后把二維碼的物理位置設(shè)置為 ,相當(dāng)于這是一個(gè)任意找的物體上的四個(gè)點(diǎn),對(duì)應(yīng)的我們找到了在圖像中對(duì)應(yīng)的像素坐標(biāo)。這就解決了世界坐標(biāo)系與像素坐標(biāo)系之間的對(duì)應(yīng)問題,然后再通過PNP求解的方式,就可以通過

    2024年02月04日
    瀏覽(22)
  • yolov8/yolov7/yolov5-車輛測(cè)距+前車碰撞預(yù)警(追尾預(yù)警)+車輛檢測(cè)識(shí)別+車輛跟蹤測(cè)速(算法-畢業(yè)設(shè)計(jì))

    yolov8/yolov7/yolov5-車輛測(cè)距+前車碰撞預(yù)警(追尾預(yù)警)+車輛檢測(cè)識(shí)別+車輛跟蹤測(cè)速(算法-畢業(yè)設(shè)計(jì))

    本項(xiàng)目效果展示視頻: https://www.bilibili.com/video/BV14d4y177vE/?spm_id_from=333.999.0.0vd_source=8c532ded7c7c9041f04e35940d11fdae 1、本項(xiàng)目通過yolov8/yolov7/yolov5和deepsort實(shí)現(xiàn)了一個(gè)自動(dòng)駕駛領(lǐng)域的追尾前車碰撞預(yù)警系統(tǒng),可為一些同學(xué)的課設(shè)、大作業(yè)等提供參考。分別實(shí)現(xiàn)了自行車、汽車、摩托車

    2024年02月04日
    瀏覽(31)
  • 項(xiàng)目設(shè)計(jì):YOLOv5目標(biāo)檢測(cè)+機(jī)構(gòu)光相機(jī)(intel d455和d435i)測(cè)距

    項(xiàng)目設(shè)計(jì):YOLOv5目標(biāo)檢測(cè)+機(jī)構(gòu)光相機(jī)(intel d455和d435i)測(cè)距

    1.1??Intel D455 Intel D455 是一款基于結(jié)構(gòu)光(Structured Light)技術(shù)的深度相機(jī)。 與ToF相機(jī)不同,結(jié)構(gòu)光相機(jī)使用另一種方法來獲取物體的深度信息。它通過投射可視光譜中的紅外結(jié)構(gòu)光圖案,然后從被拍攝物體表面反射回來的圖案重建出其三維形狀和深度信息。 Intel D455 深度相機(jī)

    2024年02月08日
    瀏覽(33)
  • 【單目測(cè)距】3D檢測(cè)框測(cè)距

    【單目測(cè)距】3D檢測(cè)框測(cè)距

    3D 檢測(cè)模型用的 fcos3D。 如何對(duì) 3D 框測(cè)距 ? 3D 檢測(cè)框測(cè)距對(duì)比 2D 檢測(cè)框測(cè)距優(yōu)勢(shì)在哪? (1) 橫向測(cè)距偏差。當(dāng)目標(biāo)有一定傾斜角度時(shí),尤其近距離目標(biāo)。如下圖id = 0目標(biāo)白車,如果是2D檢測(cè)框測(cè)距,會(huì)誤認(rèn)為車尾在點(diǎn) A 處,而實(shí)際應(yīng)該在圖像最左側(cè)外部 (2) 無法測(cè)量目標(biāo)的本身

    2024年01月23日
    瀏覽(19)
  • 單目測(cè)距(yolo目標(biāo)檢測(cè)+標(biāo)定+測(cè)距代碼)

    單目測(cè)距(yolo目標(biāo)檢測(cè)+標(biāo)定+測(cè)距代碼)

    實(shí)時(shí)感知本車周圍物體的距離對(duì)高級(jí)駕駛輔助系統(tǒng)具有重要意義,當(dāng)判定物體與本車距離小于安全距離時(shí)便采取主動(dòng)剎車等安全輔助功能,這將進(jìn)一步提升汽車的安全性能并減少碰撞的發(fā)生。上一章本文完成了目標(biāo)檢測(cè)任務(wù),接下來需要對(duì)檢測(cè)出來的物體進(jìn)行距離測(cè)量。首先

    2023年04月17日
    瀏覽(19)
  • 單目測(cè)距終于擺脫了參考物,實(shí)現(xiàn)單目測(cè)距、檢測(cè)物體大小,增加了實(shí)驗(yàn)數(shù)據(jù),效果很好

    單目測(cè)距終于擺脫了參考物,實(shí)現(xiàn)單目測(cè)距、檢測(cè)物體大小,增加了實(shí)驗(yàn)數(shù)據(jù),效果很好

    ??版權(quán):本文由作者【 Brson.AI 】原創(chuàng)首發(fā)、各位讀者大大敬請(qǐng)查閱、感謝三連?????? ??聲明:作為大腦的兒子AI,專注于分享更多AI知識(shí)干貨給大家?? ??文章若有錯(cuò)誤之處請(qǐng)大方指出,我會(huì)認(rèn)真改正,謝謝各位看官?? ??最近一直在搗騰關(guān)于 單目測(cè)距 和 檢測(cè)物體大小

    2024年02月06日
    瀏覽(25)
  • 單目測(cè)距實(shí)戰(zhàn)

    單目測(cè)距實(shí)戰(zhàn)

    單目測(cè)距是通過使用單個(gè)攝像頭捕獲的圖像信息倆估計(jì)物體的距離。這是一種在計(jì)算機(jī)領(lǐng)域廣泛研究的問題,并且困難之處在于從2d圖像中恢復(fù)3d信息。 單目測(cè)距常用的或者是實(shí)用方法是相似三角形法。 相似三角形法:假設(shè)有一個(gè)寬度為w的目標(biāo)的或者物體。然后,我們用相機(jī)

    2024年01月25日
    瀏覽(13)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包