19 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import cv2
 | |
| import numpy as np
 | |
| from PIL import Image, ImageDraw
 | |
| def main():
 | |
|     image = Image.open('D:\\MACH\\MACH\\LAB_2\\img1.jpg')
 | |
|     image_arr = np.asarray(image)
 | |
| 
 | |
|     hog = cv2.HOGDescriptor()
 | |
|     hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
 | |
|     detections, weights = hog.detectMultiScale(image_arr)
 | |
|     detections_rectangles = detections.tolist()
 | |
|     draw = ImageDraw.Draw(image)
 | |
|     for x, y, w, h in detections_rectangles:
 | |
|         draw.rectangle(
 | |
|             [x, y, x + w, y + h], outline=(255, 0, 0))
 | |
|     image.show()
 | |
| if __name__ == '__main__':
 | |
|     main()
 |