Python Forum
face tracking using optical flow method using python+opencv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
face tracking using optical flow method using python+opencv
#1
Hello Folks..

I want to track the face in motion. Suppose if i move the face in different directions, then the camera should track that face in that direction and vice versa.
Now this code track faces , if the face is exactly in front of camera. But i want to track faces in motion . How could i do this using optical flow method .. Please help me.

My code is below: detector.py
This code is simple using Cascades method
import cv2
import numpy as np

faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml');
cam=cv2.VideoCapture(0);
rec=cv2.createLBPHFaceRecognizer();
rec.load("recognizer/trainningData.yml")
id=0
font=cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_COMPLEX_SMALL,2,1,0,2)
while(True):
        ret,img=cam.read();
        gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
        faces=faceDetect.detectMultiScale(gray, 1.3,5);
        for(x,y,w,h) in faces:
              cv2.rectangle(img,(x,y),(x+w,y+h), (0,0,255),2)
              id,conf=rec.predict(gray[y:y+h,x:x+w])
              if(id==1):
                  id="Aftab Ahmed"
              elif (id==2):
                      id="Ahmed"
              cv2.cv.PutText(cv2.cv.fromarray(img),str(id),(x,y+h),font,255);
        cv2.imshow("Face", img);
        if(cv2.waitKey(1)==ord('q')):
            break;
cam.release()
cv2.destroyAllWindows()
Reply
#2
https://www.learnopencv.com/object-track...pp-python/
http://www.pyimagesearch.com/2015/09/21/...-movement/

A little googling
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to detect irregular circles in python with opencv johansigaran 4 3,692 May-01-2020, 02:07 AM
Last Post: johansigaran
  Help with Optical Mark Recognition kekko 1 1,827 Mar-11-2020, 08:28 PM
Last Post: Larz60+
  Face recognition white_bird 2 28,532 Feb-25-2020, 08:30 AM
Last Post: white_bird
  Install tensor flow for Python 2.7 in Windows 10 ErnestTBass 4 6,618 Jul-26-2019, 02:11 PM
Last Post: ThomasL
  Tracking Object Help Algorithm afyaldiz 0 1,497 Apr-14-2019, 11:28 PM
Last Post: afyaldiz
  Attribute Error while using tensor flow pratheep 2 6,579 Mar-16-2018, 10:50 AM
Last Post: pratheep
  Project using Python and Opencv trabis03 7 8,663 Apr-29-2017, 10:09 AM
Last Post: trabis03

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020