{"id":1671,"date":"2020-06-09T17:14:06","date_gmt":"2020-06-09T17:14:06","guid":{"rendered":"https:\/\/genial-code.com\/?p=1671"},"modified":"2023-10-21T05:22:49","modified_gmt":"2023-10-21T05:22:49","slug":"create-virtual-pen-and-eraser-with-python-opencv","status":"publish","type":"post","link":"https:\/\/genial-code.com\/fr\/create-virtual-pen-and-eraser-with-python-opencv\/","title":{"rendered":"Create a Virtual Pen and Eraser with Python OpenCV"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Learn Free how to create a virtual pen and eraser with python and <a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenCV\">OpenCV<\/a> with source code and complete guide. This entire application is built fundamentally on contour detection. It can be thought of as something like closed color curves on compromises that have the same color or intensity, it&#8217;s like a blob. In this project we use color masking to get the binary mask of our target color pen, then we use the counter detection to find the location of this pen and the contour to find it.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">When we work with it then it is a matter of literally connecting the dots, we just have to draw a line using the x, y dots of the previous position of the pen with new x, y dots and that&#8217;s it. , We have a virtual pen.<\/span><\/p>\n<h3><span style=\"font-family: tahoma, arial, helvetica, sans-serif;\">Virtual Pen and Eraser with Python\u00a0<\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">There are 6 main points in the structure<\/span><\/p>\n<ol>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Find color range of target object and save it.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Apply morphological operations.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Detect and track the colored object.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Find the object\u2019s x, y\u00a0 coordinates.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Add a Wiper functionality.<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Add an Eraser Functionality.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-family: tahoma, arial, helvetica, sans-serif; font-size: 12pt;\">Import required libraries<\/span><\/p>\n<p><span style=\"font-family: 'times new roman', times, serif; font-size: 12pt;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1673\" src=\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/Screenshot_5-300x31.png\" alt=\"\" width=\"716\" height=\"74\" srcset=\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/Screenshot_5-300x31.png 300w, https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/Screenshot_5.png 708w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt; font-family: tahoma, arial, helvetica, sans-serif;\">Download Complete Guide of Virtual Pen &amp; Eraser OpenCV<\/span><\/p>\n<p><a href=\"https:\/\/genial-code.com\/download-guide-and-source-code-of-virtual-pen-and-eraser-with-opencv\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-2393\" src=\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/07\/Picture11-300x69.png\" alt=\"\" width=\"139\" height=\"32\" srcset=\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/07\/Picture11-300x69.png 300w, https:\/\/genial-code.com\/wp-content\/uploads\/2020\/07\/Picture11.png 346w\" sizes=\"(max-width: 139px) 100vw, 139px\" \/><\/a><\/p>\n<p><span style=\"font-size: 12pt; font-family: tahoma, arial, helvetica, sans-serif;\">Download Source Code Of Virtual Pen &amp; Eraser OpenCV<\/span><\/p>\n<p><a href=\"https:\/\/genial-code.com\/download-source-code-of-virtual-pen-and-eraser-with-opencv\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-2430\" src=\"https:\/\/genial-code.com\/wp-content\/uploads\/2019\/10\/Download-removebg-preview.png\" alt=\"\" width=\"139\" height=\"34\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide. This entire application is built fundamentally on contour detection. It can be thought of as something like closed color curves on compromises that have the same color or intensity, it&#8217;s like a blob. In this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1683,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[104,668],"tags":[997,996,998,994,995,992,991,999,993],"translation":{"provider":"WPGlobus","version":"3.0.0","language":"fr","enabled_languages":["en","es","de","fr","ru"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"es":{"title":false,"content":false,"excerpt":false},"de":{"title":false,"content":false,"excerpt":false},"fr":{"title":false,"content":false,"excerpt":false},"ru":{"title":false,"content":false,"excerpt":false}}},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create a Virtual Pen and Eraser with Python OpenCV - Genial Code<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Virtual Pen and Eraser with Python OpenCV - Genial Code\" \/>\n<meta property=\"og:url\" content=\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/\" \/>\n<meta property=\"og:site_name\" content=\"Genial Code\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-09T17:14:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-21T05:22:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png\" \/>\n\t<meta property=\"og:image:width\" content=\"632\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"genialcode\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"genialcode\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/\",\"url\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/\",\"name\":\"Create a Virtual Pen and Eraser with Python OpenCV - Genial Code\",\"isPartOf\":{\"@id\":\"https:\/\/genial-code.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png\",\"datePublished\":\"2020-06-09T17:14:06+00:00\",\"dateModified\":\"2023-10-21T05:22:49+00:00\",\"author\":{\"@id\":\"https:\/\/genial-code.com\/#\/schema\/person\/9180609fb3eeb1144d23e2be1b52d30a\"},\"description\":\"Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage\",\"url\":\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png\",\"contentUrl\":\"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png\",\"width\":632,\"height\":422},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/genial-code.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a Virtual Pen and Eraser with Python OpenCV\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/genial-code.com\/#website\",\"url\":\"https:\/\/genial-code.com\/\",\"name\":\"Genial Code\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/genial-code.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/genial-code.com\/#\/schema\/person\/9180609fb3eeb1144d23e2be1b52d30a\",\"name\":\"genialcode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/genial-code.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c579ab454febc79194016741931b2bc1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c579ab454febc79194016741931b2bc1?s=96&d=mm&r=g\",\"caption\":\"genialcode\"},\"url\":\"https:\/\/genial-code.com\/fr\/author\/genialcode\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a Virtual Pen and Eraser with Python OpenCV - Genial Code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/","og_locale":"fr_FR","og_type":"article","og_title":"Create a Virtual Pen and Eraser with Python OpenCV - Genial Code","og_url":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/","og_site_name":"Genial Code","article_published_time":"2020-06-09T17:14:06+00:00","article_modified_time":"2023-10-21T05:22:49+00:00","og_image":[{"width":632,"height":422,"url":"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png","type":"image\/png"}],"author":"genialcode","twitter_card":"summary_large_image","twitter_misc":{"Written by":"genialcode","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/","url":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/","name":"Create a Virtual Pen and Eraser with Python OpenCV - Genial Code","isPartOf":{"@id":"https:\/\/genial-code.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage"},"image":{"@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png","datePublished":"2020-06-09T17:14:06+00:00","dateModified":"2023-10-21T05:22:49+00:00","author":{"@id":"https:\/\/genial-code.com\/#\/schema\/person\/9180609fb3eeb1144d23e2be1b52d30a"},"description":"Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide.","breadcrumb":{"@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#primaryimage","url":"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png","contentUrl":"https:\/\/genial-code.com\/wp-content\/uploads\/2020\/06\/virtual-pen.png","width":632,"height":422},{"@type":"BreadcrumbList","@id":"https:\/\/genial-code.com\/create-virtual-pen-and-eraser-with-python-opencv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/genial-code.com\/"},{"@type":"ListItem","position":2,"name":"Create a Virtual Pen and Eraser with Python OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/genial-code.com\/#website","url":"https:\/\/genial-code.com\/","name":"Genial Code","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/genial-code.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Person","@id":"https:\/\/genial-code.com\/#\/schema\/person\/9180609fb3eeb1144d23e2be1b52d30a","name":"genialcode","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/genial-code.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c579ab454febc79194016741931b2bc1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c579ab454febc79194016741931b2bc1?s=96&d=mm&r=g","caption":"genialcode"},"url":"https:\/\/genial-code.com\/fr\/author\/genialcode\/"}]}},"_links":{"self":[{"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/posts\/1671"}],"collection":[{"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/comments?post=1671"}],"version-history":[{"count":11,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/posts\/1671\/revisions"}],"predecessor-version":[{"id":2492,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/posts\/1671\/revisions\/2492"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/media\/1683"}],"wp:attachment":[{"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/media?parent=1671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/categories?post=1671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/genial-code.com\/fr\/wp-json\/wp\/v2\/tags?post=1671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}