Published: Nov 18, 2021
Duration: 00:05:19
Category: Science & Technology
Trending searches: predictit
hello guys this is farzad chochman from visual computer.net and in this tutorial we are going to use colon filter and also opencv to predict the motion of some object let me show you a video as you may see in this video there is a red object in my hand the center point of the object is indicated by a yellow circle and there is a blue circle that predicts the motion of this yellow circle we used kalman filter for this job ok let me explain it step by step for you we use opencv and numpy and also for detection of a point in front of this object i used a very simple procedure by using the contours it is very easy you can easily find it by a search in internet but step by step you can see it here i don't cover this part please find it yourself but the code is like this and i imported this file to my job and i also defined a column filter class here as you see uh here kf is a column filter and it it is cv2 dot column filter four and two comma filter is a part of opencv as you see here and it has a a part which is measurement matrix and it is numpy array of float 32 as you may see here and a transition matrix is needed here as you see here and it is also also float32 okay we defined a predict a function here as you see and it is very simple it returns us x and y of a predicted point uh uses kalman filter okay we very easily uh load the karna filter in a kf variable and the red point detector in object od variable and i also uh used alt v id out video to write my job uh in a separated video format of mp4 here the while loop starts and the frame is read frame by frame we use the red point b boxes and object detector to detect the center point of this object and it is saved in x y x two and y two this is the center point of this object okay and after that the center point is calculated by c x and c y okay but for the prediction we use this c x and c y and the history of it by using the uh kalman filter prediction okay we passed cx and cy into the column filter and it predicts a point uh we use circle of opencv to run to draw us a yellow circle this is the yellow the yellow color and it is filled and also we use uh opencv circle to draw us a circle which is below here okay and we show it uh in the monitor okay let us run our job as you see here the blue point predicts the motion of the yellow point whenever it goes the prediction is done okay thank you very much guys hope to see you soon bye