Passing Messages from the shoulders of Apache:
A demonstration of distributed image processing


Part 4: Video Display Process in C++ with Avro, Qpid, and OpenCV
By Matthew Stevenson - miamg@dnikatt.h.reutroboknoshanind@obor.ttagmaiycrehpl.com  (July 25, 2011)
  1. Overview - Distributed messaging with Avro and Qpid
  2. Camera Capture Process
  3. Face Detection Process
  4. Video Display (C++)
  5. Video Display (Java)
  6. Running the Processes
  7. Complete Code
This component will:
We can reuse a lot of what we have already done to make a Video Display process in C++.
Connect to the broker, VideoTopic, and FaceQueue:
Connection myConnection("localhost:5672", "{username:admin, password:admin}");
myConnection.open();
Session mySession = myConnection.createSession();
Receiver myImageReceiver = mySession.createReceiver("example.VideoTopic; {create: always, node: {type: topic}}");
Receiver myRegionsReceiver = mySession.createReceiver("example.FaceQueue; {create: always, node: {type: queue}}");

Pull an image from the VideoTopic, and ImageRegions from the FaceQueue:
Message message = myImageReceiver.fetch();
PortableImage* pimg = unpackMessage<PortableImage>(message);
IplImage* img = unpackImage(pimg);

Message rgnsMsg = myRegionsReceiver.fetch();
ImageRegions* regions = unpackMessage<ImageRegions>(rgnsMsg);

Draw a circle on the image at each face location:
std::vector<ImageRegion> faces = faceRegions->regions;
for(std::vector<ImageRegion>::const_iterator r = faces.begin(); r != faces.end(); r++){
    int x = cvRound((r->x + r->width*0.5));
    int y = cvRound((r->y + r->height*0.5));
    int radius = cvRound((r->width + r->height)*0.25);
    cvDrawCircle(img,cvPoint(x,y),radius,CV_RGB(255,255,255),1);
}

Display the image:
cvShowImage("Window Title", img);
cvWaitKey(5);
 
  1. Overview - Distributed messaging with Avro and Qpid
  2. Camera Capture Process
  3. Face Detection Process
  4. Video Display (C++)
  5. Video Display (Java)
  6. Running the Processes
  7. Complete Code