AIR-OpenCV-Extension is a native extension that exposes HAAR cascade executions with OpenCV. It’s implemented as an asynchronous library and uses a separate thread for the OpenCV execution. This way the application doesn’t lock up during the image processing.

In order to use the extension, a developer has to create an instance of the extension, add a detection listener and load a haar cascade xml file. After the initial configuration, image data (bitmap) can be sent to the extension through the updateImage method. It’s also possible to set minimum and maximum sizes for the detection area’s, so an area smaller than the minimum size or larger than the maximum size are ignored. It’s recommend to supply a minimum size for the detection, e.g. a face must be at least 40×40 pixels, as this will improve the application performance.


// initial configuration
openCV = new OpenCV();
openCV.addEventListener(DetectionEvent.DETECTION_UPDATE, detectionUpdateHandler);

// Read image data and upload it to the extension
openCV.updateImage(bmpData, minSize, maxSize);

// In the event handler, you’ll get the detected area’s
// with the event object that is provided:

protected function detectionUpdateHandler(event:DetectionEvent):void {
  for each(var r:Rectangle in event.rectangles) {
    //draw rectangles here
Air Native Extension, Mac . URL.