Ask Your Question
0

count the pedestrian amoun from image

asked 2013-06-17 10:02:39 -0600

Pirass gravatar image

updated 2013-06-17 18:44:04 -0600

I want to count the pedestrian amount from image.so I tried to detect the face and count the people. but it codes detect only front face pedestrian. but i want count all pedestrian there. my codes here. how can i do that. help me.

#include "stdafx.h"
#include <stdio.h>
#include <cv.h>
#include <iostream>
#include <highgui.h>

using namespace cv;
using namespace std;
void detect(IplImage *faces);
int main()
{
  freopen("out.txt","w",stdout);
  CascadeClassifier cascade;

  if (!cascade.load("haarcascade_frontalface_alt.xml"))
    return -1;

  Mat src = imread("people1.jpg");
  if (src.empty())
    return -1;

  Mat gray;
  cvtColor(src, gray, CV_BGR2GRAY);
  equalizeHist(gray, gray);

  vector<Rect> faces;
  cascade.detectMultiScale(gray, faces, 1.2, 3);

  for (int i = 0; i < faces.size(); i++)
  {
    Rect r = faces[i];
    rectangle(src, Point(r.x, r.y), Point(r.x + 5, r.y + 5), CV_RGB(0,255,0));
  }
  std::cout << "Total: " << faces.size() << " faces" << std::endl;
  imshow("src", src);
  waitKey(0);

  return 0;

}

what are the changes i want to do this codes thanks to Advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-06-17 10:24:25 -0600

berak gravatar image

there's a hog-cascade for pedestrians , that you can use instead of the frontal-face one.

edit flag offensive delete link more

Comments

I used hog-cascade for pedestrians CascadeClassifier. but that is not help to my need. Any cascade file to detect the people ear? if it is, very useful to me. but i used to it haarcascade_mcs_rightear and haarcascade_mcs_leftear. but they are not working, plz help me

Pirass gravatar imagePirass ( 2013-06-18 12:51:04 -0600 )edit

Use HOG SVM approach, which is inbuilt in openCV

ManuVISION gravatar imageManuVISION ( 2016-11-21 20:54:42 -0600 )edit

Question Tools

Stats

Asked: 2013-06-17 10:02:39 -0600

Seen: 1,309 times

Last updated: Jun 17 '13