def process_image(img_file, draw=False):

    img_src = cv2.imread(img_file, cv2.IMREAD_UNCHANGED)
    w = img_src.shape[1]
    h = img_src.shape[0]
    img_src, invdim = lkd.rescale(img_src, scale_percent=50)
    img_pref = lkd.prefilter_colors(img_src)
    img_grey = cv2.cvtColor(img_pref, cv2.COLOR_BGR2GRAY)
    thres, _ = cv2.threshold(img_grey, 20, 200,
                             cv2.THRESH_BINARY + cv2.THRESH_OTSU)
    _, img_grey = cv2.threshold(img_grey, thres - 1, 255, cv2.THRESH_BINARY)

    ret = 0

    cv2.imshow("GREY", img_grey)

    ret, _, _ = lkd.get_borders_from_grey_smear(img_src, img_grey, draw=draw)

    if ret is not None:
        if draw:
            minr = lkd.get_scaled_rect(ret, percentage=-4)
            maxr = lkd.get_scaled_rect(ret, percentage=7)

            lkd.drawimg(img_src, [ret], red=maxr, green=minr)
            cv2.waitKey(0)
        ret = np.multiply(ret,
                          invdim,
                          out=ret,
                          casting='unsafe',
                          dtype=np.int32)
    # print(img_file)
    return ret, w, h
def main():
    """ {pyname} reads a given set of svgs with a path and shows them on the screen

    Usage:
        {pyname} <imagefilenameglob> [--pathid=<pathid>] [--scale=<scalepercent>]
        {pyname} -h
    
    Options:
        -h, --help              Show this help message
        --pathid=<pathid>       [default: cutoutpath]
        --scale=<scalepercent>  [default: 100]
        
    Example:
        python {pyname} 02_shape_detected_imgs/2019_03*.jpg.svg --scale=50

    """    
    main.__doc__ = main.__doc__.format(pyname=os.path.basename(sys.argv[0]))
    # print(main.__doc__)
    args = docopt.docopt(main.__doc__, help=False)
    # pprint.pprint(args)
    if args["<imagefilenameglob>"] is None or args["--help"] == True:
        print(main.__doc__)
        return

    files = sorted(glob.glob(args["<imagefilenameglob>"]))

    if files is None or len(files) == 0:
        print("no files matched {}".format(args["<imagefilenameglob>"]))
        return

    for srcimgfname in files:
        print("{}".format(srcimgfname))
        
        srcshapedct, srcimgdatadct = parse_from_svg(read_svg(srcimgfname),pathids=[args["--pathid"]],imgids=["tweetimage"],fname=srcimgfname)
        srcshape = srcshapedct.get(args["--pathid"])
        srcimgdatatuple = srcimgdatadct.get("tweetimage")
        srcimgdata, w, h = srcimgdatatuple
        if srcimgdata.shape != (h, w):
            srcshape = (srcshape * [srcimgdata.shape[1]/w, srcimgdata.shape[0]/h]).astype(np.int32)

        lkd.drawimg(srcimgdata, [srcshape], label=srcimgfname, scalefac=int(args["--scale"])/100)#, red=srcshpcntr) 

        cv2.waitKey(0)

        cv2.destroyAllWindows()  
Esempio n. 3
0
 def growswap(growsize=1, swapoverthres=True):
     for idx, main in enumerate(retcurr):
         rect = get_grow_triangangle_along_axis_ref(
             main, retcurr[((idx + 1) % 4)], retcurr[idx - 1],
             growsize,
             np.array([[0, 0],
                       [img_grey.shape[1],
                        img_grey.shape[0]]])).astype(np.int32)
         if drawsteps:
             lkd.drawimg(img_src, [retcurr], red=rect)
             cv2.waitKey(100)
         if swapoverthres:
             if np.average(lkd.get_pixel(img_grey,
                                         rect)) > 255 * 0.3:
                 retcurr[idx] = rect[0]
         else:
             if np.average(lkd.get_pixel(img_grey,
                                         rect)) < 255 * 0.3:
                 retcurr[idx] = rect[0]
         if drawsteps:
             lkd.drawimg(img_src, [retcurr])
             cv2.waitKey(100)
def main():
    """ {pyname} creates a simple morph between multiple files resolved by one or two file patterns given
    by default the source images are scaled to fit the given out

    Usage:
        {pyname} <imagefilenamegloba> <imagefilenameglobb> <width>x<heigth> [options] 
        {pyname} <imagefilenameglob> <width>x<heigth> [options]
        {pyname} -h<w
    
    Options:
        -h, --help                   Show this help message
        -o, --outputdir=<outputdir>  [default: .] output directory    
        --projected                  project quadrangle to a rectangle trying to estimate the perspective and aspect ratio (takes precedence over zoom)
        --showimages                 Shows images used during processes
        --noscale                    if this is set the source image is not made to fit the specified image size as much as possible but centered if the target image is bigger than the source
        --frames=<frames>            [default: 30]  frames for tweening                       
        --stillframes=<stillframes>  [default: 360] how many frames the last frame is repeated
        --framedigits=<framedigits>  [default: 4]   digits to which the frame number is padded
        --suffix=<suffix>            Suffix appended to the original name yourfile_<suffix>_frameno.svg
        --outputtype=(png|svg)       [default: png] png or svg
        --pathid=<pathid>            [default: cutoutpath]
        --svgtemplate=<svgtemplate>  svgtemplate to use as target [default: svgtemplate.svg]
        
    """
    main.__doc__ = main.__doc__.format(pyname=os.path.basename(sys.argv[0]))
    args = docopt.docopt(main.__doc__, help=False)
    print(args)

    if args["--help"] == True:
        print(main.__doc__)
        return

    if (args["<imagefilenamegloba>"] is None or args["<imagefilenameglobb>"] is None) \
         and args["<imagefilenameglob>"] is None:
        print(main.__doc__)
        print("ERROR: Please provide file-paths to tween")
        return

    if args["<imagefilenamegloba>"] is not None and args[
            "<imagefilenameglobb>"] is not None:
        farraya = sorted(glob.glob(args["<imagefilenamegloba>"]))
        if len(farraya) == 0:
            print("ERROR: No files found for {}".format(
                args["<imagefilenamegloba>"]))
            return

        farrayb = sorted(glob.glob(args["<imagefilenameglobb>"]))
        if len(farrayb) == 0:
            print("ERROR: No files found for {}".format(
                args["<imagefilenameglobb>"]))
            return

        farray = farraya + farrayb

    if args["<imagefilenameglob>"] is not None:
        farray = sorted(glob.glob(args["<imagefilenameglob>"]))
        if len(farray) == 0:
            print("ERROR: No files found for {}".format(
                args["<imagefilenameglob>"]))
            return

    if len(farray) < 2:
        print("ERROR: Not enough files to tween: {}".format(farray))
        return

    if farray is None:
        print(main.__doc__)
        print("Error: please provide files to tween")
        return

    width = 1
    heigth = 1
    if re.match(r"\d+x\d+", args["<width>x<heigth>"]):
        width, heigth = args["<width>x<heigth>"].split("x")
        width, heigth = int(width), int(heigth)
    else:
        print(main.__doc__)
        print("Error: Please povide dimensions")
        return

    if args["--suffix"] is None:
        args["--suffix"] = ""

    if args["--outputtype"] != "png" and args["--outputtype"] != "svg":
        print("Error: Only png and svg are supported for option --outputtype")
        return
    if args["--outputtype"] == "svg":
        if not os.path.isfile(args["--svgtemplate"]):
            print("Error: file not found: " + args["--svgtemplate"])
            return

    args["--frames"] = int(args["--frames"])
    args["--stillframes"] = int(args["--stillframes"])

    limit = len(farray)
    dim = np.array([heigth, width])

    first = True
    for idx in range(limit - 1):
        srcimgfname = farray[idx]
        dstimgfname = farray[idx + 1]
        fnamepart = os.path.basename(srcimgfname)
        fnamepart = re.sub(r"(\.jpg)?\.[^\.]*$", "", fnamepart)
        outimgfnamebasestr = "{org}_{frameno:0" + args[
            "--framedigits"] + "d}.{ftype}"
        if args["--suffix"] != '':
            outimgfnamebasestr = "{org}_{suffix}_{frameno:0" + args[
                "--framedigits"] + "d}.{ftype}"

        print("{} => {}".format(srcimgfname, dstimgfname))

        srcshapedct, srcimgdatadct = svgreader.parse_from_svg(
            svgreader.read_svg(srcimgfname),
            pathids=[args["--pathid"]],
            imgids=["tweetimage"],
            fname=srcimgfname)
        srcshape = srcshapedct.get(args["--pathid"])
        srcimgtup = srcimgdatadct.get("tweetimage")
        srcimgdata, w, h = srcimgtup
        if srcimgdata.shape[2] == 4:
            srcimgdata = cv2.cvtColor(srcimgdata, cv2.COLOR_BGRA2BGR)
        if srcimgdata.shape != (h, w):
            srcshape = (
                srcshape *
                [srcimgdata.shape[1] / w, srcimgdata.shape[0] / h]).astype(
                    np.int32)

        dstshapedct, dstimgdatadct = svgreader.parse_from_svg(
            svgreader.read_svg(dstimgfname),
            pathids=[args["--pathid"]],
            imgids=["tweetimage"],
            fname=dstimgfname)
        dstshape = dstshapedct.get(args["--pathid"])
        dstimgtup = dstimgdatadct.get("tweetimage")
        dstimgdata, w, h = dstimgtup
        if dstimgdata.shape[2] == 4:
            dstimgdata = cv2.cvtColor(dstimgdata, cv2.COLOR_BGRA2BGR)
        if dstimgdata.shape != (h, w):
            dstshape = (
                dstshape *
                [dstimgdata.shape[1] / w, dstimgdata.shape[0] / h]).astype(
                    np.int32)

        if args["--projected"]:
            srcimgdata = lkd.get_scaled_image_keeping_aspect(
                srcimgdata, srcshape)
            srcshape = np.array([[0, 0], [srcimgdata.shape[1], 0],
                                 [srcimgdata.shape[1], srcimgdata.shape[0]],
                                 [0, srcimgdata.shape[0]]],
                                dtype=np.int32)

            dstimgdata = lkd.get_scaled_image_keeping_aspect(
                srcimgdata, srcshape)
            dstshape = np.array([[0, 0], [dstimgdata.shape[1], 0],
                                 [dstimgdata.shape[1], dstimgdata.shape[0]],
                                 [0, dstimgdata.shape[0]]],
                                dtype=np.int32)

        if srcshape is not None and dstshape is not None \
            and srcimgdata is not None and dstimgdata is not None:

            srcimgdata, _ = lkd.blacken_outside_shape(srcimgdata, srcshape)
            dstimgdata, _ = lkd.blacken_outside_shape(dstimgdata, dstshape)

            # copy source image to black common size
            srcblk = np.zeros([dim[0], dim[1], 3],
                              dtype=np.uint8)  # create black image
            if args["--noscale"] == False or dim[1] < srcimgdata.shape[
                    1] or dim[0] < srcimgdata.shape[0]:
                srcimgdata, srcshape = lkd.rescale_img_and_shape_to_size_keeping_aspect(
                    srcimgdata, srcshape, dim[1],
                    dim[0])  # scale source image to fit target image
            srcoff = np.array([srcblk.shape[1], srcblk.shape[0]]) - np.array(
                [srcimgdata.shape[1], srcimgdata.shape[0]])  # calculate offset to center original image # pylint: disable=unsubscriptable-object # srcblk.shape is subscriptable
            srcoff = (srcoff / 2).astype(
                np.int32)  # calculate offset to center original image
            srcmapul = np.min(srcshape + srcoff, axis=0)
            srcimgdata, srcshape = lkd.copy_shape(srcimgdata, srcblk, srcshape,
                                                  srcmapul)

            dstblk = np.zeros([dim[0], dim[1], 3],
                              dtype=np.uint8)  # create black image
            if args["--noscale"] == False or dim[1] < dstimgdata.shape[
                    1] or dim[0] < dstimgdata.shape[0]:
                dstimgdata, dstshape = lkd.rescale_img_and_shape_to_size_keeping_aspect(
                    dstimgdata, dstshape, dim[1],
                    dim[0])  # scale destination image to fit target image
            dstoff = np.array([dstblk.shape[1], dstblk.shape[0]]) - np.array(
                [dstimgdata.shape[1], dstimgdata.shape[0]])  # calculate offset to center original image # pylint: disable=unsubscriptable-object # dstblk.shape is subscriptable
            dstoff = (dstoff / 2).astype(
                np.int32)  # calculate offset to center original image
            dstmapul = np.min(dstshape + dstoff, axis=0)
            dstimgdata, dstshape = lkd.copy_shape(dstimgdata, dstblk, dstshape,
                                                  dstmapul)

            if args["--showimages"]:
                lkd.drawimg(srcimgdata, [srcshape], label="SRC",
                            scalefac=1)  #, red=srcshpcntr)
                lkd.drawimg(dstimgdata, [dstshape], label="DST",
                            scalefac=1)  #, red=dstshpcntr)
                lkd.drawimg(srcimgdata, [srcshape], label="MORPH", scalefac=1)

                if first:
                    first = False
                    cv2.waitKey(0)
                else:
                    cv2.waitKey(3000)

            tweenimg = np.zeros(srcimgdata.shape)
            steps = args["--frames"]
            for pos in range(0, steps + 1):
                outimgfname = os.path.join(
                    args["--outputdir"],
                    outimgfnamebasestr.format(org=fnamepart,
                                              suffix=args["--suffix"],
                                              frameno=pos,
                                              ftype=args["--outputtype"]))
                #print(outimgfname)
                tweenimg, tweenshp = get_tween_image(srcimgdata, dstimgdata,
                                                     srcshape, dstshape,
                                                     pos / steps)
                alhpaimg = lkd.get_img_shape_alpha(tweenimg, tweenshp)
                if args["--showimages"]:
                    lkd.drawimg(tweenimg, [tweenshp],
                                label="MORPH",
                                scalefac=1)
                    cv2.waitKey(20)
                svgcreator.write_image(outimgfname, alhpaimg, tweenshp,
                                       args["--outputtype"],
                                       args["--svgtemplate"])
            for pos in range(0, args["--stillframes"] + 1):
                cpos = pos + args["--frames"]
                outimgfname = os.path.join(
                    args["--outputdir"],
                    outimgfnamebasestr.format(org=fnamepart,
                                              suffix=args["--suffix"],
                                              frameno=cpos,
                                              ftype=args["--outputtype"]))
                #print(outimgfname)
                svgcreator.write_image(outimgfname, alhpaimg, tweenshp,
                                       args["--outputtype"],
                                       args["--svgtemplate"])

    if args["--showimages"]:
        cv2.destroyAllWindows()
Esempio n. 5
0
def get_optimized_rect(img_src, img_grey, rect, draw=False, drawsteps=False):
    """ We optimize a given quadrangle towards having a maximum white encompassing area
        by trying to shift its corners around.
        Shifting happens on any given corner A
        A     C
        
        B
        where ABC form a triangle made from parts of the original quadrangle
        A is shifted inwards and outwards by a few pixels along the vectors AC and AB
        Giving a point S_ being "outside" and S_' being "within" the line between A and the counter points
          Sy
        Sx A Sx'  C
          Sy'
           B
        if the area Sx A B contains more then a given threshold of white pixels
        A is moved to Sx
        if Sx' A B is mostly comprised of black pixels A is Moved to Sx'
        Same is repeated for Sy and Sy'
        This process is not repeated on one corner at once but all corners are probed in on direction clockwise
        and then counterclockwise to avoid "overoptimizing" on one corener A to much without probing the counterparts B and C
    """
    maxitter = 1000
    ret = rect
    retprev = np.zeros((4, 2))
    retcurr = ret.copy()
    diff = np.average(retcurr - retprev)
    if drawsteps:
        print("Optimizing orientation")
    for growsize in [
            12, 8, 5, 3, 2
    ]:  # magic numbers that work well for offset sizes of triangles
        if drawsteps:
            print("Optimizing size: {}".format(growsize), end='')
        retprev = np.zeros((4, 2))
        retcurr = ret.copy()
        diff = np.average(retcurr - retprev)
        curriter = 0
        while (diff > 1 and curriter < maxitter):
            curriter += 1
            if drawsteps:
                print(".", end='')
            retprev = retcurr.copy()

            def growswap(growsize=1, swapoverthres=True):
                for idx, main in enumerate(retcurr):
                    rect = get_grow_triangangle_along_axis_ref(
                        main, retcurr[((idx + 1) % 4)], retcurr[idx - 1],
                        growsize,
                        np.array([[0, 0],
                                  [img_grey.shape[1],
                                   img_grey.shape[0]]])).astype(np.int32)
                    if drawsteps:
                        lkd.drawimg(img_src, [retcurr], red=rect)
                        cv2.waitKey(100)
                    if swapoverthres:
                        if np.average(lkd.get_pixel(img_grey,
                                                    rect)) > 255 * 0.3:
                            retcurr[idx] = rect[0]
                    else:
                        if np.average(lkd.get_pixel(img_grey,
                                                    rect)) < 255 * 0.3:
                            retcurr[idx] = rect[0]
                    if drawsteps:
                        lkd.drawimg(img_src, [retcurr])
                        cv2.waitKey(100)

            #clockwise grow
            growswap(growsize, True)
            #clockwise shrink
            growswap(growsize * -1, False)
            #counterclockwise grow
            retcurr = np.flip(retcurr, 0)
            growswap(growsize)
            #counterclockwise shrink
            growswap(growsize * -1, False)
            retcurr = np.flip(retcurr, 0)
            diff = math.sqrt(
                np.max(retcurr - retprev) * np.max(retcurr - retprev))
        if drawsteps:
            print("")
        ret = retcurr
    if drawsteps:
        lkd.drawimg(img_src, [retcurr])
        cv2.waitKey(100)

    return ret
Esempio n. 6
0
def process_image(img_file, scale_percent=50, draw=False, drawsteps=False):
    ret = None
    img_src = cv2.imread(img_file, cv2.IMREAD_UNCHANGED)
    w = img_src.shape[1]
    h = img_src.shape[0]
    img_src, invdim = lkd.rescale(img_src, scale_percent=scale_percent)
    img_pref = lkd.prefilter_colors(img_src)
    img_grey = cv2.cvtColor(img_pref, cv2.COLOR_BGR2GRAY)
    thres, _ = cv2.threshold(img_grey, 20, 200,
                             cv2.THRESH_BINARY + cv2.THRESH_OTSU)
    _, img_grey = cv2.threshold(img_grey, thres - 1, 255, cv2.THRESH_BINARY)

    bbxes, mainbox = get_borderboxes(
        img_src)  # get paintboxes and paper-tissues if they exist
    if bbxes is not None:
        cv2.drawContours(img_grey, bbxes, 0, color=0,
                         thickness=-1)  # blacken them

    if mainbox is not None:  # alternative: blacken everyting
        img_grey, _ = lkd.blacken_outside_shape(img_grey, mainbox)

    if draw:
        lkd.drawimg(img_grey, [], label="GREYBLACKED")

    sdraw = draw

    shrinkrect, _, _ = lkd.process_image_shrink_boxdetect(img_src,
                                                          thres,
                                                          img_grey,
                                                          draw=draw,
                                                          drawsteps=drawsteps,
                                                          scale_percent=100)

    ret = shrinkrect

    lim = max(img_grey.shape)
    if ret.min() < 0 or ret.max() > lim:
        ret = np.array(
            [[0, 0], [img_grey.shape[1], 0],
             [img_grey.shape[1], img_grey.shape[0]], [0, img_grey.shape[0]]],
            dtype=np.int32)
    else:
        # minr = lkd.get_scaled_rect(ret, percentage=-7)
        maxr = lkd.get_scaled_rect(
            ret, percentage=7)  # 7 magic number by try and error

        # blacken out detected rectangle outer parts wit an offset of a certain percentage (see above)
        outerinv = np.zeros(img_grey.shape, dtype=np.uint8)
        outerinv = cv2.drawContours(outerinv, [maxr],
                                    0, [255, 255, 255],
                                    thickness=cv2.FILLED)
        img_grey = cv2.bitwise_and(img_grey, outerinv)

        ret = get_optimized_rect(img_src,
                                 img_grey,
                                 ret,
                                 draw=draw,
                                 drawsteps=drawsteps)

    draw = sdraw

    if draw:
        lkd.drawimg(img_src, [ret], green=ret)
    # print(img_file)
    ret = np.multiply(ret, invdim, out=ret, casting='unsafe', dtype=np.int32)
    return ret, w, h
Esempio n. 7
0
def main():
    """ {pyname} converts a SVG file to a PNG file cropping out a quadrangle given by a SVG path
    By default the original quadrangles orientation and position is kept as is and the background is made transparent.
    Alternatively the quadrangles can be zoomed to or projected flat to an estimated aspect ratio

    Usage:
        {pyname} <imagefilenameglob> [<outputdir>] [options] 
        {pyname} -h
    
    Options:
        -h, --help                   Show this help message
        --projected                  project quadrangle to a rectangle trying to estimate the perspective and aspect ratio (takes precedence over zoom)
        --zoom                       creates a image of the shape fitted into the minimum encompassing rectangle
        --showimages                 Shows images used during processes
        --autosuffix                 automatically sets "_cropped", "_zoom" or "_project" as a suffix
        --outputtype=(png|svg)       [default: png] png or svg
        --suffix=<suffix>            Suffix appended to the original name yourfile<suffix>.png
        --pathid=<pathid>            [default: cutoutpath]
        --scale=<scalepercent>       [default: 100]
        --svgtemplate=<svgtemplate>  svgtemplate to use as target [default: svgtemplate.svg]
        
    """
    main.__doc__ = main.__doc__.format(pyname=os.path.basename(sys.argv[0]))
    args = docopt.docopt(main.__doc__, help=True)

    if args["<imagefilenameglob>"] is None or args["--help"] == True:
        print(main.__doc__)
        return
    if args["<outputdir>"] is None:
        args["<outputdir>"] = "."
    if args["--outputtype"] != "png" and args["--outputtype"] != "svg":
        print("Error: Only png and svg are supported for option --outputtype")
        return
    if args["--outputtype"] == "svg":
        if not os.path.isfile(args["--svgtemplate"]):
            print("Error: file not found: " + args["--svgtemplate"])
            return
    if args["--suffix"] is None:
        if args["--autosuffix"]:
            if args["--projected"]:
                args["--suffix"] = "_projected"
            elif args["--zoom"]:
                args["--suffix"] = "_zoom"
            else:
                args["--suffix"] = "_cropped"
        else:
            args["--suffix"] = ""
    if not os.path.isdir(args["<outputdir>"]):
        print(main.__doc__)
        return

    files = sorted(glob.glob(args["<imagefilenameglob>"]))
    if files is None or len(files) == 0:
        print("no files matched {}".format(args["<imagefilenameglob>"]))
        return

    for srcimgfname in files:
        fnamepart = os.path.basename(srcimgfname)
        fnamepart = re.sub(r"\.[^\.]*$", "", fnamepart)
        dstimgfname = os.path.join(
            args["<outputdir>"],
            fnamepart) + args["--suffix"] + "." + args["--outputtype"]
        print("{} => {}".format(srcimgfname, dstimgfname))

        srcshapedct, srcimgdatadct = svgreader.parse_from_svg(
            svgreader.read_svg(srcimgfname),
            pathids=["cutoutpath"],
            imgids=["tweetimage"],
            fname=srcimgfname)
        srcshape = srcshapedct.get(args["--pathid"])
        srcimgdatatuple = srcimgdatadct.get("tweetimage")
        srcimgdata, w, h = srcimgdatatuple
        if srcimgdata.shape != (h, w):
            srcshape = (
                srcshape *
                [srcimgdata.shape[1] / w, srcimgdata.shape[0] / h]).astype(
                    np.int32)

        if args["--scale"] != "100":
            srcimgdata, srcshape = lkd.rescale_img_and_shape(
                srcimgdata, srcshape,
                int(args["--scale"]) / 100)

        if args["--projected"]:
            dstimgdata = lkd.get_scaled_image_keeping_aspect(
                srcimgdata, srcshape)
            dstimgshape = np.array([[0, 0], [dstimgdata.shape[1], 0],
                                    [dstimgdata.shape[1], dstimgdata.shape[0]],
                                    [0, dstimgdata.shape[0]]],
                                   dtype=np.int32)

        elif args["--zoom"]:
            dstimgdata, _, dstimgshape = lkd.get_shape_cropped(
                srcimgdata, srcshape)
        else:
            dstimgdata = srcimgdata
            dstimgshape = srcshape

        alhpaimg = lkd.get_img_shape_alpha(dstimgdata, dstimgshape)
        svgcreator.write_image(dstimgfname, alhpaimg, dstimgshape,
                               args["--outputtype"], args["--svgtemplate"])

        if args["--showimages"]:
            lkd.drawimg(dstimgdata, [dstimgshape], label="DST",
                        scalefac=1)  #, red=srcshpcntr)
            cv2.waitKey(0)

    if args["--showimages"]:
        cv2.destroyAllWindows()