Showing results for 
Search instead for 
Did you mean: 

Using person and face detection model parallely


I am working on pedestrian tracker demo code. I have modified the code to accept a face detection model face-detection-retail-0004 and added below lines to detect face alongside person as well.

// Load face detector
DetectorConfig face_config(fd_model_path, fd_weights_path);
auto face_plugin = plugins_for_devices[fd_mode];
ObjectDetector face_detector(face_config, face_plugin);

    face_detector.submitFrame(frame, frame_idx);		
    TrackedObjects faceDetection = face_detector.getResults();

    for (const auto &face : faceDetection) {
	cv::rectangle(frame, face.rect, cv::Scalar(255, 0, 0), 2);

//rest of the code

When running the code, it detects person and face both and keeps tracking the person body. Now I need to only detect face once a person is detected and instead of passing the complete frame for face detection, I just want to pass the person image as frame from which the face will be detected. For this, I did below changes:

for (const auto &detection : personDetection) {
	cv::rectangle(frame, detection.rect, cv::Scalar(255, 0, 0), 2);
	cv::Mat personImageFrame = frame(detection.rect);		
	face_detector.submitFrame(personImageFrame, frame_idx);		
	TrackedObjects faceDetection = face_detector.getResults();	// Get the face results
	if (faceDetection.size() > 1)
		cv::rectangle(personImageFrame, faceDetection[0].rect, cv::Scalar(255, 0, 0), 2);		

In the above code, I moved the face detection part inside the person detection. But when running this code, its not able to detect face from the person image frame. Is there anything I need to do with person image before passing it to the face detection mode. Please advise. Thanks

0 Kudos
0 Replies