在Windows上工作非常慢

时间:2016-11-03 07:34:59

标签: c++ qt opencv

我正在开发opencv和qt project.it在linux上运行得非常快但是它在windows上工作很慢.Linux操作系统是64位,Windows 64位也是。我不明白这个问题。谢谢(谢谢我的英文)

以下代码:

#include <opencv2/core/base.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/objdetect/objdetect_c.h>
#include <opencv2/objdetect.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <vector>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    VideoCapture cap(0); // open the video camera no. 0



    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
    // Load Face cascade (.xml file)
        CascadeClassifier face_cascade;
        face_cascade.load( "xml/haarcascade_frontalface_alt.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 a frame from video stream" << endl;
             break;
        }
         // Detect faces
             std::vector<Rect> faces;
             face_cascade.detectMultiScale( frame, 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( frame, 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", frame );
             }



                 //rectangle( frame, center, Size( faces[i].width*2, faces[i].height*2), Scalar( 255, 0, 255 ) );




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

}

0 个答案:

没有答案