def createMarkers(
):  #run this program then print the markers that are saved in this program's directory
    aruco_dict = aruco.Dictionary_get(
        aruco.DICT_6X6_250)  #set aruco dictionary
    Mk1 = aruco.drawMarker(aruco_dict, 1, 700)  #creat marker with ID1 size 700
    Mk2 = aruco.drawMarker(aruco_dict, 2, 700)  #creat marker with ID2 size 700
    cv2.imwrite('marker1.jpg', Mk1)  #save markers
    cv2.imwrite('marker2.jpg', Mk2)
    cv2.imshow('Marker 1', Mk1)  #show markers
    cv2.imshow('Marker 2', Mk2)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #2
0
def create_markers():
		j=2
		markers_dict_1 = aruco.getPredefinedDictionary(aruco.DICT_6X6_50)
		markers_dict1= custom_dictionary_from(j,6,markers_dict_1)
		markers_dict_2 = aruco.getPredefinedDictionary(aruco.DICT_7X7_50)
		markers_dict2 = custom_dictionary_from(j,7,markers_dict_2)

		markers1 = list(aruco.drawMarker(markers_dict1,i+1,200) for i in range(1))
		markers2 = list(aruco.drawMarker(markers_dict2,i+1,200) for i in range(1))
		
		for i in range(len(markers1)):
				cv2.imwrite(os.path.join('markers','marker6_')+str(i+1) + '.png',markers1[i])
		for i in range(len(markers2)):
				cv2.imwrite(os.path.join('markers','marker7_')+str(i+1)+'.png', markers2[i])
		return markers_dict1, markers_dict2
예제 #3
0
def aruco_gen(id_aruco, num_pixels):
    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_1000)  #replace n with no. of bits per pixel and C with the no. of combinations
                                                                #select n and C from the list mentioned above

    img = cv2.cvtColor(aruco.drawMarker(aruco_dict, id_aruco, num_pixels),cv2.COLOR_GRAY2RGB)
    img_border=cv2.copyMakeBorder(img,25,25,25,25,cv2.BORDER_CONSTANT,value=[255,255,255])
    text="ArUco ID = "+str(id_aruco)
    textsize = cv2.getTextSize(text, cv2.FONT_HERSHEY_SIMPLEX, 0.5, 1)[0]
    textX = int((img.shape[1] - textsize[0]) / 2)
    textY = int(( textsize[1]+12) / 2)
    cv2.putText(img_border,text, (textX,textY), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,255)) 
    path=""
    cv2.imwrite(path+("ArUco"+str(id_aruco)+".jpg"),img_border)
    path="Images/"
    cv2.imwrite(path+("ArUco"+str(id_aruco)+".jpg"),img_border)
    cv2.imshow('frame',img_border)
    cv2.waitKey(0)
    '''
        code here for saving the Aruco image as a "jpg" by following the steps below:
        1. save the image as a colour RGB image in OpenCV color image format
        2. embed a boundary of 25 pixels on all four sides and three channels of the image
        3. save the image as "ArUcoID.jpg" where ID is the digits of id_aruco i.e. if the ID is 26 the name should be: ArUco26.jpg
        4. APIs which are permitted to be used are:
        a. cvtColor
        b. imwrite
        and other OpenCV APIs.
        5. You are permitted to modify n, C and variables id_aruco and num_pixels
    '''

    cv2.destroyAllWindows()
예제 #4
0
def create_aruco():
    """create four arucos on A4"""
    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)
    parameters = aruco.DetectorParameters_create()

    img = np.ones((A4_PIX_H, A4_PIX_W, 3), dtype=np.uint8) * 255
    img_h, img_w, channel = img.shape
    for i in range(4):
        aruco_marker = aruco.drawMarker(aruco_dict, i, aruco_size)
        aruco_marker = cv2.cvtColor(aruco_marker, cv2.COLOR_GRAY2BGR)
        if i == 0:
            img[pad:pad + aruco_size, pad:pad + aruco_size] = aruco_marker
        elif i == 1:
            img[pad:pad + aruco_size,
                img_w - pad - aruco_size:img_w - pad] = aruco_marker
        elif i == 2:
            img[img_h - pad - aruco_size:img_h - pad,
                img_w - pad - aruco_size:img_w - pad] = aruco_marker
        else:
            img[img_h - pad - aruco_size:img_h - pad,
                pad:pad + aruco_size] = aruco_marker

    cv2.imwrite('../result.jpg', img)
    corners, ids, rejectedImgs = aruco.detectMarkers(img,
                                                     aruco_dict,
                                                     parameters=parameters)
    print(corners)
    print(ids)

    grayscale = aruco.drawDetectedMarkers(img, corners, ids, (0, 0, 255))
    cv2.imshow('frame', grayscale)
    cv2.imwrite("../detect_result.jpg", grayscale)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    return img
예제 #5
0
def aruco_gen(
    id_aruco, num_pixels
):  #This function expects two parameters as arguments-ID and the number of pixels in resolution. Both these inputs are whole decimal numbers.

    aruco_dict = aruco.Dictionary_get(
        aruco.DICT_nXn_C
    )  #Replace n with number of bits per pixels and C with the number of combinations
    img = aruco.drawMarker(
        aruco_dict, id_aruco,
        num_pixels)  #Select n and C from the list mentioned above
    img1 = cv2.copyMakeBorder(
        img, 25, 25, 25, 25, cv2.BORDER_CONSTANT,
        value=255)  #embeds a white border of 25 pixels on all sides
    image = cv2.cvtColor(img1, cv2.COLOR_GRAY2BGR)  #RGB color conversion
    font = cv2.FONT_HERSHEY_SIMPLEX
    s1 = 'ArUco ID='
    s2 = str(id_aruco)
    sf = s1 + s2
    cv2.putText(image, sf, (180, 15), font, 0.50, (0, 0, 255),
                1)  #embeds the ID of the ArUco marker in Red Font
    des1 = 'C:\\400_Task1.1\\Images\\ArUco'
    des2 = '.jpg'
    destination = des1 + s2 + des2

    cv2.imwrite(
        destination,
        image)  #saves the image as ArUco<#ID>.jpg as per the respective ID
    cv2.imshow('frame', image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #6
0
def marcador():
    cod = request.args.get('cod')
    img_marcador = aruco.drawMarker(dictionary, int(cod) - 1, 600)
    cv2.imwrite(os.path.join('static', 'markers', '{}.png'.format(cod)), img_marcador)
    html = render_template('marcador.html', cod=int(cod))
    Timer(60, delete_image, (cod,)).start()
    return html
예제 #7
0
def generate_marker(marker_code,
                    aruco_dict=aruco.DICT_5X5_250,
                    size=200,
                    filename="img.png"):
    ardict = aruco.getPredefinedDictionary(aruco_dict)
    img = aruco.drawMarker(ardict, marker_code, size)
    print(cv2.imwrite(filename, img))
def generate_markers(kind='target'):
    '''
    generate all markers for a given kind

    Parameters
    ----------
    kind : string, mandatory
        either 'target, 'obstacle', 'other'. The default is 'target'.

    Returns
    -------
    None.

    '''

    range_ = MARKER_TARGET_RANGE if kind == 'target' \
                else MARKER_OBSTACLE_RANGE if kind == 'obstacle' \
                else MARKER_OTHER

    margin = 50
    base = np.ones((200 + 2 * margin, 200 + 2 * margin), dtype=np.uint8) * 255

    #build the markers and save them to disk
    for idx in range_:
        curr_marker = aruco.drawMarker(dictionary=DICT_44_250,
                                       id=idx,
                                       sidePixels=200,
                                       borderBits=2)
        curr = base.copy()
        curr[margin:200 + margin, margin:200 + margin] = curr_marker
        cv2.imwrite(f'../data/markers/marker_{idx}.png', curr)
예제 #9
0
    def create_aruco_marker(self,
                            id: int = 1,
                            resolution: int = 50,
                            show: bool = False,
                            save: bool = False,
                            path: str = './'):
        """ Function that creates a single aruco marker providing its id and resolution
        Args:
            id: int indicating the id of the aruco to create
            resolution: int
            show: boolean. Display the created aruco marker
            save: boolean. save the created aruco marker as an image "Aruco_Markers.jpg"
            path: path to where the aruco will be saved. If none specified will be saved in the same direcory of execution the code
        Returns:
            ArucoImage: numpy array with the aruco information
        """
        self.ArucoImage = 0

        aruco_dictionary = aruco.Dictionary_get(self.aruco_dict)
        img = aruco.drawMarker(aruco_dictionary, id, resolution)
        fig, ax = plt.subplots()
        ax.imshow(img, cmap=plt.cm.gray, interpolation="nearest")
        ax.axis("off")
        if show is True:
            fig.show()
        else:
            plt.close(fig)

        if save is True:
            fig.savefig(path + "Aruco_Markers.png")

        self.ArucoImage = img
        return self.ArucoImage
예제 #10
0
def aruco_gen(id_aruco, num_pixels):
    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)

    img = aruco.drawMarker(aruco_dict, id_aruco, num_pixels)

    dst = cv2.copyMakeBorder(img,
                             25,
                             25,
                             25,
                             25,
                             cv2.BORDER_CONSTANT,
                             value=[255, 0, 0])

    img1 = cv2.cvtColor(dst, cv2.COLOR_GRAY2BGR)

    img1 = cv2.putText(img1, 'ArUco ID = 2', (120, 21),
                       cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 0, 0), 2)

    img1 = img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)

    cv2.imshow('frame', img1)

    cv2.imwrite('Aruco2.jpeg', img1)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #11
0
 def create_arucos_pdf(self,
                       nx: int = 5,
                       ny: int = 5,
                       resolution: int = 50,
                       path: str = './'):
     """
     FUnction to create a pdf file with nx X ny number of arucos and save them in specified path
     Args:
         nx: number of rows
         ny: number of columns
         resolution: resolution of the image (arucos)
         path: path to where the aruco will be saved. If none specified will be saved in the same direcory of execution the code
     Returns:
         image of the arucos and the saved pdf
     """
     aruco_dictionary = aruco.Dictionary_get(self.aruco_dict)
     fig = plt.figure()
     for i in range(1, nx * ny + 1):
         ax = fig.add_subplot(ny, nx, i)
         img = aruco.drawMarker(aruco_dictionary, i, resolution)
         plt.imshow(img, cmap='gray')
         plt.imshow(img, cmap='gray')
         ax.axis("off")
     fig.savefig(path + "markers.pdf")
     fig.show()
     return fig
예제 #12
0
def aruco_gen(id_aruco, num_pixels):
    aruco_dict = aruco.Dictionary_get(
        aruco.DICT_5X5_250
    )  # aruco.DICT_nXn_C , replace n with no. of bits per pixel and C with the no. of combinations
    WHITE = [255, 255, 255]  #select n and C from the list mentioned above
    font = cv2.FONT_HERSHEY_SIMPLEX
    img = aruco.drawMarker(aruco_dict, id_aruco, num_pixels)
    constant = cv2.copyMakeBorder(img,
                                  25,
                                  25,
                                  25,
                                  25,
                                  cv2.BORDER_CONSTANT,
                                  value=WHITE)
    i = cv2.putText(
        constant,
        'ArUco ID = ' + str(id_aruco),
        (155, 15),
        font,
        0.5,
        (0, 0, 255),
        2,
    )
    cv2.imshow('ArUco', i)
    cv2.imwrite('ArUco' + str(id_aruco) + '.jpg', i)
    cv2.waitKey(0)
    '''
    code here for saving the Aruco image as a "jpg" by following the steps below:
    1. save the image as a colour RGB image in OpenCV color image format
    2. embed a boundary of 25 pixels on all four sides and three channels of the image
    3. save the image as "ArUcoID.jpg" where ID is the digits of id_aruco i.e. if the ID is 26 the name should be: ArUco26.jpg
    4. You are permitted to modify n, C and variables id_aruco and num_pixels
    '''

    cv2.destroyAllWindows()
예제 #13
0
def create_marker(marker_number):
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    #print(aruco_dict)
    img = aruco.drawMarker(aruco_dict, marker_number, 700)
    cv2.imwrite("marker" + str(marker_number) + ".jpg", img)

    cv2.imshow('frame', img)
    cv2.waitKey(0)
예제 #14
0
def create_marker(ident=2):

    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    print(aruco_dict)
    # second parameter is id number
    # last parameter is total image size
    img = aruco.drawMarker(aruco_dict, ident, 700)
    cv2.imwrite("test_marker%d.jpg" % ident, img)
예제 #15
0
파일: func.py 프로젝트: gpaps/Msc_Thesis
def aruco_gene(aruco_dict, iterations, sidepixels):
    '''
       aruco_gene(...)
            aruco_gene(dictionary, Iterations(ids),
             sidePixels[, img[, borderBits]]) -> img
    '''
    for i in range(iterations):
        img1 = aruco.drawMarker(aruco_dict, i, sidepixels)
        cv2.imwrite("{}.jpg".format(i), img1)
예제 #16
0
 def __init__(self, idi: int, size: int = 700, bgsize: int = 1):
     self._id = idi
     self._dic = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)
     img = np.zeros((size, size), dtype=np.uint8)
     self._img = aruco.drawMarker(self._dic,
                                  idi,
                                  size,
                                  img,
                                  borderBits=bgsize)
예제 #17
0
def generate_blob():
    ar_dict = ar.Dictionary_get(ar.DICT_6X6_250)

    img = ar.drawMarker(ar_dict, 2, 700)
    cv2.imwrite('test_marker.jpg', img)

    cv2.imshow('frame', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #18
0
def createArucoMarkers():
    outputMarker = []
    markerDictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
    for i in range(50):

        outputMarker = aruco.drawMarker(markerDictionary, i, 500)
        imageName = "4x4Marker_" + str(i) + ".jpg"
        #f=open(imageName,"w")
        cv2.imwrite(imageName, outputMarker)
예제 #19
0
 def drawMarkerAt(id, markerCenter):
     marker = aruco.drawMarker(aruco_dict, id, markerPx*2, borderBits=1)	
     paddedMarker = np.ones((facePx*2, facePx*2))*255
     padding = facePx-markerPx
     paddedMarker[padding:(facePx*2)-padding, 
                  padding:(facePx*2)-padding] = marker
     cv2.rectangle(paddedMarker, (0,0), (paddedMarker.shape[0]-1, paddedMarker.shape[1]-1), 0, 1)
     cubeTemplate[markerCenter[1] - facePx:markerCenter[1] + facePx, 
                  markerCenter[0] - facePx:markerCenter[0] + facePx] = paddedMarker
예제 #20
0
def genMarker(i, dicno, paper_size):
    print " Marker %d\r" % i,
    sys.stdout.flush()
    aruco_dict = aruco.Dictionary_get(dicno)
    img = aruco.drawMarker(aruco_dict, i, 2000)
    cv2.imwrite("/tmp/marker%d.png" % i, img)
    svg = genSvg(i, dicno, paper_size)
    cairosvg.svg2pdf(bytestring=svg, write_to='/tmp/marker%d.pdf' % i)
    os.remove("/tmp/marker%d.png" % i)
예제 #21
0
    def generateMarker(self, ID=7, size=700):
        # Create an image from the marker
        img = aruco.drawMarker(self.arucoDict, ID, size)

        # Save and display (press any key to exit)
        cv2.imwrite('ARUCO_'+str(ID)+'.png', img)
        cv2.imshow('Marker ID: ' + str(ID), img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
예제 #22
0
def main():
    """Execute the command"""

    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    fig = plt.figure()

    parser = argparse.ArgumentParser(
        description='Create aruco fiducial markers')
    parser.add_argument('-b',
                        '--basename',
                        help='basename for file (an extension is added)',
                        required=False,
                        default='marker')
    parser.add_argument('-i',
                        '--id',
                        type=int,
                        help='marker ID',
                        required=False,
                        default=1)
    parser.add_argument('-p',
                        '--pair',
                        help='create a pair of markers',
                        required=False,
                        action='store_true')
    args = parser.parse_args()

    if not args.pair:
        img = aruco.drawMarker(aruco_dict, args.id, 700)
        filename = args.basename + '.png'
        cv2.imwrite(filename, img)
        print('Created ID %d marker into file %s' % (args.id, filename))
    else:
        ax = fig.add_subplot(1, 4, 1)
        img = aruco.drawMarker(aruco_dict, args.id, 700)
        plt.imshow(img, cmap=mpl.cm.gray, interpolation='nearest')
        ax.axis('off')
        ax = fig.add_subplot(1, 4, 4)
        img = aruco.drawMarker(aruco_dict, args.id, 700)
        plt.imshow(img, cmap=mpl.cm.gray, interpolation='nearest')
        ax.axis('off')
        filename = args.basename + '.pdf'
        plt.savefig(filename)
        print('Created pair of ID %d markers into file %s' %
              (args.id, filename))
예제 #23
0
def generateTag(dir, id):
    ''' The actual tag generator '''
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    img = aruco.drawMarker(aruco_dict, id, 700)

    write_dir = dir + "/../tags/" + str(id) + ".jpg"
    print("Writing to: " + write_dir)
    cv2.imwrite(write_dir, img)

    return img
예제 #24
0
def main():
    count = 100
    size = 200
    path = "markers/4x4"

    os.makedirs(path, exist_ok=True)

    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_250)
    for i in range(0, count):
        image = aruco.drawMarker(aruco_dict, i, size)
        cv.imwrite("{}/{:02d}.png".format(path, i), image)
예제 #25
0
def makearucoboard(nrow,
                   ncolumn,
                   markerdict=aruco.DICT_6X6_250,
                   markersize=25,
                   savepath='./',
                   paperwidth=210,
                   paperheight=297,
                   dpi=600):
    """
    create aruco board
    the paper is in portrait orientation, nrow means the number of markers in the vertical direction

    :param nrow:
    :param ncolumn:
    :param markerdict:
    :param markersize:
    :param savepath:
    :param paperwidth: mm
    :param paperheight: mm
    :param dpi:
    :return:

    author: weiwei
    date: 20190420
    """

    aruco_dict = aruco.Dictionary_get(markerdict)
    # 1mm = 0.0393701inch
    a4npxrow = int(paperheight * 0.0393701 * dpi)
    a4npxcolumn = int(paperwidth * 0.0393701 * dpi)
    bgimg = np.ones((a4npxrow, a4npxcolumn), dtype='uint8') * 255
    markersizepx = int(markersize * 0.0393701 * dpi)
    markerdist = int(markersizepx / 4)

    markerareanpxrow = (nrow - 1) * (markerdist) + nrow * markersizepx
    uppermargin = int((a4npxrow - markerareanpxrow) / 2)
    markerareanpxcolumn = (ncolumn - 1) * (markerdist) + ncolumn * markersizepx
    leftmargin = int((a4npxcolumn - markerareanpxcolumn) / 2)

    if (uppermargin <= 10) or (leftmargin <= 10):
        print("Too many markers! Reduce nrow and ncolumn.")
        return

    for idnr in range(nrow):
        for idnc in range(ncolumn):
            startrow = uppermargin + idnr * (markersizepx + markerdist)
            endrow = startrow + markersizepx
            startcolumn = leftmargin + idnc * (markersizepx + markerdist)
            endcolumn = markersizepx + startcolumn
            i = (idnr + 1) * (idnc + 1)
            img = aruco.drawMarker(aruco_dict, i, markersizepx)
            bgimg[startrow:endrow, startcolumn:endcolumn] = img
    im = Image.fromarray(bgimg).convert("L")
    im.save(savepath + "test.pdf", "PDF", resolution=dpi)
예제 #26
0
def generate_tag():
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    print(aruco_dict)
    # second parameter is id number
    # last parameter is total image size
    img = aruco.drawMarker(aruco_dict, 4, 700)
    cv2.imwrite("test_marker4.jpg", img)

    cv2.imshow('frame', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #27
0
    def show_aruco(self):
        aruco_dict = aruco.getPredefinedDictionary(aruco.DICT_4X4_250)

        image = aruco.drawMarker(aruco_dict, 3, 700)

        photo = ImageTk.PhotoImage(image=PIL.Image.fromarray(image))

        self.projector_window.canvas.create_image(500, 400, image=photo)
        return np.array(
            [[150, 50, 0], [850, 50, 0], [850, 750, 0], [150, 750, 0]],
            dtype=np.float32)
    def create_marker(size, id, margin):
        aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)

        # white background
        img = 255 * np.ones((size, size), dtype=np.uint8)
        img_marker = aruco.drawMarker(aruco_dict, id, size - 2 * margin)

        # add marker centered
        img[margin:-margin, margin:-margin] = img_marker

        return img
예제 #29
0
def gen_aruco(n):
    while(n):

        img = np.zeros((100,100,3), np.uint8)
        Dictionary = aruco.getPredefinedDictionary(aruco.DICT_ARUCO_ORIGINAL)
        img=aruco.drawMarker(Dictionary,n,100,img,1)
        #cv2.imwrite('C:\\Users\\ailab\\PycharmProjects\\drone\\train\\'+str(n)+'.jpg',img)
        cv2.imwrite('C:\\Users\\ailab\\PycharmProjects\\drone\\train\\class_0\\' + 'aruco_0_'+str(n) + '.jpg', img)
        print('gen_aruco:  '+'aruco_0_'+str(n) + '.jpg')
        n = n - 1
    return 0
예제 #30
0
def generateMarkers():
    aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
    print(aruco_dict)
    # second parameter is id number
    # last parameter is total image size
    img = aruco.drawMarker(aruco_dict, 2, 700)
    cv2.imwrite("../Samples/Pictures/Markers/marker.jpg", img)

    cv2.imshow('frame', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
예제 #31
0
파일: cardgen.py 프로젝트: SWiT/ARTT
    if error:
        displayHelp()
        quit()

    pdf = canvas.Canvas(outputfile, pagesize=letter)

    pagepos = 0
    cardcount = 0

    # Prepare the marker dictionary.
    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)
    markersize = 60

    for cn in range(cnstart, cnend+1):
        marker = cv2.cvtColor(aruco.drawMarker(aruco_dict, cn, markersize), cv2.COLOR_GRAY2BGR)
        marker = cv2.copyMakeBorder(marker, 10, 10, 10, 10, cv2.BORDER_CONSTANT, value=[255,255,255])
        cv2.imwrite(imgfile, marker)

        # Trim the image file down.


        # There seems to be a bug in reportlab.
        # Strings are drawn in the A4 template even though we've set the pagesize to letter.
        # Do text positioning based on A4.
        if pagepos == 0:
            pos = margin*inch, margin*inch
        elif pagepos == 1:
            pos = (margin+cwidth)*inch, margin*inch
        elif pagepos == 2:
            pos = (margin+cwidth*2)*inch, margin*inch
예제 #32
0
파일: figure.py 프로젝트: SWiT/ARTT
#!/usr/bin/env python2
#encoding: UTF-8

import cv2
import cv2.aruco as aruco

if __name__ == "__main__":
    print "AR Figure"

    aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_100)
    markersize = 22
    blackborder = 1
    whiteborder = 1

    for markerid in range(0, 100):
        marker = cv2.cvtColor(aruco.drawMarker(aruco_dict, markerid, markersize,borderBits=blackborder), cv2.COLOR_GRAY2BGR) #borderBits
        if whiteborder > 0:
            marker = cv2.copyMakeBorder(marker, whiteborder, whiteborder, whiteborder, whiteborder, cv2.BORDER_CONSTANT, value=[255,255,255])
        imagefile = "images/4X4_" + str(markerid)+".png"
        cv2.imwrite(imagefile, marker)
        print "wrote: " + imagefile