mirror of
https://github.com/sbrl/research-rainfallradar
synced 2024-11-21 17:03:00 +00:00
dlr: make cv2 import optional
This commit is contained in:
parent
05fd955067
commit
f94f777f0a
1 changed files with 5 additions and 1 deletions
|
@ -12,7 +12,7 @@ import os
|
||||||
import io
|
import io
|
||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
import cv2
|
# import cv2 # optional import below in get_overlay
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from scipy.io import loadmat
|
from scipy.io import loadmat
|
||||||
|
@ -325,6 +325,10 @@ def decode_segmentation_masks(mask, colormap, n_classes):
|
||||||
|
|
||||||
|
|
||||||
def get_overlay(image, coloured_mask):
|
def get_overlay(image, coloured_mask):
|
||||||
|
global cv2
|
||||||
|
# import cv2 only when used, since it might not be available and this function isn't currently used (was prob something I dropped halfway through writing 'cause I got distracted)
|
||||||
|
if not cv2:
|
||||||
|
cv2 = __import__("cv2")
|
||||||
image = tf.keras.preprocessing.image.array_to_img(image)
|
image = tf.keras.preprocessing.image.array_to_img(image)
|
||||||
image = np.array(image).astype(np.uint8)
|
image = np.array(image).astype(np.uint8)
|
||||||
overlay = cv2.addWeighted(image, 0.35, coloured_mask, 0.65, 0)
|
overlay = cv2.addWeighted(image, 0.35, coloured_mask, 0.65, 0)
|
||||||
|
|
Loading…
Reference in a new issue