Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python's Numpy.transpose by axes equivalent for cv::Mat?

Hi there

I'm trying to translate the below Python code that uses numpy arrays into C++ and use cv::Mat instead of numpy:

def get_face_mask(im, landmarks): im = numpy.zeros(im.shape[:2], dtype=numpy.float64)

for group in OVERLAY_POINTS:
    draw_convex_hull(im,
                     landmarks[group],
                     color=1)

im = numpy.array([im, im, im]).transpose((1, 2, 0))

im = (cv2.GaussianBlur(im, (FEATHER_AMOUNT, FEATHER_AMOUNT), 0) > 0) * 1.0
im = cv2.GaussianBlur(im, (FEATHER_AMOUNT, FEATHER_AMOUNT), 0)

return im

(Full source code can be seen here)

I'm finding it a bit difficult to understand what the below lines does:

im = numpy.array([im, im, im]).transpose((1, 2, 0))

I don't seem to be able to find the equivalent of this in OpenCV C++ version.

Any help would be much appreciated.