Esempio n. 1
0
                def sit(img=None, format='rgb', path=None, name=""):
                    if path is None:
                        path = get_temp_path(name)
                    if img is None:
                        plt.save_image(path)
                        return path

                    if format == 'bgr':
                        img = _img.bgr2rgb(img)
                    if type(img) == list:
                        plt.show_images(images=img,
                                        path=path,
                                        show=False,
                                        axis_off=True,
                                        save=True)
                    else:
                        plt.imwrite(path, img)

                    return path
Esempio n. 2
0
def sit(img=None, name=''):

    path = get_temp_path(name)

    if img is None:
        plt.save_image(path)
        return path

    img = _img.bgr2rgb(img)
    if type(img) == list:
        print "hehe"
        plt.show_images(images=img,
                        path=path,
                        show=False,
                        axis_off=True,
                        save=True)
    else:
        plt.imwrite(path, img)
    return path
Esempio n. 3
0
def sit(img=None, format='rgb', path=None, name="", image_name="", bboxes=[]):
    if path is None:
        path = get_temp_path(name)

    if img is None:
        plt.save_image(path)
        return path

    if format == 'bgr':
        img = _img.bgr2rgb(img)
    if type(img) == list:
        plt.show_images(images=img,
                        path=path,
                        show=False,
                        axis_off=True,
                        save=True)
    else:
        # print path
        # cv2.imshow("test",img)
        # cv2.waitKey(0)
        # print os.path.abspath(path)
        image_path = path + 'images/' + image_name
        # print image_path
        cv2.imwrite(image_path, img)

    def write_result_as_txt(image_name, bboxes, path):
        filename = io.join_path(path, '%s.txt' % (image_name))
        print 'path', path
        lines = []
        for b_idx, bbox in enumerate(bboxes):
            values = [int(v) for v in bbox]
            line = "%d, %d, %d, %d, %d, %d, %d, %d\n" % tuple(values)
            lines.append(line)
        io.write_lines(filename, lines)
        # print '1112222222222222'
        print 'result has been written to:', filename

    write_result_as_txt(image_name=image_name,
                        path=path + 'txt/',
                        bboxes=bboxes)
    return path