DISQUS

In Traction: Fun with Python, OpenCV and face detection

  • Si · 1 year ago
    excellent stuff. Many thanks
  • Jo Vermeulen · 1 year ago
    You're welcome! I'm glad you find it useful.
  • Nirav Patel · 1 year ago
    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.
  • Jo Vermeulen · 1 year ago
    You are right, I noticed yesterday that the cascade file was part of OpenCV. Thanks for clarifying!
  • daxroc · 1 year ago
    Nice script , worked fine for me @30fps
  • Jhon · 1 year ago
    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
  • Jo Vermeulen · 1 year ago
    Ah thanks, that's very helpful!
  • randomm · 1 year ago
    this is great stuff! thanks for this...

    We managed to get up to 4 faces recognized at the same time.
  • Jo Vermeulen · 1 year ago
    You're welcome, I'm glad it was useful for you.
  • Venkat · 10 months ago
    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!
  • Jo Vermeulen · 10 months ago
    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!
  • Simon · 10 months ago
    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.
  • gabox · 5 months ago
    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
  • Jo Vermeulen · 2 months ago
    It might be good to use a specific GUI toolkit in this case, such as WxWindows.

    Have a look at Gary Bishop's blog post, where he grabs a bitmap from the camera and displays this in a Wx window: http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/p...
  • nop · 3 months ago
    Hello!
    Your if script silently hangs on this line for me:
    cascade = cv.LoadHaarClassifierCascade('haarcascade_frontalface_alt.xml', cv.Size(1,1))

    What can be the problem here? This xml exists in same directory and the is no any error output.

    Thanks in advance!
  • Jo Vermeulen · 2 months ago
    Are you using Ubuntu?
  • nop · 1 month ago
    yes, 9.04
  • ClubPenguinCheats · 2 months ago
    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).
  • sreeraj · 2 months ago
    hi, i'm having this problem when i'm running your code..

    i have an integrated camera on my laptop, which works with some apps like cheese.

    while running this code, the camera(led) turns on, but nothing comes on the screen.
    the script hangs and i have to ctrl+C to close it.

    any pointers to help me with this situation will be appreciated.
    thanks
  • cyril · 1 month ago
    Hello, i try your code but i have this:

    cyril@zilo2:~/Bureau/test$ sudo python webcam2.py
    Traceback (most recent call last):
    File "webcam2.py", line 3, in <module>
    from CVtypes import cv
    ImportError: No module named CVtypes

    i use ubuntu, how cab i install opencv? sudo apt-get install ?

    Thinks @+
  • nop · 1 month ago
    In synaptic you can fing python-opencv
  • cyril84 · 1 month ago
    Hello, i have this:

    Traceback (most recent call last):
    File "opencv.py", line 2, in <module>
    from CVtypes import cv
    ImportError: No module named CVtypes

    What is this mistake? how install cvtypes?

    Thinks
  • cyril84 · 1 month ago
    I have do sudo apt-get install python-opencv. It is already installed. What can i do?
  • Jo Vermeulen · 1 week ago
    The script uses Gary Bishop's CVtypes, not python-opencv.
  • online games · 1 month ago
    I'm still having trouble with the escape key. Any tips?
  • club penguin cheats · 3 days ago
    this is awesome, i have been wanting to do this with python for awhile now. great stuff.