Face Detection on Advantech AIIS-1200P and most x64 Windows systems
This guide shows you how easy it is to create a face-detection programm on a x64 Windows machine like Advantech's AIIS-1200P
Software license: Apache 2.0
In this short guide I will show you how easy it is to create a face detection script with OpenCV and Python 3 on a WIndows x64 mashine like the Advantech AIIS-1200P.
- This Guide will use a Basler Dart camera. If you prefer any other Camera brand, make sure you have a proper alternative to Pylons Python interface to get images as a Numpy array.
- Before you start with this guide you will need to have OpenCV 3, Numpy and PyPylon up and running. Therefore follow this guide:
From Zero to Python OpenCV 3 on Windows x64
In the following snippet you can see how to setup a Basler camera within Python. Basically you can edit the same things like described in the C++ documentation of Pylon. This is just a minor demonstration.
# Simply get the first available pylon device. first_device = py.TlFactory.GetInstance().CreateFirstDevice() instant_camera = py.InstantCamera(first_device) instant_camera.Open() # You can change settings like this also in the Pylon Viewer and save them to the default profile. instant_camera.PixelFormat = "RGB8" instant_camera.StartGrabbing(py.GrabStrategy_LatestImages)
Now its time to use some very easy OpenCV to recognise faces. We will create a loop for this, which permanently will grab new camera images, find and mark faces in it, and finally show the result.
while True: # Update current image in video window. # Grab one image. img = np.zeros((1, 1)) if instant_camera.NumReadyBuffers: res = instant_camera.RetrieveResult(1000) if res: try: if res.GrabSucceeded(): currImg = res.Array finally: res.Release() faces = face_cascade.detectMultiScale(currImg, 1.3, 5) for (x, y, w, h) in faces: cv2.rectangle(currImg, (x, y), (x + w, y + h), (255, 0, 0), 2) # Display new image in video window. cv2.imshow('Video', currImg) # Wait 1 ms. cv2.waitKey(1)
You can find the Sample Code on Github.