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: OpenCV Face Detection, Blog #2
  • 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: 24 Mar 2019 11:21 PM Date Created
  • Views 1601 views
  • Likes 9 likes
  • Comments 5 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: OpenCV Face Detection, Blog #2

fmilburn
fmilburn
24 Mar 2019

Art is often made to appeal to a specific set of viewers.  This is the second 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 loading of software and recognition of faces using OpenCV on the Raspberry Pi 3B+ and Raspberry Pi Camera V2 are discussed.  A subjective comparison to the Raspberry Pi 3B and original Raspberry Pi Camera is made.  Shortcomings in face recognition on the Raspberry Pi to date and possible ways to overcome are discussed.  A video is presented which demonstrates face recognition and plans for next steps are made.

 

Requirements

image

Raspberry Pi 3B+

Raspberry Pi Camera V2

5.1V, 2500 mA power supply

SD Card with Rasbian

 

Raspberry Pi 3B+ and Raspberry Pi Camera V2

image

Thanks to Element14 for providing the new Raspberry Pi 3B+, Kit, and Camera for this challenge.  The RPi Zero W (left) was not tried but it would probably struggle to manage OpenCV for this application.  I have successfully used a Raspberry Pi 3B with the original camera (middle in the photo above).  But the new Camera V2 on right gives better color balance in mixed lighting and for my use is a substantial upgrade over the original.  And the 1400 MHz clock in the RPi 3B+ improves over the 1200 MHz RPi 3B for facial recognition where update frame rate speed is important.  So the current plan is to use the RPi 3B to display and control art while the RPi 3B+ does facial recognition.

 

I am using the Debian Stretch OS with Raspberry Pi Desktop November 2018 release, Kernel version 4.9.  Help on getting started with the Raspberry Pi can be found here.

 

Loading OpenCV Face Detection on the Raspberry Pi 3B+

 

Sharib Hasan gives an excellent step by step description of Raspberry Pi Facial Recognition  and how to load it here on Element14 which I will not repeat.  One small difference is that I use the following simple Python script which takes 5 photos and then select the one(s) I want to use.  The selected photos are then placed into their individually named folders in the dataset folder.

from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.resolution = (800, 600)
# camera.rotation = 180
for i in range(5):
 camera.start_preview()
 sleep(3)
 camera.capture('/home/pi/Desktop/image%s.jpg' % i)
 camera.stop_preview()
 sleep(0.1)

 

If your photos are upside down, uncomment the line "camera.rotation = 180".  I am still playing with camera resolution and 800 x 600 is probably higher than needed.  Higher resolution photos slow down the face learning part of OpenCV.

 

Raspberry Pi 3B+ OpenCV Face Detection Performance

To start, a limited number of photos has been used to train the facial recognition AI.  The subjects are myself and a doll my granddaughter plays with when she is at the house.  The doll is being used since there are no grandchildren at hand to serve as  unwilling subjects. The photos below are representative and there are 3 of each subject. A photo of one of my granddaughters was also placed  in the dataset (not shown below) to see if it would misidentify her.

image

The following video gives an idea of frame rate and errors encountered thus far with facial recognition using OpenCV on the Raspberry Pi 3B+.  Keep a lookout for where it identifies the ice cream cone as me.

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

The frame update rate is acceptable for what I want to but there is room for improvement on identification.  The problems are

  • misidentification (The doll is not Margot, and the ice cream cone is not me)
  • unknown identification (not so much a problem)

 

It seems to recognize me fairly quickly when facing head on.  This isn't too surprising since all the dataset photos are head on.  It is slower to pick up the doll and misidentifies her as my granddaughter.  This is more difficult to explain.  It is really hard to explain how it mistakes me for a cone head.  This is the preliminary list of things to explore for improving identification:

  • Take photos and set up the art exhibit in better lighting
  • Place some photos with faces less head on into the training dataset
  • Find optimal photo resolution for training OpenCV (large photos are slow to train and don't seem to give better results)
  • Experiment with background to see if it makes a difference
  • Use actual people instead of the doll whose head may be anatomically incorrect - or perhaps the underlying algorithm does not recognize babies

 

Next Steps

Investigations on how to improve facial image recognition will continue.  Failing improvement, it may be just as entertaining to watch it misidentify people image.

The second Raspberry Pi can now be connected and different displays and / or actions be taken when an identification is made.

 

image

Other Posts in this Series

 

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

PiCasso Design Challenge:  Adapting Art to Ages Blog #1

 

Useful Links

Raspberry Pi Facial Recognition by Sharib Hasan on Element 14

Getting Started on Raspberry Pi by Raspberry Pi Organization

  • Sign in to reply

Top Comments

  • shabaz
    shabaz over 6 years ago +3
    Hi Frank, This is great to see, you're getting good results!! Very cool that you did this with the Python API. I've never tried this with OpenCV, I'm a beginner with it, and had an easier task to just…
  • fmilburn
    fmilburn over 6 years ago in reply to shabaz +3
    Hi Shabaz, Thanks for the encouragement! I am very much a beginner with OpenCV so comments are greatly appreciated. You picked up on it but I should have clarified in the writeup that the reason I started…
  • dubbie
    dubbie over 6 years ago +3
    Frank, You seem to be making good progress, it is only a matter of time and training before it will be (almost) correctly recognising you and the doll. I have used a web based face recognition demonstration…
Parents
  • dubbie
    dubbie over 6 years ago

    Frank,

     

    You seem to be making good progress, it is only a matter of time and training before it will be (almost) correctly recognising you and the doll.

     

    I have used a web based face recognition demonstration system before which was amazing good so I'm sure you'll get it going. Either that or you are a Cone Head!

     

    Dubbie

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

    Frank,

     

    You seem to be making good progress, it is only a matter of time and training before it will be (almost) correctly recognising you and the doll.

     

    I have used a web based face recognition demonstration system before which was amazing good so I'm sure you'll get it going. Either that or you are a Cone Head!

     

    Dubbie

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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