element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
PiCasso Design Challenge
  • Challenges & Projects
  • Design Challenges
  • PiCasso Design Challenge
  • More
  • Cancel
PiCasso Design Challenge
Blog Picasso Adapting Art to Viewers:  Pi talks to Pi, Blog #4
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fmilburn
  • Date Created: 3 Apr 2019 5:09 AM Date Created
  • Views 1880 views
  • Likes 8 likes
  • Comments 8 comments
  • picasso
  • image recognition
  • raspberry pi camera v2
  • raspberry pi 3b+
  • ai
  • art
  • picasso_design_challenge
  • pi face
Related
Recommended

Picasso Adapting Art to Viewers:  Pi talks to Pi, Blog #4

fmilburn
fmilburn
3 Apr 2019

Art is often made to appeal to a specific set of viewers.  This is the 4th blog in a series exploring the idea of using AI to recognize a viewer and adapt art to their age or interest.  The intent is to encourage early art appreciation while being attractive to all household members.

image

In this post the progress in getting image recognition to start and run more quickly is described along with a means to communicate from one Raspberry Pi to another when a face is recognized.

 

Speeding Things Up

 

In the second post the means of capturing training photos, processing them, and then using the encoded results to recognize faces and track them on a monitor was presented.  It was noted that the update frequency was fairly slow and CPU intensive.  Adding more photos to the training set to improve accuracy, and adding additional persons to be recognized slows things even further.  The project goal is to add as many as eight different faces and have them recognized with reasonable accuracy and speed (reasonable to be defined at a later date :-).

 

The portion of the program that processes the training photos was removed and run separately.  The recognition program then accesses the encoded data and thus starts faster.  The portion of the program that tracks faces and draws boxes around them on the screen was removed as it is not needed.  The speedup is noticeable but has not been quantified.  But now that faces are no longer shown on the monitor and tracked it is necessary to indicate recognition another way.

 

Talking Pi to Pi

 

Originally the connection was to be serial or perhaps Bluetooth but there are numerous GPIO that are not being used on the two computers.  Since there is a maximum of only eight faces, it is possible to dedicate one pin to each face and then set it high or low depending on whether the face has been recognized.  The resulting block diagram looks like this with one connection (plus ground) for each face between the two computers.

image

A resistor is placed on each line to prevent damage in the event a connection from HIGH to LOW or PWR to GND is inadvertently made.  A downside to the approach is that GPIO pin connections equal to the number of persons being recognized are being utilized and information is limited to HIGH / LOW.  On the other hand it is fast, reliable, and is easy to implement.

 

In the photo below the Raspberry Pi 3B+ with camera is on the far left and connected to a breadboard with 3 LEDs that are turned on when the Python script running OpenCV detects one of three faces.  It is also connected to the second Pi center bottom which displays the name of the person detected on the display.  Ultimately this second Raspberry Pi will create / display the art that has been selected for that particular person.

image

 

GPIO and Python on the Raspberry Pi

 

The two commonly used libraries on the Raspberry Pi for use with Python are GPIO Zero and RPi.GPIO which will be used here.  The sole reason for using RPi.GPIO is that I have used it in the past and was fairly sure I could get it to work.  The following is all that is needed to initiate the GPIO and set a pin.

import RPi.GPIO as GPIO

print("Setting pins using the board header numbering")
frank = 36
margot = 38
doll = 40

GPIO.setmode(GPIO.BOARD)

GPIO.setup(frank, GPIO.OUT)
GPIO.setup(margot, GPIO.OUT)
GPIO.setup(doll, GPIO.OUT)

GPIO.output(frank, GPIO.LOW)
GPIO.output(margot, GPIO.LOW)
GPIO.output(doll, GPIO.LOW)

 

In the script running OpenCV the output is made HIGH when a face is detected and turned off on the next pass through the loop.  In the setup photographed above a separate LED flashes for each detected face and the second Raspberry Pi detects it using the same library:  The RPi.GPIO library also allows interrupts so that polling is not required.

 

The following video demonstrates the setup working.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Upcoming Work

 

  • Improvements to the cabinet
  • Obtain training photographs for all the faces and perform training
  • Fabricate a small board to connect the two Raspberry Pi computer
  • Write Python script to drive the monitor and control the art output
  • Develop / obtain art

 

If you made it this far, thanks for reading and your thoughts and comments are always appreciated.  In particular, using GPIO to communicate seems unorthodox and thoughts on that are welcome.

 

Other Posts in this Series

PiCasso Design Challenge:  Adapting Art to Ages Blog #1

PiCasso Adapting Art to Viewers: OpenCV Face Detection, Blog #2

PiCasso Adapting Art to Viewers: Cabinet Design, Blog #3

  • Sign in to reply

Top Comments

  • kiri-ll
    kiri-ll over 6 years ago +3
    It looks great! The most complicated part of the project, and it is working! Yay
  • dubbie
    dubbie over 6 years ago +2
    Frank, You seem to be making good progress and I look forward to seeing the more artistic parts of your project in action. I am a great believer in 'if it works, why not use it' so if communication using…
  • ralphjy
    ralphjy over 6 years ago +2
    Nice project. This would have been a perfect application for the Omron Vision Sensor that I roadtested last year. The one thing that it was very good at was person recognition using a small set of "registered…
  • fmilburn
    fmilburn over 6 years ago in reply to kiri-ll

    Thanks!  (But I am not out of the woods yet :-)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 6 years ago in reply to dubbie

    Thanks Dubbie!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 6 years ago in reply to genebren

    Good point on turning it into an 8 bit number Gene.  It occurred to me that If I use the PiFace to interface it gets rid of the need for current limiting resistors as well. 

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 6 years ago in reply to ralphjy

    Hi Ralph,

    Thanks.  I had similar thoughts on using a specialized camera sensor and would be interested in how well the Omron does if you get around to trying it. I am afraid I am going to run into the limits of the RPi before too long.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 6 years ago

    Frank,

     

    Great update on your project.  Nice that you are making such great progress.  When defining an interface between computers there is no right or wrong way.  The GPIO looks like it will work fine.  In the future, if you have more recognizable subjects, you could easily convert your 'one pin per person' to a 8-bit number and be able to identify up to 256 individuals.

     

    Keep up the good work!

    Gene

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube