{"id":384249,"date":"2024-06-29T05:23:46","date_gmt":"2024-06-29T05:23:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=384249"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=384249","title":{"rendered":"<span>\u0423\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u043d\u0430 Python + OpenCV \u0441 \u0441\u0430\u043c\u044b\u0445 \u0430\u0437\u043e\u0432. \u0427\u0430\u0441\u0442\u044c 9. \u041c\u043e\u0439 \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: <a href=\"https:\/\/habr.com\/ru\/articles\/688316\/\" rel=\"noopener noreferrer nofollow\">\u0423\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. \u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \/ \u0425\u0430\u0431\u0440 (habr.com)<\/a><\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430, \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u043c \u0437\u0440\u0435\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0435\u0433\u043e \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430 \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u043c \u0437\u0440\u0435\u043d\u0438\u0438. \u0412 \u0441\u0432\u043e\u0435\u043c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440, \u0433\u0434\u0435 \u044d\u0442\u0438 \u0441\u0442\u0430\u0434\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u0431 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (\u0444\u0438\u0447).<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043d\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0430\u0434\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u0434\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0430\u0434\u0438\u0438. <\/p>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0440\u0430\u0434\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430 \u043a\u0430\u043a-\u0442\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e. \u041d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u0435\u043b\u0430\u043b\u0430 \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0441\u043e \u0441\u043f\u0443\u0442\u043d\u0438\u043a\u043e\u0432 \u0438 \u0411\u041b\u0410 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b \u0438\u0445 \u0432 \u0433\u0440\u0430\u0444 (\u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u0438\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/523484\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0433\u0438\u0441\u0442\u0435\u0440\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u0441\u0435\u0440\u0442\u0430\u0446\u0438\u0438<\/a>). \u041f\u0440\u0430\u0432\u0434\u0430, \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u0430\u043c\u0431\u0438\u0446\u0438\u043e\u0437\u043d\u0430\u044f \u0437\u0430\u0434\u0443\u043c\u043a\u0430 \u0434\u043b\u044f \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041d\u0430\u0434\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e- \u043f\u0440\u043e\u0449\u0435. \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0443\u0440\u043e\u043a\u043e\u0432 \u043c\u043d\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0438\u043d\u0430\u043b\u0435 \u043f\u0430\u0440\u0443 \u0433\u043b\u0430\u0432 \u043f\u0440\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u043a. \u0418 \u0432\u043e\u0442 \u044f \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u043c\u043e\u0436\u0435\u0442, \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438? \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432? \u042d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0443\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0443\u0434\u0430 \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438: Exec \u0438 Libraries. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0443 \u043c\u0435\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u0444\u0430\u0439\u043b\u044b, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043b Core.py:<\/p>\n<pre><code class=\"python\">class Engine:     \"\"\"\"\u0414\u0432\u0438\u0436\u043e\u043a\"\"\"     pass  class ImageProcessingStep:     \"\"\"\u0428\u0430\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\"\"\"     pass  class ImageInfo:     \"\"\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\"\"\"     pass<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0438 \u0432 Core.py, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u0430\u043a\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u044e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">class Engine:     \"\"\"\"\u0414\u0432\u0438\u0436\u043e\u043a\"\"\"      def __init__(self):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\"\"\"          self.steps=[]      def process(self, image):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.         image - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\"\"\"          current_info=ImageInfo(image)         for step in self.steps:             current_info=step.process(current_info)         return current_info <\/code><\/pre>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 ImageInfo, \u0430 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 ImageProcessingStep \u043d\u0430\u0434\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 process. \u0418, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, ImageProcessingStep \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0421\u0442\u043e\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 Python \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0435\u0442 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u044b\u0445 (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 C#), \u043e\u043d\u0438 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u041d\u043e \u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u043c\u0443 \u0440\u0430\u0441\u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u0440\u0430\u0437 \u00ab\u043d\u0435\u0442\u00bb \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043d\u0435\u0442\u00bb. <\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u044f \u0441\u0434\u0435\u043b\u0430\u044e \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 pass:<\/p>\n<pre><code class=\"python\">class ImageProcessingStep:     \"\"\"\u0428\u0430\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\"\"\"      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"         pass <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c ImageInfo. \u041f\u043e \u0438\u0434\u0435\u0435, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0448\u0430\u0433\u0430, \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0410 \u043f\u043e\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<pre><code class=\"python\">class ImageInfo:     \"\"\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\"\"\"      def __init__(self,image):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\"\"\"          self.image=image <\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u00ab\u043d\u0430\u0442\u044f\u043d\u0443\u0442\u044c\u00bb \u043d\u0430 \u044d\u0442\u0443 \u0441\u0445\u0435\u043c\u0443 \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u043a\u043b\u0430\u0441\u0441 ImageProcessingStep \u0432 \u0444\u0430\u0439\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441 \u0432 ImageProcessingSteps.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">class MedianBlurProcessingStep(ImageProcessingStep):     \"\"\"\u0428\u0430\u0433, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u0430 \u041c\u0435\u0434\u0438\u0430\u043d\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f\"\"\"      def __init__(self,ksize):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440         ksize - \u0440\u0430\u0437\u043c\u0435\u0440 \u044f\u0434\u0440\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\"\"\"          self.ksize=ksize      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"          median_image = cv2.medianBlur(info.image, self.ksize)         info.filtered_image=median_image         return info <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Exec, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b run.py. \u0412\u043e\u0442 \u0442\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/273\/c28\/e92\/273c28e926787313e1d91b880606d18c.png\" width=\"345\" height=\"259\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/273\/c28\/e92\/273c28e926787313e1d91b880606d18c.png\"\/><\/figure>\n<p>\u041d\u0443 \u0438 \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 run.py:<\/p>\n<pre><code class=\"python\">import cv2  from Libraries.Core import Engine from Libraries.ImageProcessingSteps import MedianBlurProcessingStep  my_photo = cv2.imread('..\/Photos\/MyPhoto1.jpg') core=Engine() core.steps.append(MedianBlurProcessingStep(5)) info=core.process(my_photo)  cv2.imshow('origin', info.image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e cv2.imshow('res', info.filtered_image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()  <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u043e\u0434\u043d\u0443 \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438, \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438. \u0414\u0430, \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/654663\/\" rel=\"noopener noreferrer nofollow\">\u0443\u0440\u043e\u043a\u0435 3<\/a>, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u043e\u0439 \u041e\u041e\u041f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0447\u0435\u0440\u0435\u0437 tesseract. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 tesseract. \u0418 \u0442\u0430\u043a, \u0441\u0442\u0430\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<p><code>pip install pytesseract<\/code><\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/github.com\/UB-Mannheim\/tesseract\/wiki\" rel=\"noopener noreferrer nofollow\">Home \u00b7 UB-Mannheim\/tesseract Wiki (github.com)<\/a> \u0438 \u043a\u0430\u0447\u0430\u0435\u043c \u043e\u0442\u0442\u0443\u0434\u0430 \u0441\u0430\u043c\u0443 tesseract. \u0415\u0441\u043b\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f (\u043c\u0430\u043b\u043e \u043b\u0438, \u0432\u0441\u0435 \u0442\u0435\u0447\u0435\u0442, \u0432\u0441\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f), \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0442\u0435. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043a\u0430\u0447\u0430\u043b\u0438 tesseract \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0430 Python \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<pre><code class=\"python\">import cv2 import pytesseract  pytesseract.pytesseract.tesseract_cmd = \"D:\\\\Program Files\\\\Tesseract-OCR\\\\tesseract.exe\"  img = cv2.imread('image.jpg') print(pytesseract.image_to_string(img, lang = 'rus')) <\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de8\/f21\/e72\/de8f21e72eff470c4edceb381e93765a.png\" width=\"646\" height=\"279\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de8\/f21\/e72\/de8f21e72eff470c4edceb381e93765a.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (\u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0432\u043e\u0440\u0434\u0430) \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 (\u043c\u043e\u0436\u0435\u0442, \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c). <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0441\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043d\u0438\u0433\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b31\/3e0\/9f9\/b313e09f96eef298ad459f0e2344c6c2.png\" width=\"640\" height=\"975\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b31\/3e0\/9f9\/b313e09f96eef298ad459f0e2344c6c2.png\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a9\/564\/96f\/6a956496fbfef374226cdad20080f106.png\" width=\"639\" height=\"445\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a9\/564\/96f\/6a956496fbfef374226cdad20080f106.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435-\u0442\u043e \u0441\u043b\u043e\u0432\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b\u0438\u0441\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0433\u0434\u0435-\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0432\u043e. <\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d, \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u0439 \u043d\u044e\u0430\u043d\u0441. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0439 \u0442\u0435\u043a\u0441\u0442. \u041d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0431\u043b\u043e\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0447\u0435\u0440\u0442\u0435\u0436\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0442 \u0447\u0435\u0440\u0442\u0435\u0436 \u043e\u0446\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0448\u0442\u0430\u043c\u043f\u0438\u043a \u0447\u0435\u0440\u0442\u0435\u0436\u0430, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043f\u0438\u0441\u0438 \u043d\u0430 \u0432\u044b\u043d\u043e\u0441\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u0438 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u0434\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438? \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u0437\u043e\u043d\u044b, \u0438 \u044d\u0442\u0438 \u0437\u043e\u043d\u044b \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u043b\u0438\u0441\u044c tesseract.<\/p>\n<p>\u041d\u043e \u0432 \u043c\u043e\u0435\u043c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430. \u0417\u043d\u0430\u044e, \u044d\u0442\u043e \u0443\u0436\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0430\u044f\u043d\u0435\u0441\u0442\u044b\u0439 \u0431\u0430\u044f\u043d, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043f\u0438\u0448\u0443\u0442 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443. \u0418 \u0434\u0430\u0436\u0435 \u0446\u0435\u043b\u044b\u0435 \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0435. \u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u043d\u0430\u0434\u043e \u0436\u0435 \u0441 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c. \u0410 \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0443\u044e \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<p>\u041f\u043e\u0441\u0442\u0443\u043f\u043b\u044e \u044f, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041d\u0430\u0433\u0443\u0433\u043b\u044e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432, \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0432\u044b\u0431\u0435\u0440\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u0430\u0447\u043d\u044b\u0439, \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u043a\u043e\u0434 \u0432 \u043c\u043e\u0439 \u041e\u041e\u041f-\u0448\u0430\u0431\u043b\u043e\u043d. \u041f\u043e\u0435\u0445\u0430\u043b\u0438. \u041d\u0430\u0448\u0435\u043b \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u043e\u043b\u0438\u043a:<\/p>\n<p><a href=\"https:\/\/rutube.ru\/video\/b72b22d99ab60105eed1c40a1ac8c880\/\" rel=\"noopener noreferrer nofollow\"><u>[Python] \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 OpenCV | \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u043d\u043b\u0430\u0439\u043d \u0432\u0438\u0434\u0435\u043e \u043e\u0442 Boris Bochkarev | BeTry \u0432 \u0445\u043e\u0440\u043e\u0448\u0435\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435. (rutube.ru)<\/u><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0442\u0435\u0447\u0435\u0442, \u0432\u0441\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u0440\u043e\u043b\u0438\u043a. \u041d\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u043e\u043b\u0438\u043a\u0430. <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e \u0448\u0430\u0433\u0430\u043c. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0438 \u0441\u0435\u0440\u043e\u0433\u043e \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">import cv2  img = cv2.imread('cars\/6108249.jpg') height,width,_=img.shape gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray,0,255,cv2.THRESH_OTSU)[1] cv2.imshow('MyPhoto', thresh) cv2.waitKey(0)  cv2.destroyAllWindows() <\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/92b\/51a\/f78\/92b51af78b6f9c304d840de44a09dfe2.png\" width=\"593\" height=\"448\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/92b\/51a\/f78\/92b51af78b6f9c304d840de44a09dfe2.png\"\/><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/772\/9bf\/d1c\/7729bfd1c7ce6fcf9c6f8a58211a80fc.png\" width=\"626\" height=\"473\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/772\/9bf\/d1c\/7729bfd1c7ce6fcf9c6f8a58211a80fc.png\"\/><\/figure>\n<p>\u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433. \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u043d\u0430\u0439\u0442\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u0432\u043e\u0442 \u0431\u0435\u043b\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a: <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/33d\/104\/36d\/33d10436d8df6a336d3b5bbebaf428f8.png\" width=\"422\" height=\"217\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/33d\/104\/36d\/33d10436d8df6a336d3b5bbebaf428f8.png\"\/><\/figure>\n<p>\u041d\u043e, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u043e\u043b\u0438\u043a \u0434\u0430\u043b\u044c\u0448\u0435, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0430 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0442\u043a\u043e \u0432\u044b\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439 \u0437\u043d\u0430\u043a \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/72a\/6d4\/141\/72a6d41417c5e8b4ce9a2c838e846821.png\" width=\"693\" height=\"235\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/72a\/6d4\/141\/72a6d41417c5e8b4ce9a2c838e846821.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/053\/fa6\/a3d\/053fa6a3dd945527e0365636c16333ec.png\" width=\"693\" height=\"349\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/053\/fa6\/a3d\/053fa6a3dd945527e0365636c16333ec.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/216\/d01\/6ee\/216d016eedddc44f36f64f6716768e47.png\" width=\"693\" height=\"213\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/216\/d01\/6ee\/216d016eedddc44f36f64f6716768e47.png\"\/><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0445\u043e\u0442\u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0435\u0441\u0442\u044c \u043f\u043e\u043c\u0435\u0445\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dbe\/70a\/753\/dbe70a753850b79a09de8083ad24d987.png\" width=\"231\" height=\"89\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dbe\/70a\/753\/dbe70a753850b79a09de8083ad24d987.png\"\/><\/figure>\n<p>\u0410 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439 \u0437\u043d\u0430\u043a \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435. \u0425\u043e\u0442\u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0447\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/484\/83e\/71d\/48483e71da946b0297424842c85c74a3.png\" width=\"254\" height=\"114\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/484\/83e\/71d\/48483e71da946b0297424842c85c74a3.png\"\/><\/figure>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043d\u0430\u0439\u0434\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0434\u0430\u043b\u044c\u0448\u0435, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c\u0441\u044f \u043b\u0438 \u043c\u043e\u044f \u0434\u043e\u0433\u0430\u0434\u043a\u0430.<\/p>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u0430\u0440\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440\u044b, \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u044c\u044e. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"python\">import cv2 from imutils import contours import pytesseract  pytesseract.pytesseract.tesseract_cmd = \"D:\\\\Program Files\\\\Tesseract-OCR\\\\tesseract.exe\"  img = cv2.imread('cars\/6108249.jpg') height,width,_=img.shape gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray,0,255,cv2.THRESH_OTSU)[1] cnts=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) cnts,_=contours.sort_contours(cnts[0])  for c in cnts:     area=cv2.contourArea(c)     x,y,w,h=cv2.boundingRect(c)     if area>20:         img_area=img[y:y+h,x:x+h]         result=pytesseract.image_to_string(img_area,lang=\"rus+eng\")         if len(result)>3:             print(result) <\/code><\/pre>\n<p>\u0423 \u043d\u0435\u0433\u043e, \u043f\u0440\u0430\u0432\u0434\u0430, \u0431\u044b\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0440\u043e\u0433\u0438. \u0418 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043e\u043d \u043f\u0440\u044f\u043c\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0432 \u0440\u043e\u043b\u0438\u043a\u0435, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 \u043c\u043e\u0438\u0445 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u044d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u043f\u043e\u0440\u043e\u0433\u0438. \u0418 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/62e\/98c\/c5e\/62e98cc5e779f274d4094a97c3455e9b.png\" width=\"417\" height=\"161\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/62e\/98c\/c5e\/62e98cc5e779f274d4094a97c3455e9b.png\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 tesseract \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u0438:<\/p>\n<pre><code class=\"python\">\u2026 print(result) cv2.imshow('MyPhoto', img_area) cv2.waitKey(0) \u2026 <\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9af\/731\/472\/9af7314729b7445fe88470e001ad200d.png\" width=\"61\" height=\"57\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9af\/731\/472\/9af7314729b7445fe88470e001ad200d.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/47c\/703\/690\/47c70369070c329305d5a46dde33dd19.png\" width=\"19\" height=\"22\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/47c\/703\/690\/47c70369070c329305d5a46dde33dd19.png\"\/><\/figure>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0446\u0438\u0444\u0440\u044b tesseract \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0410 \u043e\u043d \u0432\u043e\u043e\u0431\u0449\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0446\u0438\u0444\u0440\u044b? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 paint-\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438\u0437 \u0446\u0438\u0444\u0440:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/684\/3e6\/e6e\/6843e6e6e804135b4588404d986c41cc.png\" width=\"102\" height=\"103\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/684\/3e6\/e6e\/6843e6e6e804135b4588404d986c41cc.png\"\/><\/figure>\n<p>\u0421\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u0435\u043c tesseract. \u0418 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u0443\u0441\u0442. \u00a0\u041f\u043e\u0433\u0443\u0433\u043b\u0438\u043b \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, tesseract \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0446\u0438\u0444\u0440\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u043e \u043c\u0435\u0441\u0442\u043e. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u044f, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041b\u0443\u0447\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0432\u043e\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043b\u043a\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439. <\/p>\n<p>\u041d\u043e, \u0434\u0430\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u043a\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430? \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0438\u0441\u043a\u0430\u0442\u044c \u0431\u0435\u043b\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u043d\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0435, \u043a\u0430\u043a \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432\u043d\u0430\u0447\u0430\u043b\u0435? \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u041e\u041e\u041f-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">def process(self, image):     \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.     image - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\"\"\"      current_info=ImageInfo(image)     for step in self.steps:         current_info=step.process(current_info)     return current_info  ... ...    def process(self,info):     \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"      median_image = cv2.medianBlur(info.image, self.ksize)     info.filtered_image=median_image     return info <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f. \u041f\u043e\u0447\u0435\u043c\u0443? \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438. \u042f \u043c\u043e\u0433\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0430 \u043c\u043e\u0433\u0443 \u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438. \u041d\u043e \u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u043d\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 image, \u0430 filtered_image. \u0418 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u0442\u043a\u0443\u0434\u0430 \u043d\u0430 \u0448\u0430\u0433\u0435 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u043d\u0430\u0434\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c image \u0438\u043b\u0438 filtered_image? \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e. \u0410 \u0432\u043e\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430\u0434\u043e \u0433\u0434\u0435-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 process \u043a\u043b\u0430\u0441\u0441\u0430 Engine:<\/p>\n<pre><code class=\"python\">def process(self, image):     \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.     image - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\"\"\"      current_info=ImageInfo(image)     history=[]     for step in self.steps:         history.append(current_info)         current_info=step.process(current_info)     return current_info, history<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0444\u0430\u0439\u043b: ImageProcessingSteps.py<\/p>\n<pre><code class=\"python\">import cv2 from Libraries.Core import ImageInfo   class ImageProcessingStep:     \"\"\"\u0428\u0430\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\"\"\"      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"         pass  class MedianBlurProcessingStep(ImageProcessingStep):     \"\"\"\u0428\u0430\u0433, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u0430 \u041c\u0435\u0434\u0438\u0430\u043d\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f\"\"\"      def __init__(self,ksize):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440         ksize - \u0440\u0430\u0437\u043c\u0435\u0440 \u044f\u0434\u0440\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\"\"\"          self.ksize=ksize      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"          median_image = cv2.medianBlur(info.image, self.ksize)         return ImageInfo(median_image)<\/code><\/pre>\n<p>\u041d\u0443, \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 run.py:<\/p>\n<pre><code class=\"python\">import cv2  from Libraries.Core import Engine from Libraries.ImageProcessingSteps import MedianBlurProcessingStep  my_photo = cv2.imread('..\/Photos\/MyPhoto1.jpg') core=Engine() core.steps.append(MedianBlurProcessingStep(5)) res,history=core.process(my_photo)  i=1 for info in history:     cv2.imshow('image'+str(i), info.image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e     i=i+1 cv2.imshow('res', res.image)    cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u0441\u043f\u044b\u0442\u0430\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u044b:<\/p>\n<pre><code class=\"python\">class ThresholdProcessingStep(ImageProcessingStep):     \"\"\"\u0428\u0430\u0433, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e\"\"\"      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"          gray = cv2.cvtColor(info.image, cv2.COLOR_BGR2GRAY)         image = cv2.threshold(gray, 0, 255, cv2.THRESH_OTSU)[1]         return ImageInfo(image)<\/code><\/pre>\n<p>\u0418 \u043d\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b run1.py:<\/p>\n<pre><code class=\"python\">import cv2  from Libraries.Core import Engine from Libraries.ImageProcessingSteps import MedianBlurProcessingStep, ThresholdProcessingStep  my_photo = cv2.imread('..\/Photos\/car.jpg') core=Engine() core.steps.append(MedianBlurProcessingStep(5)) core.steps.append(ThresholdProcessingStep()) res,history=core.process(my_photo)  i=1 for info in history:     cv2.imshow('image'+str(i), info.image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e     i=i+1 cv2.imshow('res', res.image)  cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/47c\/fd9\/418\/47cfd94184316ffa49371090723400d5.png\" width=\"651\" height=\"181\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/47c\/fd9\/418\/47cfd94184316ffa49371090723400d5.png\"\/><\/figure>\n<p>\u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043e\u0442\u0441\u044e\u0434\u0430: <a href=\"https:\/\/github.com\/megabax\/CVContainer\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/megabax\/CVContainer<\/a><\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u043c: \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u041e\u041e\u041f-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u0430\u0445 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u043c \u043a \u043d\u0435\u043c\u0443 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u043a\u0443 \u043d\u043e\u043c\u0435\u0440\u0430 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043b\u043a\u0443 \u0446\u0438\u0444\u0440 \u043d\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u0445. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/733444\/\"> https:\/\/habr.com\/ru\/articles\/733444\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: <a href=\"https:\/\/habr.com\/ru\/articles\/688316\/\" rel=\"noopener noreferrer nofollow\">\u0423\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. \u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \/ \u0425\u0430\u0431\u0440 (habr.com)<\/a><\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430, \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u043c \u0437\u0440\u0435\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0435\u0433\u043e \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430 \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u043c \u0437\u0440\u0435\u043d\u0438\u0438. \u0412 \u0441\u0432\u043e\u0435\u043c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440, \u0433\u0434\u0435 \u044d\u0442\u0438 \u0441\u0442\u0430\u0434\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u0431 \u044d\u0442\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (\u0444\u0438\u0447).<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043d\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0430\u0434\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0441\u044e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u0434\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0430\u0434\u0438\u0438. <\/p>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0440\u0430\u0434\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430 \u043a\u0430\u043a-\u0442\u043e \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e. \u041d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u0435\u043b\u0430\u043b\u0430 \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0441\u043e \u0441\u043f\u0443\u0442\u043d\u0438\u043a\u043e\u0432 \u0438 \u0411\u041b\u0410 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b \u0438\u0445 \u0432 \u0433\u0440\u0430\u0444 (\u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u0438\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/523484\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u0433\u0438\u0441\u0442\u0435\u0440\u0441\u043a\u043e\u0439 \u0434\u0438\u0441\u0441\u0435\u0440\u0442\u0430\u0446\u0438\u0438<\/a>). \u041f\u0440\u0430\u0432\u0434\u0430, \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u0430\u043c\u0431\u0438\u0446\u0438\u043e\u0437\u043d\u0430\u044f \u0437\u0430\u0434\u0443\u043c\u043a\u0430 \u0434\u043b\u044f \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041d\u0430\u0434\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e- \u043f\u0440\u043e\u0449\u0435. \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0443\u0440\u043e\u043a\u043e\u0432 \u043c\u043d\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0438\u043d\u0430\u043b\u0435 \u043f\u0430\u0440\u0443 \u0433\u043b\u0430\u0432 \u043f\u0440\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0438\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u043a. \u0418 \u0432\u043e\u0442 \u044f \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u043c\u043e\u0436\u0435\u0442, \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438? \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432? \u042d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0443\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0443\u0434\u0430 \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438: Exec \u0438 Libraries. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0443 \u043c\u0435\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\/\u0444\u0430\u0439\u043b\u044b, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043b Core.py:<\/p>\n<pre><code class=\"python\">class Engine:     \"\"\"\"\u0414\u0432\u0438\u0436\u043e\u043a\"\"\"     pass  class ImageProcessingStep:     \"\"\"\u0428\u0430\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\"\"\"     pass  class ImageInfo:     \"\"\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\"\"\"     pass<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u0442, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0438 \u0432 Core.py, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u0430\u043a\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u044e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">class Engine:     \"\"\"\"\u0414\u0432\u0438\u0436\u043e\u043a\"\"\"      def __init__(self):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\"\"\"          self.steps=[]      def process(self, image):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.         image - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\"\"\"          current_info=ImageInfo(image)         for step in self.steps:             current_info=step.process(current_info)         return current_info <\/code><\/pre>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 ImageInfo, \u0430 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 ImageProcessingStep \u043d\u0430\u0434\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 process. \u0418, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, ImageProcessingStep \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0421\u0442\u043e\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 Python \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0435\u0442 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u044b\u0445 (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 C#), \u043e\u043d\u0438 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432. \u041d\u043e \u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u043c\u0443 \u0440\u0430\u0441\u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u0440\u0430\u0437 \u00ab\u043d\u0435\u0442\u00bb \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043d\u0435\u0442\u00bb. <\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u044f \u0441\u0434\u0435\u043b\u0430\u044e \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 pass:<\/p>\n<pre><code class=\"python\">class ImageProcessingStep:     \"\"\"\u0428\u0430\u0433 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\"\"\"      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"         pass <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c ImageInfo. \u041f\u043e \u0438\u0434\u0435\u0435, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0448\u0430\u0433\u0430, \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0410 \u043f\u043e\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440:<\/p>\n<pre><code class=\"python\">class ImageInfo:     \"\"\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438\"\"\"      def __init__(self,image):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\"\"\"          self.image=image <\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u00ab\u043d\u0430\u0442\u044f\u043d\u0443\u0442\u044c\u00bb \u043d\u0430 \u044d\u0442\u0443 \u0441\u0445\u0435\u043c\u0443 \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u043a\u043b\u0430\u0441\u0441 ImageProcessingStep \u0432 \u0444\u0430\u0439\u043b \u043f\u0435\u0440\u0435\u043d\u0435\u0441 \u0432 ImageProcessingSteps.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">class MedianBlurProcessingStep(ImageProcessingStep):     \"\"\"\u0428\u0430\u0433, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u0430 \u041c\u0435\u0434\u0438\u0430\u043d\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f\"\"\"      def __init__(self,ksize):         \"\"\"\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440         ksize - \u0440\u0430\u0437\u043c\u0435\u0440 \u044f\u0434\u0440\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\"\"\"          self.ksize=ksize      def process(self,info):         \"\"\"\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\"\"\"          median_image = cv2.medianBlur(info.image, self.ksize)         info.filtered_image=median_image         return info <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Exec, \u0430 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b run.py. \u0412\u043e\u0442 \u0442\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041d\u0443 \u0438 \u0441\u0430\u043c\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 run.py:<\/p>\n<pre><code class=\"python\">import cv2  from Libraries.Core import Engine from Libraries.ImageProcessingSteps import MedianBlurProcessingStep  my_photo = cv2.imread('..\/Photos\/MyPhoto1.jpg') core=Engine() core.steps.append(MedianBlurProcessingStep(5)) info=core.process(my_photo)  cv2.imshow('origin', info.image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e cv2.imshow('res', info.filtered_image) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()  <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u043e\u0434\u043d\u0443 \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438, \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438. \u0414\u0430, \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/654663\/\" rel=\"noopener noreferrer nofollow\">\u0443\u0440\u043e\u043a\u0435 3<\/a>, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u043e\u0439 \u041e\u041e\u041f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0430. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u0447\u0435\u0440\u0435\u0437 tesseract. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 tesseract. \u0418 \u0442\u0430\u043a, \u0441\u0442\u0430\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<p><code>pip install pytesseract<\/code><\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/github.com\/UB-Mannheim\/tesseract\/wiki\" rel=\"noopener noreferrer nofollow\">Home \u00b7 UB-Mannheim\/tesseract Wiki (github.com)<\/a> \u0438 \u043a\u0430\u0447\u0430\u0435\u043c \u043e\u0442\u0442\u0443\u0434\u0430 \u0441\u0430\u043c\u0443 tesseract. \u0415\u0441\u043b\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f (\u043c\u0430\u043b\u043e \u043b\u0438, \u0432\u0441\u0435 \u0442\u0435\u0447\u0435\u0442, \u0432\u0441\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f), \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0442\u0435. <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043a\u0430\u0447\u0430\u043b\u0438 tesseract \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0430 Python \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<pre><code class=\"python\">import cv2 import pytesseract  pytesseract.pytesseract.tesseract_cmd = \"D:\\\\Program Files\\\\Tesseract-OCR\\\\tesseract.exe\"  img = cv2.imread('image.jpg') print(pytesseract.image_to_string(img, lang = 'rus')) <\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (\u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0432\u043e\u0440\u0434\u0430) \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 (\u043c\u043e\u0436\u0435\u0442, \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c). <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0441\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043d\u0438\u0433\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435-\u0442\u043e \u0441\u043b\u043e\u0432\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043b\u0438\u0441\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0433\u0434\u0435-\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0432\u043e. <\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d, \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u0439 \u043d\u044e\u0430\u043d\u0441. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0439 \u0442\u0435\u043a\u0441\u0442. \u041d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0431\u043b\u043e\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0447\u0435\u0440\u0442\u0435\u0436\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0442 \u0447\u0435\u0440\u0442\u0435\u0436 \u043e\u0446\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u0448\u0442\u0430\u043c\u043f\u0438\u043a \u0447\u0435\u0440\u0442\u0435\u0436\u0430, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043f\u0438\u0441\u0438 \u043d\u0430 \u0432\u044b\u043d\u043e\u0441\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u044d\u0442\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u0438 \u0437\u0430\u043d\u0435\u0441\u0442\u0438 \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u0434\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438? \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u0437\u043e\u043d\u044b, \u0438 \u044d\u0442\u0438 \u0437\u043e\u043d\u044b \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u043b\u0438\u0441\u044c tesseract.<\/p>\n<p>\u041d\u043e \u0432 \u043c\u043e\u0435\u043c \u043f\u044d\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430. \u0417\u043d\u0430\u044e, \u044d\u0442\u043e \u0443\u0436\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0430\u044f\u043d\u0435\u0441\u0442\u044b\u0439 \u0431\u0430\u044f\u043d, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043f\u0438\u0448\u0443\u0442 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443. \u0418 \u0434\u0430\u0436\u0435 \u0446\u0435\u043b\u044b\u0435 \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0435. \u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u043d\u0430\u0434\u043e \u0436\u0435 \u0441 \u0447\u0435\u0433\u043e-\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c. \u0410 \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u0443\u044e \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<p>\u041f\u043e\u0441\u0442\u0443\u043f\u043b\u044e \u044f, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041d\u0430\u0433\u0443\u0433\u043b\u044e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432, \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0432\u044b\u0431\u0435\u0440\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u0430\u0447\u043d\u044b\u0439, \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0443 \u043a\u043e\u0434 \u0432 \u043c\u043e\u0439 \u041e\u041e\u041f-\u0448\u0430\u0431\u043b\u043e\u043d. \u041f\u043e\u0435\u0445\u0430\u043b\u0438. \u041d\u0430\u0448\u0435\u043b \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u043e\u043b\u0438\u043a:<\/p>\n<p><a href=\"https:\/\/rutube.ru\/video\/b72b22d99ab60105eed1c40a1ac8c880\/\" rel=\"noopener noreferrer nofollow\"><u>[Python] \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 OpenCV | \u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u043d\u043b\u0430\u0439\u043d \u0432\u0438\u0434\u0435\u043e \u043e\u0442 Boris Bochkarev | BeTry \u0432 \u0445\u043e\u0440\u043e\u0448\u0435\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435. (rutube.ru)<\/u><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0442\u0435\u0447\u0435\u0442, \u0432\u0441\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u044d\u0442\u043e\u0442 \u0440\u043e\u043b\u0438\u043a. \u041d\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u043e\u043b\u0438\u043a\u0430. <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e \u0448\u0430\u0433\u0430\u043c. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0438 \u0441\u0435\u0440\u043e\u0433\u043e \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">import cv2  img = cv2.imread('cars\/6108249.jpg') height,width,_=img.shape gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray,0,255,cv2.THRESH_OTSU)[1] cv2.imshow('MyPhoto', thresh) cv2.waitKey(0)  cv2.destroyAllWindows() <\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433. \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u043d\u0430\u0439\u0442\u0438 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u0432\u043e\u0442 \u0431\u0435\u043b\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a: <\/p>\n<figure class=\"\"><\/figure>\n<p>\u041d\u043e, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u043e\u043b\u0438\u043a \u0434\u0430\u043b\u044c\u0448\u0435, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0430 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0442\u043a\u043e \u0432\u044b\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439 \u0437\u043d\u0430\u043a \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0445\u043e\u0442\u044f \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0435\u0441\u0442\u044c \u043f\u043e\u043c\u0435\u0445\u0438:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0410 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439 \u0437\u043d\u0430\u043a \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0435\u043b\u043e\u043c \u0444\u043e\u043d\u0435. \u0425\u043e\u0442\u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0447\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043d\u0430\u0439\u0434\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0434\u0430\u043b\u044c\u0448\u0435, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c\u0441\u044f \u043b\u0438 \u043c\u043e\u044f \u0434\u043e\u0433\u0430\u0434\u043a\u0430.<\/p>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u0430\u0440\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440\u044b, \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u044c\u044e. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"python\">import cv2 from imutils import contours import pytesseract  pytesseract.pytesseract.tesseract_cmd = \"D:\\\\Program Files\\\\Tesseract-OCR\\\\tesseract.exe\"  img = cv2.imread('cars\/6108249.jpg') height,width,_=img.shape gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray,0,255,cv2.THRESH_OTSU)[1] cnts=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) cnts,_=contours.sort_contours(cnts[0])  for c in cnts:     area=cv2.contourArea(c)     x,y,w,h=cv2.boundingRect(c)     if area>20:         img_area=img[y:y+h,x:x+h]         result=pytesseract.image_to_string(img_area,lang=\"rus+eng\")         if len(result)>3:             print(result) <\/code><\/pre>\n<p>\u0423 \u043d\u0435\u0433\u043e, \u043f\u0440\u0430\u0432\u0434\u0430, \u0431\u044b\u043b\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0440\u043e\u0433\u0438. \u0418 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043e\u043d \u043f\u0440\u044f\u043c\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0432 \u0440\u043e\u043b\u0438\u043a\u0435, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 \u043c\u043e\u0438\u0445 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u044d\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u043f\u043e\u0440\u043e\u0433\u0438. \u0418 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 tesseract \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u0438:<\/p>\n<pre><code class=\"python\">\u2026 print(result) cv2.imshow('MyPhoto', img_area) cv2.waitKey(0) \u2026 <\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438:<\/p>\n<figure class=\"\"><\/figure>\n<figure class=\"\"><\/figure>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0446\u0438\u0444\u0440\u044b tesseract \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0410 \u043e\u043d \u0432\u043e\u043e\u0431\u0449\u0435, \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0446\u0438\u0444\u0440\u044b? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 paint-\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438\u0437 \u0446\u0438\u0444\u0440:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0421\u043a\u0430\u0440\u043c\u043b\u0438\u0432\u0430\u0435\u043c tesseract. \u0418 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043f\u0443\u0441\u0442. \u00a0\u041f\u043e\u0433\u0443\u0433\u043b\u0438\u043b \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-384249","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/384249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=384249"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/384249\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=384249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=384249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=384249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}