{"id":1940,"date":"2016-06-24T19:06:02","date_gmt":"2016-06-24T10:06:02","guid":{"rendered":"http:\/\/avinton.com\/?page_id=1940"},"modified":"2023-11-21T18:38:23","modified_gmt":"2023-11-21T09:38:23","slug":"opencv-simple-exercise","status":"publish","type":"page","link":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/","title":{"rendered":"OpenCV Simple Exercise"},"content":{"rendered":"<h1>OpenCV Exercise<\/h1>\n<p>Make sure we are in our home directory<\/p>\n<pre><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd ~\n<\/pre>\n<p>Create a new directory for this exercise<\/p>\n<pre><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmkdir pytest\ncd pytest\n<\/pre>\n<p>Download the image below to this new directory<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-98870\" src=\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg\" alt=\"\" width=\"300\" height=\"109\" srcset=\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg 300w, https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-1024x373.jpg 1024w, https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-355x129.jpg 355w, https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise.jpg 1276w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<div style=\"display: block; text-align: left;\">Copy the following code:<\/div>\n<div style=\"display: block; text-align: left;\"><\/div>\n<div style=\"display: block; text-align: left;\">\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><\/div>\n<div class=\"sites-codeblock sites-codesnippet-block\">\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># import the necessary packages<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>import<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>numpy <\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>as<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>np<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>import<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><code>\u00a0<\/code><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># load the games image<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>image<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>imread<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #008000!important; background: transparent;\"><code>\"test.png\"<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><code>\u00a0<\/code><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># find the red color game in the image<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>upper<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>np<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>array<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>[<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>65<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>65<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>255<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>]<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>lower<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>np<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>array<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>[<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>200<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>]<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>mask<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>inRange<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>image<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>lower<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>upper<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><code>\u00a0<\/code><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># find contours in the masked image and keep the largest one<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>_<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cnts<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>_<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>findContours<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>mask<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>copy<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>RETR_EXTERNAL<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>CHAIN_APPROX_SIMPLE<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>c<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>max<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cnts<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>key<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>contourArea<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><code>\u00a0<\/code><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># approximate the contour<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>peri<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>arcLength<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>c<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>True<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>approx<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>=<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>approxPolyDP<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>c<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0.05<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>*<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>peri<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #800080!important; background: transparent;\"><code>True<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><code>\u00a0<\/code><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ff8000!important; background: transparent;\"><code># draw a green bounding box surrounding the red game<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>drawContours<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>image<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>[<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>approx<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>]<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #006fe0!important; background: transparent;\"><code>-<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>1<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>255<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>4<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: #f7f7f7!important;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>imshow<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #008000!important; background: transparent;\"><code>\"Image\"<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>,<\/code><\/span> <span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>image<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<div style=\"margin: 0px; padding: 0px 5px; border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; font-family: Monaco,MonacoRegular,Courier New,monospace; height: inherit; line-height: 15px; color: #000000; white-space: pre; background: 0px center #fdfdfd;\"><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #002d7a!important; background: transparent;\"><code>cv2<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>.<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #004ed0!important; background: transparent;\"><code>waitKey<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>(<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #ce0000!important; background: transparent;\"><code>0<\/code><\/span><span style=\"margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: inherit!important; vertical-align: baseline; font-family: inherit; height: inherit; line-height: inherit!important; font-weight: inherit!important; color: #333333!important; background: transparent;\"><code>)<\/code><\/span><\/div>\n<\/div>\n<\/div>\n<p>Paste the code into a file called pytest.py<\/p>\n<pre><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nvi pytest.py\n<\/pre>\n<p>Paste then save and exit vi<\/p>\n<p>Run the python program<\/p>\n<pre><pre class=\"brush: python; title: ; notranslate\" title=\"\">\npython pytest.py\n<\/pre>\n<p>Now it should make a green square around the red logo box.<\/p>\n<p>The exercise is to make it make the square around the blue logo box (middle one).<\/p>\n<p><a href=\"mailto:james.cauchi@avinton.com\" target=\"_blank\" rel=\"noopener\">Email me<\/a> back the result<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to this new directory Copy the following code: # import the necessary packages import numpy as np import cv2 \u00a0 # load the games image image = cv2.imread(&#8220;test.png&#8221;)<br \/><a href=\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\" class=\"more\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1906,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1940","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>OpenCV Simple Exercise - Avinton Japan<\/title>\n<meta name=\"description\" content=\"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OpenCV Simple Exercise - Avinton Japan\" \/>\n<meta property=\"og:description\" content=\"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to\" \/>\n<meta property=\"og:url\" content=\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\" \/>\n<meta property=\"og:site_name\" content=\"Avinton Japan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Avintons\/\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T09:38:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@AvintonJapan\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\",\"url\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\",\"name\":\"OpenCV Simple Exercise - Avinton Japan\",\"isPartOf\":{\"@id\":\"https:\/\/avinton.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg\",\"datePublished\":\"2016-06-24T10:06:02+00:00\",\"dateModified\":\"2023-11-21T09:38:23+00:00\",\"description\":\"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to\",\"breadcrumb\":{\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage\",\"url\":\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg\",\"contentUrl\":\"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/avinton.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Avinton Academy\",\"item\":\"https:\/\/avinton.com\/en\/academy\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"OpenCV Simple Exercise\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/avinton.com\/en\/#website\",\"url\":\"https:\/\/avinton.com\/en\/\",\"name\":\"Avinton Japan\",\"description\":\"Tailored Solutions and Consulting in AI and Big Data\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/avinton.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OpenCV Simple Exercise - Avinton Japan","description":"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to","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:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/","og_locale":"en_US","og_type":"article","og_title":"OpenCV Simple Exercise - Avinton Japan","og_description":"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to","og_url":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/","og_site_name":"Avinton Japan","article_publisher":"https:\/\/www.facebook.com\/Avintons\/","article_modified_time":"2023-11-21T09:38:23+00:00","og_image":[{"url":"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@AvintonJapan","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/","url":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/","name":"OpenCV Simple Exercise - Avinton Japan","isPartOf":{"@id":"https:\/\/avinton.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage"},"image":{"@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage"},"thumbnailUrl":"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg","datePublished":"2016-06-24T10:06:02+00:00","dateModified":"2023-11-21T09:38:23+00:00","description":"OpenCV Exercise Make sure we are in our home directory cd ~ Create a new directory for this exercise mkdir pytest cd pytest Download the image below to","breadcrumb":{"@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#primaryimage","url":"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg","contentUrl":"https:\/\/avinton.com\/wp-content\/uploads\/2023\/11\/avintonAcademyOpenCVSimpleExercise-300x109.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/avinton.com\/en\/academy\/opencv-simple-exercise\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/avinton.com\/en\/"},{"@type":"ListItem","position":2,"name":"Avinton Academy","item":"https:\/\/avinton.com\/en\/academy\/"},{"@type":"ListItem","position":3,"name":"OpenCV Simple Exercise"}]},{"@type":"WebSite","@id":"https:\/\/avinton.com\/en\/#website","url":"https:\/\/avinton.com\/en\/","name":"Avinton Japan","description":"Tailored Solutions and Consulting in AI and Big Data","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/avinton.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/comments?post=1940"}],"version-history":[{"count":8,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1940\/revisions"}],"predecessor-version":[{"id":98876,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1940\/revisions\/98876"}],"up":[{"embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/pages\/1906"}],"wp:attachment":[{"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/media?parent=1940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/categories?post=1940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avinton.com\/en\/wp-json\/wp\/v2\/tags?post=1940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}