# danila_lib v1.3.7
python library for Danila
# To install project made
pip install danila-lib
# To use in your project
from danila.danila import Danila
# All use methods are in
class Danila
# main method returns dict {'number', 'prod', 'year'} for openCV rama img or 'no_rama'
def text_recognize(self, img):
# steps for algorythm
# returns string - class of rama, img - openCV frame
def rama_classify(self, img):
# returns openCV frame with rama from openCV frame
def rama_detect(self, img):
# returns openCV image with cut_rama
def rama_cut(self, img):
# returns openCV cut rama with drawn text areas
def text_detect_cut(self, img):
# returns openCV img with drawn text areas
def text_detect(self, img):
# in package data/neuro there is module Rama_classify_class
class Rama_classify_class
# reads CNN taught model and includes it in class example
def __init__():
# makes grey NumPy Array(1,512,512) of doubles[0..1] from openCV image
def prepare_img(img : openCV frame): NumPy Array(1,512,512)[0..1]
# classify openCV img with CNN, returns list with double[0..1] values
def work_img(img : openCV frame): Double[0..1] list
# classify openCV img with CNN, returns Class_im
def classify(img : openCV frame): Class_im
# in package data/neuro there is module Rama_detect_class
class Rama_detect_class
# reads yolov5 taught model from yandex-disk and includes it in class example
def __init__(self, model_path, model_name, yolo_path):
# получить JSON с результатами yolo
def work_img(self, img_path):
# получить координаты прямоугольника с рамой
def rama_detect(self, img_path):
# in package data/neuro there is module Rama_text_detect_class
class Rama_text_detect_class
# reads yolov5 taught model from yandex-disk and includes it in class example
def __init__(self, model_path, model_name, yolo_path):
# find text areas on img from img_path with yolov5, returns yolojson
def work_img(self, img_path):
# find text areas on img from img_path with yolov5, returns dict with rects for each text class
def text_detect(self, img_path):
# draw img_text_areas on img, returns opencv img
def draw_text_areas_in_opencv(self, image_text_areas, img):
# in package data/neuro there is module Letters_recognize
class Letters_recognize:
# main_method takes all image_text_areas from image_rama_cut and recognize text
def work_image_cut(self, image_text_areas, image_rama_cut, number_length, prod_length, year_length):
# read CNN model from yandex and put into object
def __init__(self):
# cut text_areas imgs for each Rect from rect_array returns openCv imgs list
def make_cuts(self, img_rama_cut, rect_array):
# for every text_class recognize text from all areas of text_class, length is depends on class and prod, returns string
def work_image_cuts(self, number_image_cuts, length):
# recognize one word of given length from one img, returns str
def work_img_word(self, image_number, letter_number):
# prepare img of one letter for CNN, returns np_array(1,28,28,1) of Double[0..1]
def prepare_img_letter(self, image_letter):
# recognize img of one letter with CNN, returns list[10] of p
def work_img_letter(self, image_initial):
# recognize img of one letter with CNN, returns letter in str
def classify_letter(self, image_letter):
# in package data/result Rect module for rectangle operations
# прочитать из json результата йоло
@staticmethod
def get_rect_from_yolo_json(yolo_json):
# makes Rect object from xmin, xmax, ymin, ymax
def __init__(self, xmin=0, xmax=0, ymin=0, ymax=0):
# Найти IOU между этим прямоугольником и другим, данным в объекте
def IoU(self, rect):
# makes string from object
def __str__(self):
# find intersection square between object and other rectangle
def intersection(self, rect):
# find union RECT between object and other rectangle
def union(self, rect):
# in package data/result Class_im
class Class_im(Enum):
rama_no_spring = 0
rama_spring = 1
# in package data/result class Text_area
def __init__(self, dict_text_area):
self.class_im = Class_text(dict_text_area['class'])
self.rect = Rect(...)
# in package data/result class image_text_areas
# class contains dict with Rects list for each text_class
class Image_text_areas:
# makes dict {Class_text.number : [], Class_text.prod : [], Class_text.text : [], Class_text.year : []}
def __init__(self):
# add text area to dict
def add_area(self, text_area):
# add list of text areas
def fill_in_with_areas(self, areas):
# delete all cases in which two areas are intersected
def correct_intersections(self):
# changes Rects coordinates from cut_img to whole_img from rama Rect
def explore_to_whole_image(self, rama_rect):
# exapmles of using you can find
https://github.com/Arseniy-Zhuck/danila_lib_demo
Raw data
{
"_id": null,
"home_page": "https://github.com/Arseniy-Zhuck/danila_lib",
"name": "danila-lib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "rama detect machine-learning computer-vision",
"author": "arseniy_zhuck",
"author_email": "arseniyzhuck@mail.ru",
"download_url": "https://files.pythonhosted.org/packages/70/f4/ee4891be164a9d918973f5a5ebc57369fed5e09ab219b33e25ec118ebf67/danila_lib-3.1.0.tar.gz",
"platform": null,
"description": "# danila_lib v1.3.7\r\n python library for Danila\r\n\r\n# To install project made \r\n pip install danila-lib\r\n\r\n\r\n# To use in your project \r\n from danila.danila import Danila\r\n\r\n# All use methods are in \r\n class Danila\r\n\r\n# main method returns dict {'number', 'prod', 'year'} for openCV rama img or 'no_rama'\r\n def text_recognize(self, img):\r\n\r\n# steps for algorythm\r\n\r\n# returns string - class of rama, img - openCV frame\r\n def rama_classify(self, img):\r\n\r\n# returns openCV frame with rama from openCV frame\r\n def rama_detect(self, img):\r\n\r\n# returns openCV image with cut_rama\r\n def rama_cut(self, img):\r\n\r\n# returns openCV cut rama with drawn text areas\r\n def text_detect_cut(self, img):\r\n\r\n# returns openCV img with drawn text areas\r\n def text_detect(self, img):\r\n\r\n# in package data/neuro there is module Rama_classify_class\r\n class Rama_classify_class\r\n\r\n# reads CNN taught model and includes it in class example\r\n def __init__():\r\n\r\n# makes grey NumPy Array(1,512,512) of doubles[0..1] from openCV image\r\n def prepare_img(img : openCV frame): NumPy Array(1,512,512)[0..1]\r\n\r\n# classify openCV img with CNN, returns list with double[0..1] values \r\n def work_img(img : openCV frame): Double[0..1] list\r\n\r\n# classify openCV img with CNN, returns Class_im\r\n def classify(img : openCV frame): Class_im\r\n\r\n# in package data/neuro there is module Rama_detect_class\r\n class Rama_detect_class\r\n# reads yolov5 taught model from yandex-disk and includes it in class example\r\n def __init__(self, model_path, model_name, yolo_path):\r\n# \u0420\u0457\u0420\u0455\u0420\u00bb\u0421\u0453\u0421\u2021\u0420\u0451\u0421\u201a\u0421\u040a JSON \u0421\u0403 \u0421\u0402\u0420\u00b5\u0420\u00b7\u0421\u0453\u0420\u00bb\u0421\u040a\u0421\u201a\u0420\u00b0\u0421\u201a\u0420\u00b0\u0420\u0458\u0420\u0451 yolo\r\n def work_img(self, img_path):\r\n# \u0420\u0457\u0420\u0455\u0420\u00bb\u0421\u0453\u0421\u2021\u0420\u0451\u0421\u201a\u0421\u040a \u0420\u0454\u0420\u0455\u0420\u0455\u0421\u0402\u0420\u0491\u0420\u0451\u0420\u0405\u0420\u00b0\u0421\u201a\u0421\u2039 \u0420\u0457\u0421\u0402\u0421\u040f\u0420\u0458\u0420\u0455\u0421\u0453\u0420\u0456\u0420\u0455\u0420\u00bb\u0421\u040a\u0420\u0405\u0420\u0451\u0420\u0454\u0420\u00b0 \u0421\u0403 \u0421\u0402\u0420\u00b0\u0420\u0458\u0420\u0455\u0420\u2116\r\n def rama_detect(self, img_path):\r\n\r\n# in package data/neuro there is module Rama_text_detect_class\r\n class Rama_text_detect_class\r\n\r\n# reads yolov5 taught model from yandex-disk and includes it in class example\r\n def __init__(self, model_path, model_name, yolo_path):\r\n\r\n# find text areas on img from img_path with yolov5, returns yolojson\r\n def work_img(self, img_path):\r\n\r\n# find text areas on img from img_path with yolov5, returns dict with rects for each text class\r\n def text_detect(self, img_path):\r\n\r\n# draw img_text_areas on img, returns opencv img\r\n def draw_text_areas_in_opencv(self, image_text_areas, img):\r\n\r\n# in package data/neuro there is module Letters_recognize\r\n class Letters_recognize:\r\n\r\n# main_method takes all image_text_areas from image_rama_cut and recognize text \r\n def work_image_cut(self, image_text_areas, image_rama_cut, number_length, prod_length, year_length):\r\n\r\n# read CNN model from yandex and put into object\r\n def __init__(self):\r\n\r\n# cut text_areas imgs for each Rect from rect_array returns openCv imgs list\r\n def make_cuts(self, img_rama_cut, rect_array):\r\n\r\n# for every text_class recognize text from all areas of text_class, length is depends on class and prod, returns string \r\n def work_image_cuts(self, number_image_cuts, length):\r\n\r\n# recognize one word of given length from one img, returns str\r\n def work_img_word(self, image_number, letter_number):\r\n\r\n# prepare img of one letter for CNN, returns np_array(1,28,28,1) of Double[0..1]\r\n def prepare_img_letter(self, image_letter):\r\n\r\n# recognize img of one letter with CNN, returns list[10] of p\r\n def work_img_letter(self, image_initial):\r\n\r\n# recognize img of one letter with CNN, returns letter in str\r\n def classify_letter(self, image_letter):\r\n\r\n# in package data/result Rect module for rectangle operations\r\n# \u0420\u0457\u0421\u0402\u0420\u0455\u0421\u2021\u0420\u0451\u0421\u201a\u0420\u00b0\u0421\u201a\u0421\u040a \u0420\u0451\u0420\u00b7 json \u0421\u0402\u0420\u00b5\u0420\u00b7\u0421\u0453\u0420\u00bb\u0421\u040a\u0421\u201a\u0420\u00b0\u0421\u201a\u0420\u00b0 \u0420\u2116\u0420\u0455\u0420\u00bb\u0420\u0455\r\n @staticmethod\r\n def get_rect_from_yolo_json(yolo_json):\r\n# makes Rect object from xmin, xmax, ymin, ymax\r\n def __init__(self, xmin=0, xmax=0, ymin=0, ymax=0):\r\n# \u0420\u045c\u0420\u00b0\u0420\u2116\u0421\u201a\u0420\u0451 IOU \u0420\u0458\u0420\u00b5\u0420\u00b6\u0420\u0491\u0421\u0453 \u0421\u040c\u0421\u201a\u0420\u0451\u0420\u0458 \u0420\u0457\u0421\u0402\u0421\u040f\u0420\u0458\u0420\u0455\u0421\u0453\u0420\u0456\u0420\u0455\u0420\u00bb\u0421\u040a\u0420\u0405\u0420\u0451\u0420\u0454\u0420\u0455\u0420\u0458 \u0420\u0451 \u0420\u0491\u0421\u0402\u0421\u0453\u0420\u0456\u0420\u0451\u0420\u0458, \u0420\u0491\u0420\u00b0\u0420\u0405\u0420\u0405\u0421\u2039\u0420\u0458 \u0420\u0406 \u0420\u0455\u0420\u00b1\u0421\u0409\u0420\u00b5\u0420\u0454\u0421\u201a\u0420\u00b5\r\n def IoU(self, rect):\r\n# makes string from object\r\n def __str__(self):\r\n\r\n# find intersection square between object and other rectangle\r\n def intersection(self, rect):\r\n# find union RECT between object and other rectangle\r\n def union(self, rect):\r\n# in package data/result Class_im\r\n class Class_im(Enum):\r\n rama_no_spring = 0\r\n rama_spring = 1\r\n\r\n# in package data/result class Text_area\r\n def __init__(self, dict_text_area):\r\n self.class_im = Class_text(dict_text_area['class'])\r\n self.rect = Rect(...)\r\n\r\n# in package data/result class image_text_areas\r\n# class contains dict with Rects list for each text_class\r\n class Image_text_areas:\r\n\r\n# makes dict {Class_text.number : [], Class_text.prod : [], Class_text.text : [], Class_text.year : []} \r\n def __init__(self):\r\n\r\n# add text area to dict\r\n def add_area(self, text_area):\r\n\r\n# add list of text areas\r\n def fill_in_with_areas(self, areas):\r\n\r\n# delete all cases in which two areas are intersected\r\n def correct_intersections(self):\r\n\r\n# changes Rects coordinates from cut_img to whole_img from rama Rect\r\n def explore_to_whole_image(self, rama_rect):\r\n\r\n# exapmles of using you can find \r\nhttps://github.com/Arseniy-Zhuck/danila_lib_demo\r\n",
"bugtrack_url": null,
"license": null,
"summary": "This is the module for detecting and classifying text on rama pictures",
"version": "3.1.0",
"project_urls": {
"GitHub": "https://github.com/Arseniy-Zhuck/danila_lib",
"Homepage": "https://github.com/Arseniy-Zhuck/danila_lib"
},
"split_keywords": [
"rama",
"detect",
"machine-learning",
"computer-vision"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "99eb98be0916ba58df9a2fd6d19816718a6a6883b4612922abd86747feadfce2",
"md5": "d35783df120b2d5e92d3a8f69af55466",
"sha256": "14d8326ea3c2dd79c6e8129c68f12419ccb80327b4e697854f46ea77eb17eeb2"
},
"downloads": -1,
"filename": "danila_lib-3.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d35783df120b2d5e92d3a8f69af55466",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 152259,
"upload_time": "2024-10-11T14:07:49",
"upload_time_iso_8601": "2024-10-11T14:07:49.018791Z",
"url": "https://files.pythonhosted.org/packages/99/eb/98be0916ba58df9a2fd6d19816718a6a6883b4612922abd86747feadfce2/danila_lib-3.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "70f4ee4891be164a9d918973f5a5ebc57369fed5e09ab219b33e25ec118ebf67",
"md5": "f6f6348e4e0e7e40cacd1ec7499cad2f",
"sha256": "cc783057d10beb71f576d4f75190e6fb1624ffff5e8049dce51689b13bab14d4"
},
"downloads": -1,
"filename": "danila_lib-3.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f6f6348e4e0e7e40cacd1ec7499cad2f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 46849,
"upload_time": "2024-10-11T14:07:51",
"upload_time_iso_8601": "2024-10-11T14:07:51.522322Z",
"url": "https://files.pythonhosted.org/packages/70/f4/ee4891be164a9d918973f5a5ebc57369fed5e09ab219b33e25ec118ebf67/danila_lib-3.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 14:07:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Arseniy-Zhuck",
"github_project": "danila_lib",
"github_not_found": true,
"lcname": "danila-lib"
}