Yaohong

为了真相不惜被羞辱

How to Read a Image in Python

How to Read a Image in Python There are three ways to read a image, the codes is showing below. image_path = "fasterRCNN/faster-rcnn-keras-master/img/street.jpg"; from PIL import Image import numpy as np image = Image.open(image_path) # RGB tmp_image = np.array(image) print("PIL open shape:",tmp_image.shape, tmp_image) # load with cv2 import cv2 image = cv2.imread(image_path) # mode: BGR print("cv2 imread shape:", image.shape) # (width,height,channel) # load with matplotlib import matplotlib.image as mpimg image = mpimg.

What do `*args` and `**kwargs` mean in python function?

What do *args and **kwargs mean in python function? *args means we can pass an arbitrary number of arguments to the function; Similarly, **kwargs allow we pass many key=value argument to the function; *args *args iterable: def my_sum(*args): result = 0 # Iterating over the Python args tuple for x in args: result += x return result print(my_sum(1, 2, 3)) # output: 6 The * is a unpacking operator; def print_three_things(a, b, c): print( 'a = {0}, b = {1}, c = {2}'.

SSLCertVerificationError报错

双击执行Applications > Python3.6 下的Install Certificates.command

SSLCertVerificationError报错 Error: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091) Solution: 环境:Mac Macintosh HD > Applications > Python3.6 (或者其它安装python目录) 然

简单的图像加宽和截取类

支持图像加宽高,或截掉宽高

简单的图像加宽和截取类 源码如下: class ImageUtils: def __init__(self): import numpy; self.np = numpy; pass ## def resizePadding(self, np_2d_image, target_width,target_height): single_img = np_2d_image; tmp_img_width = single_img.shape[1] tmp_img_height = single_img.shape[0] np = self.np print("resizeFile origin shape :",single_img.shape) # 宽度pading添加 if tmp_img_width < target_width: for x in range(tmp_img_width, target_width): # tmp_arr =