Src_gray := cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)īinary := cv2.threshold(src_gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU) Src := cv2.imread("C:\Users\HP\AppData\Local\Packages\_cw5n1h2txyewy\AC\INetCache\QHO4UEI4\illustration.png") Turn off the camera and release resources Here you can modify the data amount according to the actual situation Or exit the camera after getting enough samples. The waitkey method can bind keys to ensure the playback of the picture, and exit the camera through the q key Of course, it can also be set to other paths or call the database)Ĭv2.imwrite("data/User." String(face_id) '.' String(count) '.jpg', gray) (Here is the folder where the data is created. Save the image and regard the grayscale image as a two-dimensional array to detect the face area If successful, the number of samples will increase Use rectangle to mark the frame for the faceĬv2.rectangle(img,, , ) Xy is the coordinate of the upper left corner, w is the width, and h is the height. Framed face, for loop ensures a real-time dynamic video stream that can be detected Where gray is the grayscale image to be detected, 1.3 is the proportion of each image size reduction, and 5 is minNeighborsįaces := face_tectMultiScale(gray, 1.3, 5) Detect the face, bring the data recorded by each camera frame into OpenCv, and let the Classifier judge the face Gray := cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) Convert to grayscale image to reduce program compliance and improve recognition SampleNum is used to count the number of samples 'haarcascade_frontalface_default.xml') To be changedįace_id := input('`n User data input,Look at the camera and wait. Call the face classifier and adjust it according to the actual path If there are other cameras, the parameter can be adjusted to 1,2 Call the built-in camera of the notebook, and the parameter is 0.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |