Is originally want to use camera to collect images, after an error for a simple example, but still an error... In order to ensure the integrity of their code so retained commented out part of the
error message is as follows:
"FaceDemo1. Exe (Win32) :" loaded "C: \ Program Files \ (x86) Intel \ \ 1.5 \ bin \ x86 OpenCL SDK \ intelocl DLL", cannot find or open the PDB file,
"FaceDemo1. Exe (Win32) :" unloaded "C: \ Program Files \ (x86) Intel \ \ 1.5 \ bin \ x86 OpenCL SDK \ intelocl DLL"
Critical error detected c0000374
FaceDemo1. Exe has triggered a breakpoint,
0 x00007ffe3037e6fc (NTDLL. DLL) (located in FaceDemo1. Exe) caused by abnormal: 0 xc0000374: pile has been damaged, (parameters: 0 x00007ffe303d22b0),
0 x00007ffe3037e6fc (NTDLL. DLL) (FaceDemo1. Exe) in untreated exception: 0 xc0000374: pile has been damaged, (parameters: 0 x00007ffe303d22b0),
Two program error location is in "detectMultiScale" place, see some people say that this error is address cross-border online, but I also don't know what to modify where, hope to be able to get you a great god help,
# include & lt; Opencv2/opencv. Hpp>
# include & lt; Iostream>
Using the namespace CV;
using namespace std;
String haar_face_datapath="G:/opencv3.4.0/opencv/build/etc/haarcascades/haarcascade_frontalface_alt_tree XML";
Int main (int arg c, char * * argv) {
/* VideoCapture capture (0);//open the camera
if (! The capture. IsOpened ()) {
Printf (" could not open the camera... \n");
return -1;
}
The Size S=Size ((int) capture. Get (CV_CAP_PROP_FRAME_WIDTH), (int) capture. Get (CV_CAP_PROP_FRAME_HEIGHT));
Int FPS=the capture. Get (CV_CAP_PROP_FPS);
*/
CascadeClassifier faceDetector;
FaceDetector. Load (haar_face_datapath);//load detector
/* Mat frame;
NamedWindow (" camera - demo ", CV_WINDOW_AUTOSIZE);
VectorFaces;
int count=0;
While (the capture. Read (frame)) {
Flip (frame, frame, 1);//image about flip
FaceDetector. DetectMultiScale (frame, faces, 1.1, 1, 0, the Size (100, 120), the Size (380, 400));
for (int i=0; I & lt; Faces. The size (); I++) {
If (count % 10==0) {
Mat DST.
The resize (frame (faces [I]), DST, the Size (100, 100));
Imwrite (format (" D:/MyFaces surprised/face_ % jeter pg ", count), DST);
}
A rectangle (frame, faces [I], Scalar (0, 0, 255), 2, 8, 0).
}
Imshow (" camera - demo, "frame).
Char c=waitKey (10);
If (27) c=={
break;
}
count++;
}
The capture. Release ();
*/
Mat srcImage, grayImage, dstImage;
//[2] read picture
SrcImage=imread (" D:/123 JPG ");
DstImage=srcImage. Clone ();
Imshow (" [artwork], "srcImage);
GrayImage. Create (srcImage. The size (), srcImage. The type ());
CvtColor (srcImage, grayImage, CV_BGR2GRAY);//generated grayscale, and improve the detection efficiency
Scalar colors []=
{
//red, orange, yellow, green, blue, purple
CV_RGB (255, 0, 0),
CV_RGB (255, 97, 0),
CV_RGB (255, 255, 0),
CV_RGB (0, 255, 0),
CV_RGB (0, 255, 255),
CV_RGB (0, 0, 255),
CV_RGB (160, 32, 240)
};
//[3] test
VectorThe rect.
FaceDetector. DetectMultiScale (grayImage, the rect, 1.1, 3, 0).//object classifier called
Printf (" the number of detected face: % d \ n ", the rect. The size ());
//[4] tag, the circle is drawn on the face
for (int i=0; I & lt; The rect. The size (); I++)
{
Point center;
Int the radius;
Center. X=cvRound ((the rect [I] x + the rect [I] width * 0.5));
Center. Y=cvRound ((the rect [I] y + the rect [I] height * 0.5));
The radius=cvRound ((the rect [I] width + the rect [I] height) * 0.25);
Circle (dstImage, center, the radius, colors, [7] I % 2);
}
//[5] according to
Imshow (" [face recognition detectMultiScale], "dstImage);
WaitKey (0);
return 0;
}
CodePudding user response:
FaceDetector. Load (haar_face_datapath);//load success here?Bool ok=faceDetector. Load (haar_face_datapath);
Printf (" % d ", "ok");
Assert (! "Ok");//check whether loaded successfully
CodePudding user response: