#### user_bot.roiCartoon = cv2.cvtColor(user_bot.roiCartoon, cv2.COLOR_BGR2RGB) rightImg = cv2.cvtColor(rightImg, cv2.COLOR_BGR2RGB) leftImg = cv2.cvtColor(leftImg, cv2.COLOR_BGR2RGB) user_bot.specialImg = cv2.cvtColor(user_bot.specialImg, cv2.COLOR_BGR2RGB) #### imgList = [ user_bot.roiCartoon, user_bot.roiCartoon, rightImg, rightImg, rightImg, user_bot.roiCartoon, user_bot.roiCartoon, leftImg, leftImg, leftImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg, user_bot.specialImg ] user_bot.moviePath = CVTools.makeMovie(imgList, self.outPath) return user_bot if __name__ == '__main__': import botClass from landmarkModule import landmarker bb = botClass.bot() la = landmarker() bb.roiCartoon = cv2.imread('pic/1620210456.7131963.jpg') bb.roiLandmarks = la.run(bb.roiCartoon)[0] bb.specialImg = cv2.imread('../facefatter.jpg') mm = movie_maker('pic/', la) bb = mm.run(bb, 1) print(bb.moviePath)
else: return morph_image # 显示 # cv2.imshow('thin', thin_image) # cv2.imwrite('thin.jpg', thin_image) # cv2.imwrite('mask.jpg',mask) if __name__ == '__main__': from landmarkModule import landmarker from cartonModule import cartoon_face la = landmarker(False) cm = cartoon_face(la) cf = face_morph(la, cm) src_img = cv2.imread('roi.jpg') from botClass import bot user_bot = bot() user_bot.imgPath = 'pic/25033812051166452013.jpg' # user_bot.roiCartoon=cv2.imread('inputImg.jpg') out = cf.run(user_bot) # print('in',image.shape,'out',out.shape) # cv2.imwrite('../facefatter.jpg', out.specialImg) # print('time', time.time() - t1) # # src = cv2.imread('a10.png')[:,:,:3] # src = cv2.imread('wuyifan.jpg')[:,:,:3] # # face_thin_auto(src)
print('emotion_flag',emotion_flag) print('img_path',img_path) img=[] img=cv2.imread(img_path)[:,:,:3] if len(img.shape)==0:return [] landmarks=self.faceLandmarker.run(img) if len(landmarks)>0: roi_img=CVTools.roiChoice(landmarks, img, self.perspect_size) user_bot.roiImg=roi_img user_bot.roiCartoon=self.process(roi_img) # roi_img = cv2.medianBlur(roi_img, 3) # user_bot.roiCartoon =self.cartoon_model.style_transfer(images=[roi_img], visualization=False)[0] return user_bot else: return user_bot if __name__=='__main__': from landmarkModule import landmarker la=landmarker() cf=cartoon_face(la) import botClass bot=botClass.bot() bot.imgPath='pic/24451810641815485231.jpg' out=cf.run(bot,2) # print('in',image.shape,'out',out.shape) cv2.imwrite('../cartoon.jpg', out.roiCartoon) # print('time', time.time() - t1)
def createBot(self, username, content): print('bot process create', username) self.userBotDict[username] = botClass.bot() self.userBotDict[username].userName = username return self.updateBot(username, content)