OpenCV Tutorial: Real-Time Object Tracking Without Colour

Share
Embed
  • Published on Jan 28, 2014
  • Found this video useful? Donations are very much appreciated, thank you.
    PayPal: www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X24GRDPJ4PZHW&lc=CA&item_name=OpenCV%20Tutorials&currency_code=CAD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
    BTC: 18Hysn4veDCCkhKtkqBiigJ8HfhjkzWDta
    Ethereum: 0x97267a8d15d35012FaA9B07be4ac5Ff935876E10
    Business Inquiries and Tutoring rates email kyle.hounslow@gmail.com
    In this tutorial we will look at real-time object tracking using the method of sequential images. This allows us to track objects without the use of colour filtering. We code in C++ using Visual Studio 2010.
    Start by downloading the following zip file: www.dropbox.com/s/qhkwml7cu75lar2/motionTrackingTutorial.zip?dl=0
    If you got stuck anywhere in this tutorial you can download the final source code from here:
    www.dropbox.com/s/67gtew15zn2rpun/motionTracking.cpp?dl=0

Comments • 239

  • David Duarte
    David Duarte 6 months ago +1

    2019 and this is the best object tracking tutorial i have found so far! Thank you very much, great video!

  • Dr. Ömür GÜNALDI
    Dr. Ömür GÜNALDI 6 months ago

    Congragulation Kyle Hounslow. How can I show position of 3D objects while tracking?

  • omkaram rangasesha
    omkaram rangasesha 10 months ago

    please
    anybody can help me to multiple objects and not by using the filtered color for multiple object like apple,cheery example of his videos

  • Nisa Ulfahayati
    Nisa Ulfahayati 11 months ago

    thanks very much Kyle, it helped me a lot. I'm still watch it on 2018. LOL

  • zultan dimitry
    zultan dimitry Year ago

    im looking for the same but in python do you know were i can get the code ?

  • Sami Ullah Shah
    Sami Ullah Shah Year ago

    really impressive, i am trying to use your logic but in c#. if you have any clue then you can share with me thanks.

  • ravinder rikhi
    ravinder rikhi Year ago

    Getting this error when trying to access my webcam using OpenCv. Can anybody help ?
    GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed

  • Mike BORYS
    Mike BORYS Year ago

    Thanks Kyle, everybody knows how to reduce the delay?

  • Anas Ait Aomar
    Anas Ait Aomar Year ago

    Hi ,i really enjoy your videos i'm new to opencv and c++ ,i've used your code and i want to store this cordinates in a text file

  • ADEEL MUHAMMAD
    ADEEL MUHAMMAD Year ago

    I want to use ZED camera, may you guide me how to connect ZED stereo vision
    camera with this code?

    • Rebeccah Kahn
      Rebeccah Kahn Year ago

      This is what I want to do! Except I would be using a stereo rig with 2 GoPro Heros. ZED cameras have SDK, perhaps find some research on C++ coding for SDK compatibility?

  • Sweta Dwivedi
    Sweta Dwivedi Year ago

    I love your teaching style. Organized material and easy to follow! Subscribed.

  • Trần Bảo Long

    thank you so much for these videos tutorial

  • Simon Prell
    Simon Prell 2 years ago

    Hi is IT possibe to use this when the camera is moving ?

  • ibrahim ethem gürsoy
    ibrahim ethem gürsoy 2 years ago

    This is my code:
    github.com/iegrsy/Object-Counting
    Good luck..

  • Trương Lê Văn
    Trương Lê Văn 2 years ago

    If some one want to detect human and control camera tracking come to see my video and get the source code: ru-clip.net/video/TYfssug9PYY/video.html

  • noob code
    noob code 2 years ago

    sir,please add so that cout and cin could work. :)

  • Cliff Batalla
    Cliff Batalla 2 years ago

    When i click "t" the program stops but doesn't display any build problems
    debug mode is working when "d" is pressed

  • Suhadra Pattra
    Suhadra Pattra 2 years ago

    bro , is your source code just for tracking a ball ? or it can track other objects base on the database you input to the code ?

  • epiclapser
    epiclapser 2 years ago

    +Kyle Hounslow
    So apparently eroding the output of the absdiff function before passing it through the blur reduces allot of noise. My webcam has allot of noise in its image so if anyone else is trying to write this code with a crappy webcam just erode before the blur.

  • Mohamed Aouled Issa
    Mohamed Aouled Issa 2 years ago

    I have implemented your code and I came up with a quick fix to get only one object (tennis ball) after thresholding. The trick is to substract grayImage1 from grayImage2 (grayImage2-grayImage1) before thresholding which means that the differenceImage should be : differenceImage = grayImage2-grayImage1;
    This will produce only one ball in the frame.
    Thanks

  • SadKo2U
    SadKo2U 2 years ago +2

    Hey Kyle! The link is not working! Where could I get the code?

    • Kyle Hounslow
      Kyle Hounslow  2 years ago +1

      Hi @SadKo2U, The links are now updated. My apogolies!
      Kyle

  • sahar alaa
    sahar alaa 2 years ago

    thank you very much for your effort ^_^

  • Hassan Fida
    Hassan Fida 2 years ago

    Hi Mr Kyle! Can you please provide me your email so I may ask you some questions

  • Enrique Ortiz
    Enrique Ortiz 2 years ago

    hello, great tutorial, I tried runnin git, but got the following error:
    file f:\\dd\vctools\crt\crtw32\convert\isctype.c
    line: 68
    Expression: c>=-1&&C

  • Muhd Azrin Yusof
    Muhd Azrin Yusof 3 years ago

    Hi, can i have your email ? Need something urgent to discuss

  • alireza ghaderi
    alireza ghaderi 3 years ago

    Great Man it was great...
    you have any idea for moving camera? i want to have a moving camera forexample on a UAV and then detect car motions from high altitude.

    • Saad Uzair
      Saad Uzair 2 years ago

      you got your answer for moving camera ?
      if you get it it please let me know. i got stucked in the same case

  • نٌےـوِنٌےـٱيّےـة ИÂИØṩĦÂ

    hello^^
    ,,my project this year about object track with opencv+image processing
    so,i need some help
    can you help me?
    just give me the resourses such as book,sites,etc about how i can dealing with object track!!

  • Dmitry Fatiev
    Dmitry Fatiev 3 years ago

    I don't know if you still answer the comments here, but - what if I have moving people in the frame as well? They won't occlude the ball when it's position matters, but what would you recommend to disregard any undesired "diff" artifacts?

    • Maurizio Ingrassia
      Maurizio Ingrassia 3 years ago

      Indeed this solution (like the 99% of the youtube video) is not robust. Any minimal light condition change would screw everything

  • nihat nihat
    nihat nihat 3 years ago

    Hi there,
    I trying to do this project as I am watching your tutorial step by step but I am stuck at adding existing property sheet the file called 'OPENCV_DEBUG247' . I could not get it anywhere. Could you share it with me by any chance?
    Best Regards,

    • SnowySeraph
      SnowySeraph 3 years ago

      He builds it in another one of his tutorial videos. He basically assumes you watch all of them in order.

  • q zorn
    q zorn 3 years ago

    i have watched this video before and like it even better now with some opencv experience. it would be great to run a python version of your code on the raspberry pi 3. thanks.

  • Naveen Pathirana
    Naveen Pathirana 3 years ago

    Warning:Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:537) .... please help me

    • Aarjav Khara
      Aarjav Khara 3 years ago +1

      try
      #include "opencv2/highgui/highgui.hpp"

  • manvstaco
    manvstaco 3 years ago +2

    holy cow I got it working on all the new releases :D Haven't programmed in years thank you much!

  • Fadli FM
    Fadli FM 3 years ago

    awesome tutorial :) just started learn opencv and i love this tutorial for detail explanation :) great job sir :) make more tutorial and surely ill watch and comment your vid :D

  • Jesus Soberon
    Jesus Soberon 3 years ago

    Hi Kyle. Many thanks for your video tutorials on Object tracking using opencv. Your explanation is very detailed. Im starting on computer vision, and your tutorials are very usefull. Again, many thank Amigo! saludos

  • Carlos E Freitas
    Carlos E Freitas 3 years ago +2

    Thanks for the tutorial. Can I ask you if would be possible to do the same using OpenCV in Linux ? I´m planning to do something like this using a Raspberry Pi3, by now I got some Face detection working, but its terribly slow. I must fond a way of follow objects moving on live video feed.
    Once again, thankyou for your inspiring work.

    • Abdallah Hegab
      Abdallah Hegab 2 years ago

      so did it work with python

    • noob code
      noob code 2 years ago

      yes sir,you can use openCV in linux(i am a user of ubuntu 16.04).it's quite easy and fast. thankyou

    • Sarvesh Thakur
      Sarvesh Thakur 2 years ago

      Yes. You can use Python(or C++) + OpenCV on Raspberry Pi

    • Naveen Pathirana
      Naveen Pathirana 3 years ago

      that's the same question also I have .... Did you have a answer for this question

  • Per Malmstedt
    Per Malmstedt 3 years ago +1

    Just started studying object tracking for a new project and stumbled on your tutorial. I love your detailed explanation and the fact that you just don't assume a lot of knowledge about the tools used. I will for sure try to undersand the CV library, and watch all tutorials I can find that you have made. I am way more fluent in C# but I guess there is no rapper for OpenCV out there..
    Again, thanx!

    • Kelvin Wekesa
      Kelvin Wekesa 2 years ago

      hello, where are your zip files the link does not display on my video

    • Kyle Hounslow
      Kyle Hounslow  3 years ago +1

      Glad you've taken an interest in Computer Vision and thanks for watching!
      There actually is a very nice wrapper for OpenCV named EmguCV.
      Head over to Chris Dahms' RU-clip page for some excellent tutorials on EmguCV ru-clip.net/user/18F4550videos
      Thanks,
      Kyle

  • John Christian
    John Christian 3 years ago

    Hey Kyle, Thank you so much for this amazing program. We really appreciate programmers like you, who really help other programmers out and also the beginners. I really need a little bit of help tho. How can I make this program run using OpenCV 3.1.0 ? Any info would really help. Thank you so much man.

  • kestha ravali
    kestha ravali 3 years ago

    thank you so much for the video and please help me how to stop the loop of the video and instead of tracking the the positions how can we draw a rectangle around the object detected please help me

  • twilighttucson
    twilighttucson 3 years ago

    Thank you for the indepth tutorial! After this final project you'll be sure to get a donation! Alot of this information has saved my skin. Albeit, working on the python side of Opencv.
    Thanks again.

  • kadir çağrı ÜNAL
    kadir çağrı ÜNAL 3 years ago

    hey kyle firstly,i want to thank you for your helpful tutorial videos.But i have a problem when i try to debug this program visual studio gives me this error '1>LINK : fatal error LNK1104: cannot open file 'MSVCP120D.dll'' and also it says that can not find MSVCR120D.dll what should i do please help me.

  • Razvan Has
    Razvan Has 3 years ago

    Thank you very much for the great tutorial. Keep up the good work!

  • Prasanna Routray
    Prasanna Routray 3 years ago +1

    Hey Kyle,
    is it possible for you to create a tutorial for object tracking using only depth images and not color/RGB images? like you are doing here with RGB image.
    Waiting for your reply.
    Thanks
    regards,
    Prasanna

  • Schmuck
    Schmuck 3 years ago

    To anyone getting an error "Sizes of input arrays do not match", use this differenceImage = abs(grayImage1 - grayImage2); to calculate the difference image. I'm new to opencv, so don't ask me why the old one doesn't work. I'm going to guess it's depreciated/old

  • Hussam Bedair
    Hussam Bedair 3 years ago

    I'm getting "Debug Assertion Failed!" when i press"t" to tracking ... how can I solve this problem ?? Please Help .

  • TING-YUAN HUANG
    TING-YUAN HUANG 3 years ago

    Thanks for doing this!!
    I'd want to know how write in c# with visual studio?

  • Michael del Rosario
    Michael del Rosario 3 years ago

    Great tutorial! Quick question, is this applicable for a moving camera?

  • Chun Qhai
    Chun Qhai 3 years ago

    Great tutorial ! Thanks you so much!
    One question. Seems like your source codes only work with single moving object, how can I detect multiple moving objects ?

  • ash sal
    ash sal 3 years ago

    how can i get the source code ?

  • tech nician
    tech nician 4 years ago

    What camera do you recommend? I have the beaglebone and like to use it to track objects in the kitchen. If the roommate leaves unclean dishes in the sink, I want it to sms him on his cell phone to clean the kitchen :)

  • tech nician
    tech nician 4 years ago

    Now If I can use it to track my cell phone in my house before it dies then its really useful :)

  • Vikram Gupta
    Vikram Gupta 4 years ago

    Hi Kyle, Thanks for this great tutorial on this very useful application. Works beautifully on my Mac. The fact that you have shared an template to fill while seeing the tutorial, makes learning more hands on.

  • Russell __
    Russell __ 4 years ago

    You are a good teacher. Thanks.

  • Das K
    Das K 4 years ago +1

    Hi Kyle,
    This video is very helpful, I am looking for a solution to track multiple objects (people), is it possible to use the same solution for that if so how ? do I need to use Kalaman filter for that purpose ? pls share your thoughts on this.

  • Đông Quang
    Đông Quang 4 years ago

    Thank you so much ! Amazing solution !

  • PhonicUK
    PhonicUK 4 years ago +5

    You can get a significant performance boost by instead of capturing two frames from the camera each loop iteration, you actually just capture into the 'first' buffer, do all the work, then copy the 'first' buffer into the 'second' buffer at the end. That way you're comparing a sliding window of 2 consecutive frames instead of fixed pairs.

  • HARSH MUNSHI
    HARSH MUNSHI 4 years ago

    Can it track multiple objects?

    • Fathima Khalid
      Fathima Khalid 4 years ago

      +Ghassem Tofighi thanks a lot for your immense guide.
      I went through those links. It is very useful for 3D tracking.
      Can you suggest me some methods to track 2D cartoon objects?

    • Ghassem Tofighi
      Ghassem Tofighi 4 years ago

      I've written some guides here, not completely what you are looking for, but maybe useful:
      stackoverflow.com/questions/32946097/openni-human-tracking-from-the-ceiling-with-asus-xtion-pro/32975177#32975177

    • Fathima Khalid
      Fathima Khalid 4 years ago

      Could you please guide me to implement it in c++?

    • Fathima Khalid
      Fathima Khalid 4 years ago

      +HARSH MUNSHI thanks a lot

    • HARSH MUNSHI
      HARSH MUNSHI 4 years ago

      Yes it is able to, it'll take some effort to convert it to C++. Since my platform supports python I used it

  • Hoàng Đạt Lê
    Hoàng Đạt Lê 4 years ago +2

    Hi, thanks for your video.
    but I encountered some problems, i can't see OPENCV_DEBUG (Project Property file). Can you help me this problems?
    thank you!

  • michael mcgowan
    michael mcgowan 4 years ago

    Kyle I have a few questions about a project that I have been working on for years and I could really use some advice about how to apply this type of tracking to it. Can I contact you through phone are email?

  • Claude Pageau
    Claude Pageau 4 years ago +1

    Well I found your tutorial very informative. I used your technique to write a Raspberry Pi, picamera, opencv motion tracking program written in python. It is not quite as fast as your demo but good enough. This program is a vehicle speed camera that records speed data in a log and speed photo with overlayed text. Anyway thanks for your excellent Tutorial and code walkthrough. Here is a link to my RU-clip video. ru-clip.net/video/eRi50BbJUro/video.html
    code is on github doc here github.com/pageauc/motion-track/blob/master/speed-track/speed_track.md

  • EL KASRI Zakaria
    EL KASRI Zakaria 4 years ago +3

    I'm getting "Debug Assertion Failed!" when i press"t" to tracking, i think that it is from findContours() because the code works without this method. I checked the path, dll files and everything. I'm using VS2013 Express with openCV 2.4.11

    • Max Jensen
      Max Jensen 3 years ago

      Thank you - excatly what solved my problem before with a heap problem! :) - I was looking at this error, since this user had the same error as me, but you solved it. stackoverflow.com/questions/34760254/debug-assertion-failed-opencv-is-block-type-validheader-block-use Emil.

    • Emil Andersson
      Emil Andersson 3 years ago +1

      +nizam ahmed I tried to put my vectors (contours and hierarchy) as Global and it helped :)

    • nizam ahmed
      nizam ahmed 3 years ago

      Hey how did you solve this error of debug assertion error.it would be greatly appreciated if you share your solution

    • SIMuTech
      SIMuTech 4 years ago

      '

    • EL KASRI Zakaria
      EL KASRI Zakaria 4 years ago

      +Izzat Ikhwan Syazri Hasanuddin
      i had some error in lib files, you have to create a new project and ensure that you have the good configuration