{"id":1372,"date":"2016-02-13T03:49:23","date_gmt":"2016-02-13T03:49:23","guid":{"rendered":"http:\/\/www.richa1.com\/RichardAlbritton\/?p=1372"},"modified":"2016-02-17T02:40:00","modified_gmt":"2016-02-17T02:40:00","slug":"opencv-and-python-color-detection-pyimagesearch","status":"publish","type":"post","link":"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/","title":{"rendered":"OpenCV and Python Color Detection &#8211; PyImageSearch"},"content":{"rendered":"<p>I am working on some stuff at the Makerspace that involves computer vision. Hopefully this information will help. Currently we are trying to do this another way, but it is just getting to be more complicated than I think it should be.<\/p>\n<p>Python code for taking a photo and saving it:<\/p>\n<pre class=\"lang:python decode:true \" title=\"PYTHON PICAMERA\">Import picamera\r\ncamera = picamera.PiCamera()\r\ncamera.capture('image.png')<\/pre>\n<p>https:\/\/www.raspberrypi.org\/documentation\/usage\/camera\/python\/README.md<\/p>\n<p>Button Pressed code:<\/p>\n<pre class=\"lang:default decode:true \" title=\"GPIO Code\">import os\r\nimport time\r\nimport RPi.GPIO as GPIO\r\n\r\nGPIO.setmode(GPIO.BCM)\r\nGPIO.setup(23, GPIO.IN)\r\nGPIO.setup(18, GPIO.OUT)\r\n\r\ndef loop():\r\n    if (GPIO.input(23) == False):\r\n        os.system('Enter the command to execute your code')\r\n\r\n    if Test == \"open\":\r\n        GPIO.output(18, True)\r\n    else:\r\n        GPIO.output(18, False)\r\nloop()\r\nfinally:\r\n    GPIO.cleanup()<\/pre>\n<p>This should listen for the button to be pressed, then it will run your code. If the code returns Test as &#8220;open&#8221;, Pin 18 goes high.<\/p>\n<p>The image detection part of the code. I have yet to get this going.<\/p>\n<p><a href=\"http:\/\/www.pyimagesearch.com\/2014\/08\/04\/opencv-python-color-detection\/\">http:\/\/www.pyimagesearch.com\/2014\/08\/04\/opencv-python-color-detection\/<\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1372\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1372\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>I am working on some stuff at the Makerspace that involves computer vision. Hopefully this information will help. Currently we are trying to do this another way, but it is just getting to be more complicated than I think it should be. Python code for taking a photo and saving it: Import picamera camera = &hellip; <a href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">OpenCV and Python Color Detection &#8211; PyImageSearch<\/span><\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-print\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-print sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/\" target=\"_blank\" title=\"Click to print\"><span>Print<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1372\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1372\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/www.richa1.com\/RichardAlbritton\/opencv-and-python-color-detection-pyimagesearch\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[57,59,64],"tags":[117],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5AhH6-m8","_links":{"self":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1372"}],"collection":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/comments?post=1372"}],"version-history":[{"count":3,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1372\/revisions"}],"predecessor-version":[{"id":1378,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/posts\/1372\/revisions\/1378"}],"wp:attachment":[{"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/media?parent=1372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/categories?post=1372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.richa1.com\/RichardAlbritton\/wp-json\/wp\/v2\/tags?post=1372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}