Skip to content

blobFromImage and crop #14659

@LaurentBerger

Description

@LaurentBerger

in blobFromImage it is possible to resize and crop image. blob generated can be used as input for yolo net. Values return by yolo are in a new coordinates system that must be computed using this code :

            if crop:
                s = max([blob_width / img.shape[1], blob_height / img.shape[0]])
                r_blob = (int(0.5 / s * (int(img.shape[1] * s) - blob_width )),
                          int(0.5 / s * (int(img.shape[0] * s) - blob_height )),
                          int(blob_width / s),
                          int(blob_height / s))
            else:
                r_blob = (0, 0, img.shape[1], img.shape[0])

for yolov3 or yolov2 result.

new function would be Rect getBlobFromimagerect(Mat , Size , bool crop)

Is it a good pr?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions