Tracking Your Ears (Two Ears, \(^o^)/~)
// Capture the current frame
cap >> frame;
// Resize the frame
resize(frame, frame, Size(), scalingFactor, scalingFactor, INTER\_AREA);
// Convert to grayscale
cvtColor(frame, frameGray, CV\_BGR2GRAY);
// Equalize the histogram
equalizeHist(frameGray, frameGray);
// Detect left ear
leftEarCascade.detectMultiScale(frameGray, leftEars, 1.1, 2, 0CV\_HAAR\_SCALE\_IMAGE, Size(30, 30) );
// Detect right ear
rightEarCascade.detectMultiScale(frameGray, rightEars, 1.1, 2, 0CV\_HAAR\_SCALE\_IMAGE, Size(30, 30) );
// Draw green rectangle around the left ear
for(int i = 0; i < leftEars.size(); i++)
{
Rect leftEarRect(leftEars\[i\].x, leftEars\[i\].y, leftEars\[i\].width, leftEars\[i\].height);
rectangle(frame, leftEarRect, Scalar(0,255,0), 4);
}
// Draw green rectangle around the right ear
for(int i = 0; i < rightEars.size(); i++)
{
Rect rightEarRect(rightEars\[i\].x, rightEars\[i\].y, rightEars\[i\].width, rightEars\[i\].height);
rectangle(frame, rightEarRect, Scalar(0,255,0), 4);
}