diff --git a/AddMosaic.py b/AddMosaic.py old mode 100644 new mode 100755 diff --git a/CleanMosaic.py b/CleanMosaic.py old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/hand.gif b/hand.gif old mode 100644 new mode 100755 diff --git a/models/__init__.py b/models/__init__.py old mode 100644 new mode 100755 diff --git a/models/loadmodel.py b/models/loadmodel.py old mode 100644 new mode 100755 diff --git a/models/pix2pix_model.py b/models/pix2pix_model.py old mode 100644 new mode 100755 diff --git a/models/runmodel.py b/models/runmodel.py old mode 100644 new mode 100755 diff --git a/models/unet_model.py b/models/unet_model.py old mode 100644 new mode 100755 diff --git a/models/unet_parts.py b/models/unet_parts.py old mode 100644 new mode 100755 diff --git a/options/addmosaic_options.py b/options/addmosaic_options.py old mode 100644 new mode 100755 diff --git a/options/cleanmosaic_options.py b/options/cleanmosaic_options.py old mode 100644 new mode 100755 diff --git a/pretrained_models/AddMosaic/put_AddMosaic_model_here b/pretrained_models/AddMosaic/put_AddMosaic_model_here old mode 100644 new mode 100755 diff --git a/pretrained_models/CleanMosaic/put_CleanMosaic_model_here b/pretrained_models/CleanMosaic/put_CleanMosaic_model_here old mode 100644 new mode 100755 diff --git a/result/result_save_here b/result/result_save_here old mode 100644 new mode 100755 diff --git a/util/__init__.py b/util/__init__.py old mode 100644 new mode 100755 diff --git a/util/data.py b/util/data.py old mode 100644 new mode 100755 diff --git a/util/ffmpeg.py b/util/ffmpeg.py old mode 100644 new mode 100755 diff --git a/util/image_processing.py b/util/image_processing.py old mode 100644 new mode 100755 index 2c805e070a94b848f275cb2345db3acc25062130..f44f23585794d8f3ac61c20e7484fd256b8a7246 --- a/util/image_processing.py +++ b/util/image_processing.py @@ -107,20 +107,11 @@ def mask_threshold(mask,blur,threshold): return mask def mask_area(mask): - contours= cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[1] + mask = cv2.threshold(mask,127,255,0)[1] + # contours= cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[1] #for opencv 3.4 + contours= cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[0]#updata to opencv 4.0 try: area = cv2.contourArea(contours[0]) except: area = 0 return area - -# def eclosion_add(img_fg,img_bg,mask,eclosion_num,Type = 'inside'): - -# mask = (cv2.blur(mask, (eclosion, eclosion))) -# mask = ch_one2three(mask) -# mask = mask/255.0 - -# # img_tmp = np.zeros(img_bg.shape, dtype='uint8') -# # img_tmp[y-size:y+size,x-size:x+size]=img_fake -# img_result = img_origin.copy() -# img_result = img_origin*(1-mask)+img_tmp*mask \ No newline at end of file diff --git a/util/mosaic.py b/util/mosaic.py old mode 100644 new mode 100755 index 191d73606bdb4d866baf9dd652e3cf1b00595d4f..483c4a7beca6610a0ab16a5c351bc47ace5c60ef --- a/util/mosaic.py +++ b/util/mosaic.py @@ -2,7 +2,7 @@ import cv2 import numpy as np import os import random -from .image_processing import resize,ch_one2three +from .image_processing import resize,ch_one2three,mask_area def addmosaic(img,mask,n,out_size = 0,model = 'squa_avg'): @@ -10,7 +10,6 @@ def addmosaic(img,mask,n,out_size = 0,model = 'squa_avg'): img = resize(img,out_size) h, w = img.shape[:2] mask = cv2.resize(mask,(w,h)) - img_mosaic=img.copy() if model=='squa_avg': @@ -64,9 +63,8 @@ def random_mosaic(img,mask): h,w = img.shape[:2] mask = cv2.resize(mask,(w,h)) #area_avg=5925*4 - image, contours, hierarchy = cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) try: - area = cv2.contourArea(contours[0]) + area = mask_area(mask) except: area = 0 if area>50000: diff --git a/util/util.py b/util/util.py old mode 100644 new mode 100755 diff --git a/video_or_image/put_your_input_data_here b/video_or_image/put_your_input_data_here old mode 100644 new mode 100755