Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why facedetection not happening in Portrait mode in Android , using javaCV cvHaarDetectObjects method

I tried to modify the FacePreview.java sample provided for Android and since that code always open your camera in landscape mode, I added orientation logic in Preview.java, once we opens the camera:

mCamera.setDisplayOrientation(90);

When I ran the program I found always the Object detection i.e. cvHaarDetectObjects only works if the phone is in landscape mode, in other modes mainly in portrait, it's not at all detecting any face. What is the reason behind this?

faces = cvHaarDetectObjects(
    grayImage,
    classifier,
    storage,
    1.1,
    3,
    CV_HAAR_FEATURE_MAX
      | CV_HAAR_SCALE_IMAGE 
      | CV_HAAR_FIND_BIGGEST_OBJECT
      | CV_HAAR_DO_ROUGH_SEARCH
      | CV_HAAR_DO_CANNY_PRUNING);

faces.total always returns 0 when the phone is in portrait mode or orientation is different that landscape.

I tried modifying places but didn't find the expected.

click to hide/show revision 2
retagged

updated 2013-10-08 12:38:51 -0600

berak gravatar image

why facedetection not happening in Portrait mode in Android , using javaCV cvHaarDetectObjects method

I tried to modify the FacePreview.java sample provided for Android and since that code always open your camera in landscape mode, I added orientation logic in Preview.java, once we opens the camera:

mCamera.setDisplayOrientation(90);

When I ran the program I found always the Object detection i.e. cvHaarDetectObjects only works if the phone is in landscape mode, in other modes mainly in portrait, it's not at all detecting any face. What is the reason behind this?

faces = cvHaarDetectObjects(
    grayImage,
    classifier,
    storage,
    1.1,
    3,
    CV_HAAR_FEATURE_MAX
      | CV_HAAR_SCALE_IMAGE 
      | CV_HAAR_FIND_BIGGEST_OBJECT
      | CV_HAAR_DO_ROUGH_SEARCH
      | CV_HAAR_DO_CANNY_PRUNING);

faces.total always returns 0 when the phone is in portrait mode or orientation is different that landscape.

I tried modifying places but didn't find the expected.