mardi 27 avril 2021

How can I crop face rectangles from the frame in C++ code?

 # Detect face
        if len(video_frames) == 0:
            face_rects = faceCascade.detectMultiScale(gray, 1.3, 5)

        # Select ROI
        if len(face_rects) > 0:
            for (x, y, w, h) in face_rects:
                roi_frame = img[y:y + h, x:x + w]
            if roi_frame.size != img.size:
                roi_frame = cv2.resize(roi_frame, (500, 500))
                frame = np.ndarray(shape=roi_frame.shape, dtype="float")
                frame[:] = roi_frame * (1. / 255)
                video_frames.append(frame)

    frame_ct = len(video_frames)
    cap.release()

This is part of the python code from this link https://github.com/rohintangirala/eulerian-remote-heartrate-detection/blob/master/preprocessing.py I am converting this to C++. Could someone provide me the C++ code for this?

Aucun commentaire:

Enregistrer un commentaire