为什么短短几段代码,打开摄像头却特别卡,各位老师,怎么解决
#include
#include
using namespace cv;
using namespace std;
string car_detection_name = "D:\opencv\sources\data\haarcascades\car_detection.xml";
CascadeClassifier car_detection;
int main(int argv, char **argc) {
car_detection.load(car_detection_name);
VideoCapture cam(0);
if(strcmp(argc[1],"run")==0)
{
while (1)
{
Mat frame, Gray;
vectorcar;
cam >> frame;
cvtColor(frame, Gray, CV_BGR2GRAY);
equalizeHist(Gray, Gray);
car_detection.detectMultiScale(Gray, car, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(1, 1));
for (int i = 0; i < car.size(); i++)
{
rectangle(frame, car[i], Scalar(255, 0, 0), 1, 8, 0);
}
imshow("output", frame);
if (waitKey(30) >= 0)
break;
}
}
return 0;
}