read rgb image Args: im_file (str|np.ndarray): input can be image path or np.ndarray im_info (dict): info of image Returns: im (np.ndarray): processed image (np.ndarray) im_info (dict): info of processed image
(im_file, im_info)
| 20 | |
| 21 | |
| 22 | def decode_image(im_file, im_info): |
| 23 | """read rgb image |
| 24 | Args: |
| 25 | im_file (str|np.ndarray): input can be image path or np.ndarray |
| 26 | im_info (dict): info of image |
| 27 | Returns: |
| 28 | im (np.ndarray): processed image (np.ndarray) |
| 29 | im_info (dict): info of processed image |
| 30 | """ |
| 31 | if isinstance(im_file, str): |
| 32 | with open(im_file, 'rb') as f: |
| 33 | im_read = f.read() |
| 34 | data = np.frombuffer(im_read, dtype='uint8') |
| 35 | im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode |
| 36 | im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) |
| 37 | else: |
| 38 | im = im_file |
| 39 | im_info['im_shape'] = np.array(im.shape[:2], dtype=np.float32) |
| 40 | im_info['scale_factor'] = np.array([1., 1.], dtype=np.float32) |
| 41 | return im, im_info |
| 42 | |
| 43 | |
| 44 | class Resize_Mult32(object): |
no outgoing calls
no test coverage detected