Skip to content

opencl has no impact on the performance of face detection #5697

@anguoyang

Description

@anguoyang

Hi, all,

I have compiled opencv 3.0 with opencl(WITH_OPENCL), and also compiled and run a face detection sample, without any error, however, there is no difference no matter I using TAPI/UMAT or NOT.
Here is my source code(using UMAT):
int main()
{

VideoCapture cap("subway.avi"); // open the video file for reading

if (!cap.isOpened())  // if not success, exit program
{
    cout << "Cannot open the video file" << endl;
    return -1;
}

namedWindow("MyVideo", CV_WINDOW_NORMAL); //create a window called "MyVideo"

// Load Face cascade (.xml file)
CascadeClassifier face_cascade;
face_cascade.load("haarcascade_frontalface_alt2.xml");
while (1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read the frame from video file" << endl;
        break;
    }

    UMat umat;
    umat = frame.getUMat(ACCESS_READ);

    imshow("MyVideo", umat); //show the frame in "MyVideo" window

    // Detect faces
    std::vector<Rect> faces;
    face_cascade.detectMultiScale(umat, faces, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));

    // Draw circles on the detected faces
    for (int i = 0; i < faces.size(); i++)
    {
        Point center(faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5);
        ellipse(umat, center, Size(faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0);
    }

    imshow("Detected Face", umat);


    if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}

return 0;

}

Could you please help me to find out the reason? thanks a lot.

My display card is Intel Iris HD graphics, and there is no error when running my sample, but the speed is very very very slow!!! btw, the input video:"subway.avi" is with 1080P resolution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    question (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.org

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions