o
    R|h
                     @   s\   d dl Z d dlZd dlZd dlZd dlZd dlZdd Zdd Zdd Z	dd	 Z
d
d ZdS )    Nc                 C   s   t d t|  d S )Nx   )timesleeposremove)file r   0/var/www/html/reskinaiphotoeditor/remove_logo.py
delet_file	   s   
r
   c                 C   s0   t | }tjt|jdd}t|tj}|S )Nuint8dtype)	requestsgetnpasarray	bytearraycontentcv2imdecodeIMREAD_COLOR)urlrespimgr   r   r	   
urlToImage   s   
r   c           	   
   C   s   g }t d| jd D ]S}| d d d d |f }|d d d d |f }|d d d d |f }tjtj|tjt|d| dtjdtjdtj|tj|dtjdtjdtj	d}||g7 }q
t
|}|S )Nr         g     o@r   )rangeshaper   addmultiplydivider   	full_likeCV_32FCV_8Umerge)	src1src2maskres_channelscabmresr   r   r	   blend_with_mask_matrix   s   *
r/   c                 C   s  t | }|jdd \}}t|j tj||dfdtjd}tjt|t|d d  t|t|d d  dfd	d|t|d d |t|d d |f< t	|d
}t	|d}|}d| 
dd  }t|t||| tjt|gd  | 
dd S )Nr   r      r   r            r   )d   r4   )2   r5   z./static/temp_img//)targetargs)r   r   printr   fullr   zerosintr   blursplitimwriter/   	threadingThreadr
   start)r   r   heightwidthr(   roiimg2	file_namer   r   r	   	operation%   s   
drI   c                 C   s   t | }d| S )Nz&http://172.105.57.151/static/temp_img/)rI   )r   filenamer   r   r	   remove_whatermakG   s   rK   )r   numpyr   r   r   r   rA   r
   r   r/   rI   rK   r   r   r   r	   <module>   s    "