Exemplo n.º 1
0
                cv2.putText(
                    show_frame,
                    "g:%d a:%d" % (face_attribute.gender, face_attribute.age),
                    (result.box.left, result.box.top - 10),
                    cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0))
            if face_angle is not None and landmark.landmarks_count > 0:
                print('face angle: %f %f %f' %
                      (face_angle.pitch, face_angle.yaw, face_angle.roll))
                cv2.putText(
                    show_frame, "p=%.0f y=%.0f r=%.0f" %
                    (face_angle.pitch, face_angle.yaw, face_angle.roll),
                    (result.box.left, result.box.bottom + 30),
                    cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0))
            for p in landmark.landmarks:
                cv2.circle(show_frame, (p.x, p.y), 1, (0, 255, 0), 2)
            index += 1

        # Display the resulting frame
        cv2.imshow('RockX Face Analyze - ' + str(args.device), show_frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    face_det_handle.release()
    face_landmark5_handle.release()
    face_landmark68_handle.release()
    face_attr_handle.release()
Exemplo n.º 2
0
import cv2

if __name__ == '__main__':

    parser = argparse.ArgumentParser(description="RockX Object Detection Demo")
    parser.add_argument('-i', '--image', help="input image", type=str)
    parser.add_argument('-d', '--device', help="target device id", type=str)
    args = parser.parse_args()

    object_det_handle = RockX(RockX.ROCKX_MODULE_OBJECT_DETECTION, target_device=args.device)

    in_img = cv2.imread(args.image)
    in_img_h, in_img_w = in_img.shape[:2]

    ret, results = object_det_handle.rockx_face_detect(in_img, in_img_w, in_img_h, RockX.ROCKX_PIXEL_FORMAT_BGR888)

    for result in results:
        label = RockX.ROCKX_OBJECT_DETECTION_LABELS_91[result.cls_idx]
        print('%s (%d %d %d %d) %f' % (label, result.box.left, result.box.top, result.box.right, result.box.bottom, result.score))
        cv2.rectangle(in_img,
                        (result.box.left, result.box.top),
                        (result.box.right, result.box.bottom),
                        (0, 255, 0), 2)
        cv2.putText(in_img, "%s" % label,
                    (result.box.left, result.box.top - 10),
                    cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0))

    cv2.imwrite('out.jpg', in_img)

    object_det_handle.release()
Exemplo n.º 3
0
        index = 0
        for result in results:
            cv2.rectangle(show_frame,
                          (result.box.left, result.box.top),
                          (result.box.right, result.box.bottom),
                          (0, 255, 0), 2)

            ret, align_result = carplate_align_handle.rockx_carplate_align(frame, in_img_w, in_img_h,
                                                                           RockX.ROCKX_PIXEL_FORMAT_RGB888, result.box)

            if align_result is not None:
                ret, recog_result = carplate_recog_handle.rockx_carplate_recognize(align_result.aligned_image)

                if recog_result is not None:
                    show_frame = draw_cn_char(show_frame, recog_result, (160 + 10, (40*index)), (255, 0, 0))
                    # cv2.putText(frame, str, (160 + 10, (10+40*index+20)), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255))

                show_frame[(10+40*index):(10+40*index+40), 10:(160+10)] = align_result.aligned_image

            index += 1

        cv2.imshow('RockX Carplate - ' + str(args.device), show_frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    cap.release()
    cv2.destroyAllWindows()

    carplate_det_handle.release()
                          2)
            if align_img is not None and index < 3:
                show_frame[(10 + 112 * index):(10 + 112 * index + 112),
                           10:(112 + 10)] = align_img

            show_str = str(result.id)
            if target_name is not None:
                show_str += str.format(" - {name}", name=target_name)

            if target_face is not None and 'image' in target_face.keys(
            ) and target_face['image'] is not None and index < 3:
                show_frame[(10 + 112 * index):(10 + 112 * index + 112),
                           132:(112 + 132)] = target_face['image']

            cv2.putText(show_frame, show_str,
                        (result.box.left, result.box.top - 12),
                        cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0))

            index += 1
        # Display the resulting frame
        cv2.imshow('RockX Face Recog - ' + str(target_device), show_frame)
        cv2.moveWindow('RockX Face Recog - ' + str(target_device), 300, 100)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    face_det_handle.release()
Exemplo n.º 5
0
                            target_device=args.device)

    cap = cv2.VideoCapture(args.camera)
    cap.set(3, 1280)
    cap.set(4, 720)
    last_face_feature = None

    while True:
        # Capture frame-by-frame
        ret, frame = cap.read()
        in_img_h, in_img_w = frame.shape[:2]

        ret, results = head_det_handle.rockx_face_detect(
            frame, in_img_w, in_img_h, RockX.ROCKX_PIXEL_FORMAT_BGR888)

        for result in results:
            cv2.rectangle(frame, (result.box.left, result.box.top),
                          (result.box.right, result.box.bottom), (0, 255, 0),
                          2)

        # Display the resulting frame
        cv2.imshow('RockX Head Detection - ' + str(args.device), frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    head_det_handle.release()
Exemplo n.º 6
0
        in_img_h, in_img_w = frame.shape[:2]

        start = time.time()
        ret, results = pose_body_handle.rockx_pose_body(
            frame, in_img_w, in_img_h, RockX.ROCKX_PIXEL_FORMAT_BGR888)
        end = time.time()
        print('pose body use: ', end - start)

        index = 0
        for result in results:
            for p in result.points:
                cv2.circle(frame, (p.x, p.y), 3, (0, 255, 0), 3)
            for pairs in RockX.ROCKX_POSE_BODY_KEYPOINTS_PAIRS:
                pt1 = result.points[pairs[0]]
                pt2 = result.points[pairs[1]]
                if pt1.x <= 0 or pt1.y <= 0 or pt2.x <= 0 or pt2.y <= 0:
                    continue
                cv2.line(frame, (pt1.x, pt1.y), (pt2.x, pt2.y), (255, 0, 0), 2)
            index += 1

        # Display the resulting frame
        cv2.imshow('RockX Pose - ' + str(args.device), frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    pose_body_handle.release()
Exemplo n.º 7
0
    pose_finger_handle = RockX(RockX.ROCKX_MODULE_POSE_FINGER_3,
                               target_device=args.device)

    cap = cv2.VideoCapture(args.camera)
    cap.set(3, 1280)
    cap.set(4, 720)
    last_face_feature = None

    while True:
        # Capture frame-by-frame
        ret, frame = cap.read()

        in_img_h, in_img_w = frame.shape[:2]

        ret, result = pose_finger_handle.rockx_pose_finger(
            frame, in_img_w, in_img_h, RockX.ROCKX_PIXEL_FORMAT_BGR888)
        for p in result.points:
            cv2.circle(frame, (p.x, p.y), 3, (0, 255, 0), 3)

        # Display the resulting frame
        cv2.imshow('RockX Finger - ' + str(args.device), frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    pose_finger_handle.release()