1, install OpenCV on BPI-M2 Ultra
sudo apt-get update
sudo apt-get install libcv-dev
test opencv version:
#include <opencv2/core/core.hpp>
#include <stdio.h>
using namespace cv;
int main()
{
printf("OpenCV version is:%s\n",CV_VERSION);
return 0;
}
compile and run:
g++ -o testVersion.cpp ./testVersion.cpp -lopencv_core
2,install SimpleCV lib
sudo apt-get install ipython python-opencv python-scipy python-numpy python-setuptools
python-pip
sudo pip install https://github.com/ingenuitas/SimpleCV/zipball/master
sudo apt-get install python-pygame
sudo apt-get install python-imaging
3, inert UVC camera and test it;
4,Python realize face recognition program
#!/usr/bin/env python
from SimpleCV import *
from time import sleep
myCamera = Camera(prop_set={'width':320, 'height': 240})
myDisplay = Display(resolution=(320, 240))
while not myDisplay.isDone():
frame = myCamera.getImage()
faces = frame.findHaarFeatures('face')
if faces:
for face in faces:
print "Face at: " + str(face.coordinates())
facelayer = DrawingLayer((frame.width,frame.height))
w=face.width()
h=face.height()
print "x:"+str(w)+" y:"+str(h)
facebox_dim = (w,h)
facebox = facelayer.centeredRectangle(face.coordinates(),facebox_dim)
frame.addDrawingLayer(facelayer)
frame.applyLayers()
print "faces has detected."
else:
print "No faces detected."
frame.save(myDisplay)
sleep(.1)