pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

python中的軌跡交叉點

Trajectory intersection in python(python中的軌跡交叉點)
本文介紹了python中的軌跡交叉點的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 tensorflow 和 python 檢測人員和車輛.我計算軌跡并使用卡爾曼濾波器預測它們,并擬合一條線來預測軌跡.

我的問題是如何找到兩條軌跡之間的交點和碰撞時間?

我嘗試了線到線的交點,但擬合線并不總是兩點線,而是一條折線.這是我的嘗試:

 detections = tracker.update(np.array(z_box))對于檢測中的 trk [0]:trk = trk.astype(np.int32)helpers.draw_box_label(img, trk, trk[4]) # 繪制邊界框centerCoord = (((trk[1] +trk[3])/2), (trk[0] + trk[2])/2)point_lists[trk[4]].append(centerCoord)x = [i[0] for i in point_lists[trk[4]]]y = [i[1] for i in point_lists[trk[4]]]p = np.polyfit(x, y, deg=1)y = p[1] + p[0] * np.array(x)擬合=列表(zip(x,y))cv2.polylines(img, np.int32([fitted]), False, color=(255, 0, 0))對于其他檢測[0]:其他 = other.astype(np.int32)if other[4] != trk[4]: # 檢查自己的 IDx2 = [i[0] for i in point_lists[other[4]]]y2 = [i[1] for i in point_lists[other[4]]]p2 = np.polyfit(x2, y2, deg=1)y2 = p2[1] + p2[0] * np.array(x2)other_fitted = list(zip(x2, y2))if(line_intersection(fitted, other_fitted)):打印(交叉點")別的:print("不是交集")

解決方案

這是一個有點寬泛的話題,所以我將只關注數學/物理部分,因為我感覺 CV/DIP部分已由你們兩個提問者(andre ahmed 和

如前所述,轉換為 3D(項目符號 #2)不是必需的,但它消除了非線性,因此以后可以使用簡單的線性插值/外插大大簡化了事情.

I'm detecting persons and vehicles using tensorflow and python. I calculate the trajectories and predict them using Kalman filter and I fit a line for predicting the trajectory.

My problem is how would I find the intersection and time of collision between the two trajectories ?

I tried line to line intersection but the fitted line is not always a two point lines, it's a polyline. Here is my attempt:

 detections = tracker.update(np.array(z_box))

    for trk in detections[0]:
            trk = trk.astype(np.int32)
            helpers.draw_box_label(img, trk, trk[4])  # Draw the bounding boxes on the
            centerCoord = (((trk[1] +trk[3]) / 2), (trk[0] + trk[2]) / 2)
            point_lists[trk[4]].append(centerCoord)
            x = [i[0] for i in point_lists[trk[4]]]
            y = [i[1] for i in point_lists[trk[4]]]
            p = np.polyfit(x, y, deg=1)
            y = p[1] + p[0] * np.array(x)
            fitted = list(zip(x, y))
            cv2.polylines(img, np.int32([fitted]), False, color=(255, 0, 0))
            for other in detections[0]:
                other = other.astype(np.int32)
                if other[4] != trk[4]: # check for self ID
                    x2 = [i[0] for i in point_lists[other[4]]]
                    y2 = [i[1] for i in point_lists[other[4]]]
                    p2 = np.polyfit(x2, y2, deg=1)
                    y2 = p2[1] + p2[0] * np.array(x2)
                    other_fitted = list(zip(x2, y2))
                    if(line_intersection(fitted, other_fitted)):
                        print("intersection")
                    else:
                        print("not intersection")

解決方案

this is a bit broader topic so I will focus only on the math/physics part as I got the feeling the CV/DIP part is already handled by both of you askers (andre ahmed, and chris burgees).

For simplicity I am assuming linear movement with constant speeds So how to do this:

  1. obtain 2D position of each object for 2 separate frames after known time dt

    so obtain the 2D center (or corner or whatever) position on the image for each object in question.

  2. convert them to 3D

    so using known camera parameters or known bacground info about the scene you can un-project the 2D position on screen into 3D relative position to camera. This will get rid of the non linear interpolations otherwise need if handled just like a 2D case.

    There are more option how to obtain 3D position depending on what you got at your disposal. For example like this:

    • Transformation of 3D objects related to vanishing points and horizon line
  3. obtaining actual speed of objects

    the speed vector is simply:

    vel = ( pos(t+dt) - pos(t) )/dt
    

    so simply subbstract positions of the same object from 2 consequent frames and divide by the framerate period (or interval between the frames used).

  4. test each 2 objects for collision

    this is the funny stuff Yes you can solve a system of inequalities like:

    | ( pos0 + vel0 * t ) - (pos1 + vel1 * t ) | <= threshold
    

    but there is a simpler way I used in here

    • Collision detection between 2 "linearly" moving objects in WGS84

    The idea is to compute t where the tested objects are closest together (if nearing towards eachother).

    so we can extrapolate the future position of each object like this:

    pos(t) = pos(t0) + vel*(t-t0)
    

    where t is actual time and t0 is some start time (for example t0=0).

    let assume we have 2 objects (pos0,vel0,pos1,vel1) we want to test so compute first 2 iterations of their distance so:

    pos0(0) = pos0;
    pos1(0) = pos1;
    dis0 = | pos1(0) - pos0(0) |
    
    pos0(dt) = pos0 + vel0*dt;
    pos1(dt) = pos1 + vel1*dt;
    dis1 = | pos1(dt) - pos0(dt) |
    

    where dt is some small enough time (to avoid skipping through collision). Now if (dis0<dis1) then the objects are mowing away so no collision, if (dis0==dis1) the objects are not moving or moving parallel to each and only if (dis0>dis1) the objects are nearing to each other so we can estimate:

    dis(t) = dis0 + (dis1-dis0)*t
    

    and the collision expects that dis(t)=0 so we can extrapolate again:

    0 = dis0 + (dis1-dis0)*t
    (dis0-dis1)*t = dis0 
    t = dis0 / (dis0-dis1)
    

    where t is the estimated time of collision. Of coarse all this handles all the movement as linear and extrapolates a lot so its not accurate but as you can do this for more consequent frames and the result will be more accurate with the time nearing to collision ... Also to be sure you should extrapolate the position of each object at the time of estimated collision to verify the result (if not colliding then the extrapolation was just numerical and the objects did not collide just was nearing to each for a time)

As mentioned before the conversion to 3D (bullet #2) is not necessary but it get rid of the nonlinearities so simple linear interpolation/extrapolation can be used later on greatly simplify things.

這篇關于python中的軌跡交叉點的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 蒸压釜-陶粒板隔墙板蒸压釜-山东鑫泰鑫智能装备有限公司 | 广西教师资格网-广西教师资格证考试网| 运动木地板_体育木地板_篮球馆木地板_舞台木地板-实木运动地板厂家 | 泉州陶瓷pc砖_园林景观砖厂家_石英砖地铺石价格 _福建暴风石英砖 | 干法制粒机_智能干法制粒机_张家港市开创机械制造有限公司 | 山东集装箱活动房|济南集装箱活动房-济南利森集装箱有限公司 | 股指期货-期货开户-交易手续费佣金加1分-保证金低-期货公司排名靠前-万利信息开户 | 天津热油泵_管道泵_天津高温热油泵-天津市金丰泰机械泵业有限公司【官方网站】 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 权威废金属|废塑料|废纸|废铜|废钢价格|再生资源回收行情报价中心-中废网 | 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 洗砂机械-球磨制砂机-洗沙制砂机械设备_青州冠诚重工机械有限公司 | 新密高铝耐火砖,轻质保温砖价格,浇注料厂家直销-郑州荣盛窑炉耐火材料有限公司 | 真空乳化机-灌装封尾机-首页-温州精灌 | 网站建设-高端品牌网站设计制作一站式定制_杭州APP/微信小程序开发运营-鼎易科技 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 挤出机_橡胶挤出机_塑料挤出机_胶片冷却机-河北伟源橡塑设备有限公司 | 球磨机,节能球磨机价格,水泥球磨机厂家,粉煤灰球磨机-吉宏机械制造有限公司 | 贴片电容-贴片电阻-二三极管-国巨|三星|风华贴片电容代理商-深圳伟哲电子 | 影合社-影视人的内容合作平台| 北京百度网站优化|北京网站建设公司-百谷网络科技 | 通用磨耗试验机-QUV耐候试验机|久宏实业百科 | 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 瓶盖扭矩仪(扭力值检测)-百科| 亚克力制品定制,上海嘉定有机玻璃加工制作生产厂家—官网 | 气象监测系统_气象传感器_微型气象仪_气象环境监测仪-山东风途物联网 | 气胀轴|气涨轴|安全夹头|安全卡盘|伺服纠偏系统厂家-天机传动 | 网带通过式抛丸机,,网带式打砂机,吊钩式,抛丸机,中山抛丸机生产厂家,江门抛丸机,佛山吊钩式,东莞抛丸机,中山市泰达自动化设备有限公司 | 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 活性炭-果壳木质煤质柱状粉状蜂窝活性炭厂家价格多少钱 | 深圳市万色印象美业有限公司| 磁力加热搅拌器-多工位|大功率|数显恒温磁力搅拌器-司乐仪器官网 | 示波器高压差分探头-国产电流探头厂家-南京桑润斯电子科技有限公司 | 袋式过滤器,自清洗过滤器,保安过滤器,篮式过滤器,气体过滤器,全自动过滤器,反冲洗过滤器,管道过滤器,无锡驰业环保科技有限公司 | 环氧铁红防锈漆_环氧漆_无溶剂环氧涂料_环氧防腐漆-华川涂料 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 皮带输送机-大倾角皮带输送机-皮带输送机厂家-河南坤威机械 | 济南网站策划设计_自适应网站制作_H5企业网站搭建_济南外贸网站制作公司_锐尚 | 河南砖机首页-全自动液压免烧砖机,小型砌块水泥砖机厂家[十年老厂] | 塑胶跑道施工-硅pu篮球场施工-塑胶网球场建造-丙烯酸球场材料厂家-奥茵 | SF6环境监测系统-接地环流在线监测装置-瑟恩实业 |