Bottom Page

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()
Quote
#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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Install tensor flow for Python 2.7 in Windows 10 ErnestTBass 4 203 Jul-26-2019, 02:11 PM
Last Post: ThomasL
  Tracking Object Help Algorithm afyaldiz 0 251 Apr-14-2019, 11:28 PM
Last Post: afyaldiz
  for loop problem with opencv Miradox 1 390 Dec-23-2018, 10:39 PM
Last Post: stullis
  OpenCV - extract 1st frame out of a video file kerzol81 2 1,415 Nov-12-2018, 09:12 AM
Last Post: kerzol81
  How to create mask for different types of images using opencv Prince_Bhatia 0 3,211 Apr-26-2018, 07:38 AM
Last Post: Prince_Bhatia
  Attribute Error while using tensor flow pratheep 2 3,149 Mar-16-2018, 10:50 AM
Last Post: pratheep
  Model.predict() always returning the same value of 1 for opencv nastyheatnor 0 1,815 Dec-14-2017, 08:20 AM
Last Post: nastyheatnor
  Heuns method in Python auting82 0 1,192 Oct-18-2017, 01:46 PM
Last Post: auting82
  OpenCV installation issue NOOBscripts 8 2,948 Aug-17-2017, 03:09 PM
Last Post: snippsat
  Project using Python and Opencv trabis03 7 4,218 Apr-29-2017, 10:09 AM
Last Post: trabis03

Forum Jump:


Users browsing this thread: 1 Guest(s)