├── Image to sketch ├── img2sketch.py └── ranveer.jpg ├── README.md └── Text_to_Handwritten_Text_Converter-master ├── meta ├── app.ico └── writing.png ├── pywhatkit_dbs.txt ├── requirements.txt └── text_to_HWT.py /Image to sketch/img2sketch.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | img = cv2.imread('C:/Users/maina/Desktop/rid.jpg') 4 | gi = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 5 | inv_gr_img = 255 - gi 6 | bi = cv2.GaussianBlur(inv_gr_img, (21,21), 0) 7 | inv_bl = 255 - bi 8 | pencil_sk = cv2.divide(gi, inv_bl, scale = 256.0) 9 | pencil = pencil_sk-45 10 | cv2.imshow('Actual Image',img) 11 | 12 | cv2.imshow('Pencil Sketch',pencil) 13 | 14 | 15 | cv2.waitKey(0) 16 | cv2.destroyAllWindows() 17 | 18 | # to use it in a loop 19 | k = cv2.waitKey(0) 20 | if k == 27: # wait for ESC key to exit 21 | cv2.destroyAllWindows() 22 | elif k == ord('s'): 23 | cv2.imwrite('image.png',img) 24 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /Image to sketch/ranveer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/OpenCV-Projects/de829045d970a8d321f4c995e536c23fbc9b448b/Image to sketch/ranveer.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenCV-Projects 2 | Some computer vision projects 3 | -------------------------------------------------------------------------------- /Text_to_Handwritten_Text_Converter-master/meta/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/OpenCV-Projects/de829045d970a8d321f4c995e536c23fbc9b448b/Text_to_Handwritten_Text_Converter-master/meta/app.ico -------------------------------------------------------------------------------- /Text_to_Handwritten_Text_Converter-master/meta/writing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MainakRepositor/OpenCV-Projects/de829045d970a8d321f4c995e536c23fbc9b448b/Text_to_Handwritten_Text_Converter-master/meta/writing.png -------------------------------------------------------------------------------- /Text_to_Handwritten_Text_Converter-master/pywhatkit_dbs.txt: -------------------------------------------------------------------------------- 1 | -------------------- 2 | -------------------------------------------------------------------------------- /Text_to_Handwritten_Text_Converter-master/requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow==7.1.2 2 | pywhatkit==4.7 -------------------------------------------------------------------------------- /Text_to_Handwritten_Text_Converter-master/text_to_HWT.py: -------------------------------------------------------------------------------- 1 | from PIL import ImageTk 2 | import PIL.Image 3 | import tkinter as tk 4 | import pywhatkit as kit 5 | from tkinter import * 6 | from tkinter import colorchooser 7 | from tkinter.ttk import Progressbar 8 | import time 9 | import datetime 10 | from threading import * 11 | from pathlib import Path 12 | import os 13 | 14 | ## To create 'results' directory if not exist 15 | repn = Path('results') 16 | if repn.is_dir(): 17 | pass 18 | else: 19 | os.mkdir('results') 20 | 21 | windo = Tk() 22 | windo.configure(background='black') 23 | windo.title("Text to Handwritten Text Converter App") 24 | width = windo.winfo_screenwidth() 25 | height = windo.winfo_screenheight() 26 | windo.geometry(f'{width}x{height}') 27 | windo.iconbitmap('./meta/app.ico') 28 | # windo.resizable(0,0) 29 | color_result_rgb = [0,0,0] 30 | 31 | def threading(): 32 | # Call work function 33 | t1=Thread(target=convert_txt_to_HW) 34 | t1.start() 35 | 36 | def convert_txt_to_HW(): 37 | text = txt2.get("1.0",END) 38 | ts = time.time() 39 | dat = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 40 | timeStam = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S') 41 | Hour, Minute, Second = timeStam.split(":") 42 | fileN = "./results/" + dat + "_" + Hour + "-" + Minute + "-" + Second + ".png" 43 | img_txt = kit.text_to_handwriting(text,fileN,rgb = color_result_rgb) 44 | 45 | def bar(): 46 | progress['value'] = 20 47 | windo.update_idletasks() 48 | time.sleep(1) 49 | progress['value'] = 40 50 | windo.update_idletasks() 51 | time.sleep(1) 52 | progress['value'] = 60 53 | windo.update_idletasks() 54 | time.sleep(1) 55 | progress['value'] = 80 56 | windo.update_idletasks() 57 | time.sleep(1) 58 | progress['value'] = 100 59 | windo.update_idletasks() 60 | progress.destroy() 61 | 62 | progress = Progressbar(windo, orient=HORIZONTAL, length=100, mode='determinate') 63 | progress.place(x=770, y=652) 64 | bar() 65 | 66 | conv_text_lbl.config(text="Handwritten Text", width=15, height=2, fg="#00FF89", bg="blue", 67 | font=('segou UI', 16, ' bold')) 68 | conv_text_lbl.place(x=990, y=157) 69 | 70 | im2 = PIL.Image.open(fileN) 71 | im2 = im2.resize((887, 402), PIL.Image.ANTIALIAS) 72 | sp_img2 = ImageTk.PhotoImage(im2) 73 | panel6.config(image=sp_img2) 74 | panel6.image = sp_img2 75 | panel6.pack() 76 | panel6.place(x=1005, y=237) 77 | 78 | def destroy_widget(widget): 79 | widget.destroy() 80 | 81 | def clear_txt(): 82 | txt2.delete("1.0",END) 83 | 84 | def color_choose(): 85 | global color_result_rgb 86 | color_code = colorchooser.askcolor(title ="Choose color") 87 | color_result_rgb = ' '.join(str(int(x)) for x in color_code[0]) 88 | color_result_rgb = color_result_rgb.split(' ') 89 | # color_tup = tuple(color_result_rgb) 90 | 91 | color_tup = [int(item) for item in color_result_rgb] 92 | color_tup = tuple(color_tup) 93 | print(color_tup) 94 | colordis_lbl.configure(bg = _from_rgb(color_tup)) 95 | colordis_lbl.place(x=680, y=652) 96 | 97 | def _from_rgb(rgb): 98 | """translates an rgb tuple of int to a tkinter friendly color code 99 | """ 100 | return "#%02x%02x%02x" % rgb 101 | 102 | title = tk.Label(windo, text="Text to Handwritten Text Converter", width=56, height=2, fg="#00FF89",bg="#8B13F3", 103 | font=('segou UI', 28, ' bold italic')) 104 | title.place(x=0, y=20) 105 | 106 | enter_text_lbl = tk.Label(windo, text="Enter your text", width=15, height=2, fg="#00FF89",bg="blue", 107 | font=('segou UI', 16, ' bold')) 108 | enter_text_lbl.place(x=10, y=170) 109 | 110 | im1 = PIL.Image.open('./meta/writing.png') 111 | im1 =im1.resize((150,110), PIL.Image.ANTIALIAS) 112 | sp_img = ImageTk.PhotoImage(im1) 113 | panel5 = Label(windo,borderwidth=0, image=sp_img,bg = '#8B13F3') 114 | panel5.pack() 115 | panel5.place(x=315, y=30) 116 | 117 | txt2_border = Frame(windo,borderwidth = 3, background="#8B13F3") 118 | txt2 = tk.Text(txt2_border,borderwidth = 1, width=70,height=13, bg='black', fg="white", font=('times', 13, ' bold ')) 119 | txt2.pack(padx=1, pady=1) 120 | txt2_border.place(x=30, y=235) 121 | 122 | conv_border = Frame(windo,borderwidth = 2, background="#8B13F3") 123 | conv= Button(conv_border,text='Convert Text',command = threading, bg='black', fg="#00FF89", font=('times', 15, ' bold '),activebackground = "#00FF89") 124 | conv.pack(padx=1, pady=1) 125 | conv_border.place(x=30, y=650) 126 | 127 | clear_border = Frame(windo,borderwidth = 2, background="#8B13F3") 128 | clear = Button(clear_border,text='Clear Text',command = clear_txt, bg='black', fg="#00FF89", font=('times', 15, ' bold '),activebackground = "#00FF89") 129 | clear.pack(padx=1, pady=1) 130 | clear_border.place(x=255, y=650) 131 | 132 | color_border = Frame(windo,borderwidth = 2, background="#8B13F3") 133 | color = Button(color_border,text='Choose Color',command = color_choose, bg='black', fg="#00FF89", font=('times', 15, ' bold '),activebackground = "#00FF89") 134 | color.pack(padx=1, pady=1) 135 | color_border.place(x=445, y=650) 136 | 137 | colordis_lbl = tk.Label(windo, width=6, height=2, fg="#00FF89",bg="green") 138 | 139 | panel6 = Label(windo,borderwidth=0) 140 | 141 | conv_text_lbl = tk.Label(windo, text="Enter your text", width=15, height=2, fg="#00FF89",bg="blue", 142 | font=('segou UI', 16, ' bold')) 143 | 144 | windo.mainloop() --------------------------------------------------------------------------------