Smile Detection in Processing – Mac OSX

I manage to compile an OSX version of the library. I use the 10.6 SDK to package the library. You can download the sample application below. I place it temporarily in a code folder.

PSmile library sample

smile detection processing.org

smile detection processing.org
This is the Processing source code for the example.

import processing.video.*;
import pSmile.PSmile;
 
Capture cap;
PSmile smile;
PImage img2;
float res, factor;
PFont font;
int w, h;
 
void setup() {
  size(640,480);
  w = width/2;
  h = height/2;
  background(0);
  cap = new Capture(this, width, height, Capture.list()[1], 25);
  img2 = createImage(w,h,ARGB);
  smile = new PSmile(this,w,h);
  res = 0.0;
  factor = 0.0;
  font = loadFont("SansSerif.plain-16.vlw");
  textFont(font,16);
  textAlign(CENTER);
  noStroke();
  fill(255,200,0);
  rectMode(CORNER);
}
 
void draw() {
  img2.copy(cap,0,0,width,height,0,0,w,h);
  img2.updatePixels();
  image(cap,0,0);
  res = smile.getSmile(img2);
  if (res>0) {
    factor = factor*0.8 + res*0.2;
    float t_h = factor*30;
    rect(width/2-20,height-t_h-30,40,t_h);
  }
  String str = nf(res,1,4);
  text(str,width/2,height-10);
}
 
void captureEvent(Capture _c) {
  _c.read();
}
This entry was posted in Uncategorized and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.

24 Comments

  1. Sunny
    Posted 2014/09/04 at 12:12 am | Permalink

    Hi Bryan
    Where can I download Psmile library?

  2. Izzie
    Posted 2013/11/08 at 10:26 am | Permalink

    when I run the code it runs but there is no image in the application. Have I not installed something correctly?

    Izzie

  3. Luis
    Posted 2013/07/08 at 4:51 am | Permalink

    Hello brian, i get the cam window all black, any suggestions?

    • Jasper
      Posted 2013/10/05 at 10:35 pm | Permalink

      Hi Brian,

      Same happens here, tried to modify Capture.list()[1] to 0, and still can’t capture anything, the cam windows is all black.

    • Izzie
      Posted 2013/11/13 at 11:50 pm | Permalink

      Hey Luis,
      Did you ever get the video up an working Luis?
      thanks Izzie

    • Posted 2013/11/27 at 8:56 am | Permalink

      Hi Luis, you just need to change this line:

      cap = new Capture(this, width, height, Capture.list()[1], 25);

      to

      cap = new Capture(this, width, height);

  4. Izac
    Posted 2012/06/05 at 9:54 am | Permalink

    Hi Bryan,

    This is the errors I am getting..
    Any chance you could help out?

    Cheers

    Izac
    java.lang.NullPointerException
    at processing.app.Library.getClassPath(Library.java:298)
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:390)
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
    at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
    at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
    at java.lang.Thread.run(Thread.java:680)

  5. James Britto .C
    Posted 2012/03/06 at 10:06 pm | Permalink

    Hey I’m Getting this Error When i Compiled it Under Windows 7 at line
    cap = new Capture(this, width, height, Capture.list()[1], 25);

    Exception in thread “Animation Thread” java.lang.ArrayIndexOutOfBoundsException: 1
    at Smile002.setup(Smile002.java:40)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

    Do U have Any suggestions To Over come This Problem…
    Thanks in advance…..

    • bryan
      Posted 2012/03/08 at 11:29 am | Permalink

      Dear James,
      It may be due to the number of webcams in your computer. In the example, I use Capture.list()[1], that is the 2nd webcam in my computer. If you have only one webcam, you can skip this or use Capture.list()[0]. See if it helps. Thanks.

      Bryan

  6. filippo
    Posted 2012/02/13 at 7:01 am | Permalink

    Hi Bryan,

    Unfortunately I could make working your ‘SmileRecognition’. Do you have any suggestion to give me to fix this problem on a pc with Windows XP?

    Just to give you information that might be useful to figure out the problem I have installed ‘OpenCV_1.1pre1a.exe’ and I could make working all the openCV examples (http://ubaa.net/shared/processing/opencv/).

    processing.app.debug.RunnerException: UnsatisfiedLinkError: C:\Documents and Settings\Filippo\Documenti\Processing\Smile002\code\PSmile.dll: Can’t find dependent libraries
    at processing.app.Sketch.placeException(Sketch.java:1543)
    at processing.app.debug.Runner.findException(Runner.java:582)
    at processing.app.debug.Runner.reportException(Runner.java:558)
    at processing.app.debug.Runner.exception(Runner.java:498)
    at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
    at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
    at processing.app.debug.EventThread.run(EventThread.java:89)
    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: C:\Documents and Settings\Filippo\Documenti\Processing\Smile002\code\PSmile.dll: Can’t find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at pSmile.PSmile.(PSmile.java:9)
    at Smile002.setup(Smile002.java:42)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:619)

    Waiting to hear back from you, best regards.
    Filippo

    • bryan
      Posted 2012/02/15 at 2:08 pm | Permalink

      Hi Filippo,
      It may be missing libraries from Windows platform. I suggest you run Dependency Walker (http://www.dependencywalker.com/) in your computer to check my library PSmile.dll to see which libraries are missing in your machine. I build it in Windows 7 with Visual Studio 2010. Thanks.

      Bryan

  7. lakshya
    Posted 2011/09/11 at 5:19 am | Permalink

    hey bryan
    I am having same Library dependency problem and dealing with video capturing error in processing 1.2.1in vista and windows 7 if i dont use Psmile library and exclude its function code is running fine . So i think their problem wid Psmile library dependency plz chek

  8. Steve
    Posted 2011/07/20 at 3:19 pm | Permalink

    Hello Bryan!
    I got an error while setting up capture on Mac with a massage below.
    ————————–
    quicktime.std.StdQTException[QTJava:7.6.6g],-2090=videoOutputInUseErr,QT.vers:7668000
    at quicktime.std.StdQTException.checkError(StdQTException.java:40)
    at quicktime.std.sg.SGChannel.setDevice(SGChannel.java:330)
    at processing.video.Capture.init(Capture.java:203)
    at processing.video.Capture.(Capture.java:154)
    at Smile002.setup(Smile002.java:43)
    at processing.core.PApplet.handleDraw(PApplet.java:1608)
    at processing.core.PApplet.run(PApplet.java:1530)
    at java.lang.Thread.run(Thread.java:637)
    Exception in thread “Animation Thread” java.lang.RuntimeException: Error while setting up Capture
    at processing.core.PApplet.die(PApplet.java:2571)
    at processing.core.PApplet.die(PApplet.java:2580)
    at processing.video.Capture.init(Capture.java:244)
    at processing.video.Capture.(Capture.java:154)
    at Smile002.setup(Smile002.java:43)
    at processing.core.PApplet.handleDraw(PApplet.java:1608)
    at processing.core.PApplet.run(PApplet.java:1530)
    at java.lang.Thread.run(Thread.java:637)
    ————————–

    Do I need particular version of quicktime player?
    or do you have other solution…?

    Thank you for your time!

    • bryan
      Posted 2011/07/28 at 1:06 pm | Permalink

      Hi Steve,
      The library is independent of the quicktime version. It seems that you cannot do the capture even without my library. Maybe you can take a look of the processing forum at http://wiki.processing.org/w/Video_Issues

      Otherwise, you can try to update to the latest Quicktime and Java for your Mac to have a try again. Thank you.

      Bryan

  9. alex
    Posted 2011/07/11 at 12:04 am | Permalink

    I extracted [Smile002_Processing.zip] into [C:/processing-1.0.3/processing-1.0.3/libraries/] folder, compile the Smile002.pde …. but still get [UnsatisfiedLinkError].

    How to solve the
    [UnsatisfiedLinkError: C:/processing-1.0.3/processing-1.0.3/libraries/Smile002/code/PSmile.dll: Can’t find dependent libraries]

    OS Win7, Processing-1.0.3
    Thanks.

  10. random
    Posted 2011/06/10 at 3:58 am | Permalink

    hey Bryan! this library works in pc/win7?

    • bryan
      Posted 2011/06/30 at 1:34 pm | Permalink

      Yes, I also tested in Windows 7. Nevertheless, I often use the jMyron library for video capture instead of the Quicktime + winvdig standard video library in Processing. It may be the reason. Thanks.

      Bryan

  11. Marc
    Posted 2011/05/26 at 7:06 pm | Permalink

    Hey, the link of the application is broken! 🙁

    • bryan
      Posted 2011/06/09 at 11:24 am | Permalink

      The link is now updated. Thanks.

  12. Lidy
    Posted 2011/05/05 at 12:29 pm | Permalink

    The link for the OSX link doesn’t seem to be working for me..tells me that the document is not found on the server 🙁

    • bryan
      Posted 2011/06/09 at 11:24 am | Permalink

      The link is updated now. Thx.

  13. bryan
    Posted 2011/06/30 at 1:32 pm | Permalink

    I did the Windows version first. Maybe, the Processing Video library for capture is not working well with Winvdig. You can try the jMyron library instead to do video capture in Windows.

    Bryan

2 Trackbacks