def opencvblit(src_tri, dst_tri, src_cv_img, dst_pil_img):
    
    ((x11,x12), (x21,x22), (x31,x32)) = src_tri
    ((y11,y12), (y21,y22), (y31,y32)) = dst_tri

    minx = int(math.floor(min(y11, y21, y31)))
    miny = int(math.floor(min(y12, y22, y32)))
    y11 -= minx
    y21 -= minx
    y31 -= minx
    y12 -= miny
    y22 -= miny
    y32 -= miny
    sizex = int(math.ceil(max(y11, y21, y31)))
    sizey = int(math.ceil(max(y12, y22, y32)))
    
    #if the destination size is 0, no point in performing the transformation
    # and opencv throws an exception that we can't catch anyway
    if sizex < 1 or sizey < 1:
        return
    
    src_vec = pcv.vector_Point2f([pcv.Point2f(float(x),float(y)) for (x,y) in src_tri])
    dst_vec = pcv.vector_Point2f([pcv.Point2f(float(x),float(y)) for (x,y) in [(y11,y12), (y21,y22), (y31,y32)]])
    
    A = pcv.getAffineTransform(src_vec, dst_vec)
    
    transformed_im = pcv.Mat()
    pcv.warpAffine(src_cv_img, transformed_im, A, pcv.Size(sizex, sizey), pcv.INTER_CUBIC, pcv.BORDER_WRAP)
    
    transformed_im = transformed_im.to_pil_image()
    mask = Image.new('1', (sizex, sizey))
    maskdraw = ImageDraw.Draw(mask)
    maskdraw.polygon(((y11,y12), (y21,y22), (y31,y32)), outline=255, fill=255)

    dst_pil_img.paste(transformed_im, (minx, miny), mask=mask)
Mismatched values and dtypes should raise exceptions
dataset/ETHPy150Open pycollada/meshtool/meshtool/filters/simplify_filters/sander_simplify.py/opencvblit--crossover with--dataset/ETHPy150Open mapbox/rasterio/tests/test_features.py/test_rasterize_mismatched_dtype