【问题标题】:Face tracking using opencv arduino and python使用 opencv arduino 和 python 进行人脸跟踪
【发布时间】:2017-03-30 17:19:13
【问题描述】:

我正在从事面部跟踪项目。我在 python 上成功编码了人脸检测。我需要通过网络摄像头跟踪我的脸。我有 arduino 用于电机控制。我无法追踪我的脸,很难与 arduino 交流。以及我应该使用什么代码来跟踪我不知道轴。请帮忙????

【问题讨论】:

    标签: python opencv arduino


    【解决方案1】:

    Face Detection in Python Using a Webcam

    import cv2
    import sys
    
    cascPath = sys.argv[1]
    faceCascade = cv2.CascadeClassifier(cascPath)
    
    video_capture = cv2.VideoCapture(0)
    
    while True:
        # Capture frame-by-frame
        ret, frame = video_capture.read()
    
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    
        faces = faceCascade.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            flags=cv2.cv.CV_HAAR_SCALE_IMAGE
        )
    
        # Draw a rectangle around the faces
        for (x, y, w, h) in faces:
            cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
    
        # Display the resulting frame
        cv2.imshow('Video', frame)
    
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    # When everything is done, release the capture
    video_capture.release()
    cv2.destroyAllWindows()
    

    但是你知道你不能在任何类型的微控制器上的 arduino 或任何其他 OpenCV 喜欢的(图像处理库)上使用它 就此而言,因为它们的处理器功率非常低,仅足以处理一些 IO 命令,但您也可以使用一些更昂贵的相机模块,并在硬件上内置人脸检测。 进行人脸检测;但如果使用网络摄像头,您将需要 raspberry pi 或任何其他具有足够 CPU 和 GPU 的单板电脑来完成这项工作。

    和python的交流可以去arduino playground

    Arduino and Python

    安装pySerial后,从Arduino读取数据就很简单了:

    >>> import serial
    >>> ser = serial.Serial('/dev/tty.usbserial', 9600)
    >>> while True:
    ...     print ser.readline()
    '1 Hello world!\r\n'
    '2 Hello world!\r\n'
    '3 Hello world!\r\n'
    

    【讨论】:

    • 感谢您的回复,我的笔记本电脑装有 python3.5 进行人脸检测。现在我如何在检测到人脸和在两种情况下都没有检测到人脸时进行串行通信。你能给我完整的代码吗?
    猜你喜欢
    • 2011-09-07
    • 1970-01-01
    • 2013-07-17
    • 1970-01-01
    • 2016-07-20
    • 1970-01-01
    • 2017-05-31
    • 2017-07-08
    • 2014-06-28
    相关资源
    最近更新 更多