-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprdict.py
More file actions
28 lines (22 loc) · 774 Bytes
/
prdict.py
File metadata and controls
28 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import cv2
import numpy as np
from tensorflow import keras
from Unet import unet_predict
from core import locate, erode,dilate
import tensorflow as tf
print(tf.__version__)
UNet = tf.keras.models.load_model('unet.h5')
img_src, img_mask = unet_predict(UNet,'/home/sjq/81.jpg') #测试图片
# cv2.imshow('mask',img_mask)
img2gray = erode(img_mask)
# cv2.imshow('img2gray',img2gray)
ret, mask = cv2.threshold(img2gray, 200, 255, cv2.THRESH_BINARY)
# cv2.imshow('mask',mask)
cv2.imshow('img_mask',cv2.bitwise_and(img_src,img_src,mask=cv2.bitwise_not(mask)))
cv2.waitKey(0)
gray2img = cv2.cvtColor(img2gray, cv2.COLOR_GRAY2BGR)
img_src_copy = locate(img_src, gray2img)
# cv2.imshow('show', img_mask)
cv2.imshow('plate',img_src_copy)
cv2.waitKey(0)
cv2.destroyAllWindows()