how to detect human body in android

android, image-processing, opencv

Solution

You can integrate Cascade Classifier of opencv (here is tutorial).

Opencv provides few xml files already trained to detect faces, eyes and even body. You may also train for your aimed object to get your own xml files (here is a tuto how to train yours from the scratch)

Now, for android, you need to install Opencv4android SDK (here). After installation, you will find some provided samples, what you need is to use the sample of "face detection", then you will just replace, in the the code, the xml used for face detection by the one for body detection. Opencv will provide you (haarcascade_upperbody.xml, hogcascade_pedestrians.xml )

here is what you have to check to replace (in FdActivity.java):

try {
           // load cascade file from application resources
          InputStream is = getResources().openRawResource(R.raw.lbpcascade_frontalface);
          File cascadeDir = getDir("cascade", Context.MODE_PRIVATE);
          mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
          FileOutputStream os = new FileOutputStream(mCascadeFile);
.........

Problem

I want to detect the whole human body in android is there any way to do that ? I think there is an easy way to do that in opencv. but I'am pretty new to android and i don't know how to use opencv in android.

Original source