Research Article
CAMeL: A Self-Adaptive Framework for Enriching Context-Aware Middlewares with Machine Learning Capabilities
Listing 2
iPOJO module able to detect faces in images consumed from an SEDA queue.
(1) | public class HumanBodyProcessor implements Processor { | (2) | private CvHaarClassifierCascade classifier = new CvHaarClassifierCascade (cvLoad (“body.xml”)); | (3) | public void process (Exchange exchange) throws Exception { | (4) | //getting image raw data | (5) | ImageData imageData = exchange.getIn ().getBody (ImageData.class); | (6) | //… rgb to gray conversion | (7) | //classification of bodies in the image via OpenCV API | (8) | CvSeq bodies = cvHaarDetectObjects (grayImage, classifier, storage, 1.1, 10); | (9) | int total = bodies (); | (10) | LabelData labelData = new LabelData (“body”, total); | (11) | //send classification label to the awareness layer | (12) | producer.sendBody (“seda:label”, labelData); | (13) | } | (14) | } |
|