def save(self, shape, prefix): prefix = self.get_workspace() / prefix shape.save(prefix + '.stl') import sketch sketch.sketch(shape, prefix + '-sketch.svg')
def save(self, shape, prefix): prefix = self.get_workspace()/prefix shape.save(prefix + '.stl') import sketch sketch.sketch(shape, prefix + '-sketch.svg')
def gen_sketch(rv_number = 100): t0 = time.clock() m = open_sig() print "signature matrix size is {0} x {1}".format(m.shape[0], m.shape[1]) sketches = sketch(m, rv_number) print "sketch matrix size is {0} x {1}".format(sketches.shape[0], sketches.shape[1]) print time.clock() - t0, "seconds in generating sketches" savetxt('sketch.txt', sketches, fmt='%d')
def sketch(): t0 = time.clock() m = open_sig() print "signature matrix size is {0} x {1}".format(m.shape[0], m.shape[1]) sketches = sketch(m, rv_number) print "sketch matrix size is {0} x {1}".format(sketches.shape[0], sketches.shape[1]) print time.clock() - t0, "seconds in generating sketches" savetxt('result/sketch.txt', sketches, fmt='%d')
def operation(): global filename, current_file # print(filename) if "cartoonize" in request.form: img = cv2.imread('static/uploads/'+filename) prev_filename = filename name = filename.split('.') filename1 = name[0]+"_1."+name[1] current_file = filename1 img = cartoon(img) cv2.imwrite(os.path.join(app.config['UPLOAD_FOLDER'], filename1),img) return render_template('home.html', filename=prev_filename, filename_1 = filename1) elif "sketch" in request.form: img = cv2.imread('static/uploads/'+filename) prev_filename = filename name = filename.split('.') filename2 = name[0]+"_2."+name[1] current_file = filename2 img = sketch(img) cv2.imwrite(os.path.join(app.config['UPLOAD_FOLDER'], filename2),img) return render_template('home.html', filename=prev_filename, filename_2 = filename2) else: return render_template('home.html')
main function ''' if __name__ == "__main__": c = sys.argv[1] if len(sys.argv) > 1 else "" if c == "sig": sig() elif c == "sketch": if len(sys.argv) > 2: rv = int(sys.argv[2]) else: rv = 256 print 'INFO: ', rv, ' random vectors' sketch(rv) elif c == "cos": cos() elif c == "matrix": matrix() elif c == "similar": if len(sys.argv) > 4: similar(int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4])) else: print 'ERROR: Please identify the picture id.' elif c == "all": similar_all()
import sketch texture = sketch.sketch() texture.learn() new_Texture = texture.sample() sketch.paint(new_Texture)