cv2.error: \modules\imgproc\src\imgwarp.cpp:2114: error: (-215) func != 0 in function cv::resize

def visualize_mean_face(x_mean, size, new_dims):
    """Rearrange the data in the mean face to a 2D array

    - Organize the contents in the mean face vector to a 2D array.
    - Normalize this image.
    - Resize it to match the new dimensions parameter

    Args:
        x_mean (numpy.array): Mean face values.
        size (tuple): x_mean 2D dimensions
        new_dims (tuple): Output array dimensions

    Returns:
        numpy.array: Mean face uint8 2D array.
    """
    #new_size = size+(1,)
    #vis_mean = x_mean.reshape(size).astype(np.uint8)
    vis_mean = x_mean.reshape(size).astype(int)
    vis_mean = cv2.resize(vis_mean, new_dims, interpolation = cv2.INTER_CUBIC)
    return vis_mean

After change the datatype, I found I can't resize the image, and the error says:"cv2.error: ......\opencv-2.4.13.2\modules\imgproc\src\imgwarp.cpp:2114: error: (-215) func != 0 in function cv::resize"
After a long time search, I found that datatype has a problem, I should change the float to np.uint8, instead of pure int.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容