{"id":48217375,"url":"https://github.com/q-viper/final-devanagari-word-char-detector","last_synced_at":"2026-04-04T19:00:58.200Z","repository":{"id":116043811,"uuid":"218929020","full_name":"q-viper/final-devanagari-word-char-detector","owner":"q-viper","description":"A Academic project done during 7th semester. Read blog at https://q-viper.github.io/2020/09/30/ocr-for-devanagari-handwritten-character-recognition-building-a-classifier/","archived":false,"fork":false,"pushed_at":"2022-12-10T09:51:29.000Z","size":98786,"stargazers_count":9,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-06T06:01:32.144Z","etag":null,"topics":["character-recognition","csit","deep-learning","devanagari","devanagari-character-dataset","hacktoberfest","project"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/q-viper.png","metadata":{"files":{"readme":"ReadMe.txt","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-11-01T06:46:40.000Z","updated_at":"2023-02-14T09:50:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"e4183e67-93fb-4745-85a8-da9042ebac22","html_url":"https://github.com/q-viper/final-devanagari-word-char-detector","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/q-viper/final-devanagari-word-char-detector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/q-viper%2Ffinal-devanagari-word-char-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/q-viper%2Ffinal-devanagari-word-char-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/q-viper%2Ffinal-devanagari-word-char-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/q-viper%2Ffinal-devanagari-word-char-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/q-viper","download_url":"https://codeload.github.com/q-viper/final-devanagari-word-char-detector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/q-viper%2Ffinal-devanagari-word-char-detector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31409471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["character-recognition","csit","deep-learning","devanagari","devanagari-character-dataset","hacktoberfest","project"],"created_at":"2026-04-04T19:00:28.583Z","updated_at":"2026-04-04T19:00:58.119Z","avatar_url":"https://github.com/q-viper.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"=================================================================================================================================================================\n=================================================================================================================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDevanagari Character and Word Recognition \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAuthor: Quassarian Viper\n\n=================================================================================================================================================================\n=================================================================================================================================================================\n1. Requirements:\n\tFor dependencies open project demonstration notebook.\n\tFurther if you want to train for yourself then you need dataset also and may be 1 day of train time. I recommend google colab for train.\n\t\n2. Time taken:\n\t- Model creation: 20 days(7 hours /day at least)\n\t\t- Data Collection\n\t\t- Data Manipulation\n\t\t- Data Analysis\n\t\t- Model Design\n\t\t- Model Model Creation\n\t\t- Model train/validation\n\t\t- Model Analysis\n\t\t- Model Delivery\n\t\n\t- Recognition Model: 7 days(12 hours / day at least)\n\t\t- Image Acquistion\n\t\t- Image Preprocessing\n\t\t- Image Thresholding\n\t\t- Image Manipulation\n\t\t- Text Detection\n\t\t- Text Localization\n\t\t- Text Recognition\n\t\t\nWe have main.py, video_test.py, recognition.py, predictor.py python files. From main.py, we call different functions and they further calls others. Here is the complete algorithm:\nA. Main.py:\n1. For each program run:\n    1.a. Try:\n        i. Ask for image directory\n        ii. Open the given directory\n        iii. If the directory image exists then call recognition function\n        iv. Else go to except block\n    2.a. Except:\n        i. Call the camera funtction\n        \nB. Video_test.py:\nInside camera function, capture every frame of video. And for every frame of video do:\n1. Define the size of square where image should align.\n2. Convert every frame to Grayscale\n3. Crop the frame from the aligned area\n4. Define wait key for key event\n    4.a. If key is 'spacebar' then call recognition(gray, 'show')\n    4.b. If key is 'enter' then call recognition(gray, 'no')\n    4.c. If key is 'escape' then exit the camera window\n    4.d. Else do nothing and show camera running.\n\nC. Recognition.py:\nInside recognition function:\n1. Call preprocess function and recieve segments of image, template, th_img, text_color\n2. Create list for labels, accuracy and also make a copy of input image\n3. For each segment:\n    3.a. Call detect_text function and recieve recognize image and bordered image.\n    3.b. Call prediction function and receive label of segment and accuracy.\n    3.c. Append segment accuracy, label\n    3.d. If accruacy is more than 80:    \n        3.d.i. Call dectect_image and receive the image where that is located. \n        3.d.ii. Call localize and receive image where segement is located.\n4. If the average accuracy is less than 80 then:\n    4.a. Call dectect_image and receive the image where that is located.\n    4.b. Call localize and receive image where segement is located.\n    4.c. Call prediction function and receive label of segment and accuracy.\n    \n5. If the input image was photo then:\n        5.a. Show RGB image\n         Else:\n                View the frame.\n6. Show prediction and accuracy of entire process.\n\nD. predictor.py\nInside prediction function:\n    1. Open the saved model and load it\n    2. Prepare the labels.\n    3. Convert the input image to model's input shape\n    4. Do prediction \n    5. Return label and accurracy\n\nE. preprocess.py\n1. preprocess function:\n    1.a. Add gaussian blur\n    1.b. Threshold image to binary\n    1.c. Find the background color by checking 5 pixels from left corner\n    1.d. Call borders function and receive top/down and left/right borders\n    1.e. Create template image by cropping image and adding dummy borders.\n    1.f. Call segmentation function and receive segnents\n    1.g. Return segments, template, thresholded image and text color.\n    \n2. borders function\n    2.a. Define the checking value by 20% of number of extreme rows, define top, down.\n    2.b. Make a array with all text_color value of shape of columns.\n    2.c. For each rows:\n        2.c.i. If any of pixels matches with previous array then increase count, the number of useful rows. Else make count zero.\n        2.c.ii. If count becomes greater or equal than check then make top = row - check and break. This is our top border.\n     2.d. Reverse the image and do for each rows:\n         2.d.i. If any of pixels matches with previous array then increase count, the number of useful rows. Else make count zero.\n         2.d.ii. If count becomes greater or equal than check then make top = row + check and break. This is our bottom border.\n         2.e. Define dummy values to prevent all background loss on borders.\n\n3. segmentation function:\n    3.a. Try:\n        3.a.i. Define check as 15% of rows and we remove that 15% of top rows as they must be tick, find shape and tilt the cropped image \n        3.a.ii. Define backgroound colored array\n        3.a.iii. for each row on tilted image:\n            - if  that row's all value is equal to colored row then append that row\n        3.a.iv. Define new keys for final segmenting rows\n        3.a.v. For each key in keys:\n            - if the difference between consecutive keys are greater than check then add that key to new keys.\n        3.a.vi. Sort new keys\n        3.a.vii. For each sorted keys:\n            - untilt the bordered image and take segment between each key then append it to segmented templates by tilting.\n        3.a.viii. Append first and last segments\n        3.a.ix. For each segment:\n            - if shape of row and column of segment is less than 5% of entire row and column then remove that segment\n        3.a.x. Return segments\n     3.b. Except:\n         - return input image\n\n4. detect_text function:\n    4.a. Convert input image into 30 * 30 and add background border around it by 1 pixel on each side and return this image.\n\n5. localize function:\n    5.a. Take template and match it on the thresholded image\n    5.b. Take the points where 80% of template matches \n    5.c. Make a rectangle around those points on the original RGB image and return localized image\n\n\n        \n# Devanagari-Character-Recognition\nThis is the final project of 7th semester BSC.CSIT.\n\u003ch1 align = 'center'\u003eIntroduction\u003c/h1\u003e\nDevanagari is the national font of Nepal and is used widely throughout the India also. It contains 10 numerals(०, १, २, ३, ४, ५, ६, ७, ८, ९) and 36 consonants (क, ख, ग, घ, ङ, च, छ, ज, झ, ञ, ट, ठ, ड, ढ, ण, त, थ, द, ध,न, प,फ, ब, भ, म, य, र, ल, व, श, ष, स, ह, क्ष, त्र, ज्ञ). Some consonants are complex and made by combine some other. However, throughout this project i considered them as single character.\n\nThe required dataset is publicly available on the \u003ca href = 'https://web.archive.org/web/20160307001701/http://cvresearchnepal.com/wordpress/dhcd/'\u003e link.\u003c/a\u003e \n\n\u003ch1 align = 'center'\u003e Implementation \u003c/h1\u003e\nFor this project i am using python 3.6 on anaconda. More importantly i am running it on Jupyter Notebook sometimes but \u003cstrong\u003eGoogle Colab\u003c/strong\u003e is what is used most. The dependencies and libraries i used are:\u003cbr\u003e\nPython 3.6\u003cbr\u003e\nNumpy\u003cbr\u003e\nMatplotlib\u003cbr\u003e\nOpenCv\u003cbr\u003e\nKeras\u003cbr\u003e\n\n\u003ch3\u003eFor better project information start with \u003ca href = \"https://github.com/q-viper/Devanagari-Character-Recognition/blob/master/Proj_demonstration.ipynb\"\u003eProject Demonstration\u003c/a\u003e.\u003cbr\u003e For more information please visit the drive link and feel free to edit. \u003ca href = 'https://drive.google.com/open?id=1tB4SYR4f0-narJk-OWi1LzVRNPG8WrUB'\u003eClick here for entire project on drive link.\u003c/a\u003e And plese help me improve it.\u003c/h3\u003e\n\n\t\n\t","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fq-viper%2Ffinal-devanagari-word-char-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fq-viper%2Ffinal-devanagari-word-char-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fq-viper%2Ffinal-devanagari-word-char-detector/lists"}