DISQUS

DISQUS Hello! In Traction is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Fun with Python, OpenCV and face detection

Started by Jo Vermeulen · 1 year ago

I had some fun with Gary Bishop’s OpenCV Python wrapper this morning. I wanted to try out OpenCV for detecting faces using a web cam. This could be used for instance to see if someone is sitting behind his desk or not. I used Gary’s Python wrapper since I didn’t want to code in C++.

I [...] ... Continue reading »

13 comments

  • excellent stuff. Many thanks
  • You're welcome! I'm glad you find it useful.
  • Just to clarify, the Haar cascade file is one of the sample ones that comes with OpenCV. The script I wrote was based on the OpenCV face detection sample too, but using gstreamer instead of OpenCV's HighGUI to interface the webcam (HighGUI didn't support the camera in the XO).

    Its good that you got it working though. There is some pretty amazing stuff in OpenCV.
  • You are right, I noticed yesterday that the cascade file was part of OpenCV. Thanks for clarifying!
  • Nice script , worked fine for me @30fps
  • I figured it out how to properly use cvWaitKey.

    In your code you are waiting just 10 ms for a key, and only after the image was processed.
    So, if you wait a little bit longer(maybe 100ms, but this will slow down a lot the fps) you will be able to catch the keys.

    However, there is also another problem cvWaitKey returns -1 when no key was pressed, but return a string(char) holding the key pressed, so you need to do the following:
    if k!=-1 and ord(k) == 0x1b: # ESC
    print 'ESC pressed. Exiting ...'
    break
  • Ah thanks, that's very helpful!
  • this is great stuff! thanks for this...

    We managed to get up to 4 faces recognized at the same time.
  • You're welcome, I'm glad it was useful for you.
  • When I tried runing the above code in windows xp, encountered the following error.

    D:\SW\CamFD>python test2.py
    Traceback (most recent call last):
    File "test2.py", line 2, in <module>
    from CVtypes import cv
    File "D:\SW\CamFD\CVtypes.py", line 42, in <module>
    _cxDLL = cdll.cxcore100
    File "C:\Python25\lib\ctypes\__init__.py", line 423, in __getattr__
    dll = self._dlltype(name)
    File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 126] The specified module could not be found

    Any help regarding this will be great!
  • You need to have OpenCV installed. I guess that is the problem. I didn't try it on Windows yet since there's no D-BUS support, but in theory the face detection code should work.

    I will probably release a first version of the code in the following weeks, so stay tuned!
  • Hello, Sir
    I'm from Asia. I'm just starting to learn openCV.
    Is there any opinion or advise from Sir as an expert to me to start learning opencv

    Thank you very much.
  • hi i want to put the window's webcam in other program both under python, but i dont how to do it, the project is a program with bottons and they controll a robot and the robot get the webcam, by the way im using linux mint 6

Add New Comment

Returning? Login