void MockAnalytic::process(analytic::ImageQueue<analytic::api::Image_t>* pInputQueue, analytic::ImageQueue<analytic::api::Image_t>* pOutputQueue)
{

	while(true)
	{
		/* 1. get a image from input queue */
		api::Image_t image = pInputQueue->pop();

		cv::Mat matInputImage = image.matImage; // got it
		/* 2. clone the input image */
		cv::Mat matToBeProcessed = matInputImage.clone();
		/* 3. release the input image */
		matInputImage.release(); //please do this release!
		/* 4. OK, now use cloned image for analysis */

		// Start processing
		cv::Mat matOutputImage;
		cv::cvtColor(matToBeProcessed, matOutputImage, CV_BGR2GRAY);
		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
		// freeing generated Mats
		matOutputImage.release();
		matToBeProcessed.release();

		/* 5. set output */
		image.bGenerateAnalyticEvent = true;
		std::string sResultXml;
		resultXml("Did a mock process.", sResultXml);
		image.sCustomTextResult = sResultXml;
		pOutputQueue->push(image);
	}
}
示例#2
0
void CollectMetadataOperation::restoreState( BinaryIStream& istr ) {
  RefPtr< XmlObject > resultXml( new XmlObject );
  istr >> *resultXml;

  if ( !mContextStack.empty() ) {
    mContextStack.top()->appendChild( resultXml );
  } else {
    mResult->appendChild( resultXml );
  }
}
void FaceDetectAnalytic::process(analytic::ConcurrentQueue<analytic::api::Image_t>* pInputQueue, analytic::ConcurrentQueue<analytic::api::Image_t>* pOutputQueue)
{
	/* Analytic process starts from here */
	while(pHaarCascade)
	{
		/* 1. get a image from input queue */
		api::Image_t image = pInputQueue->pop();
		cv::Mat matInputImage = image.matImage; // got it
		/* 2. clone the input image */
		cv::Mat matToBeProcessed = matInputImage.clone();
		/* 3. release the input image */
		matInputImage.release(); //please do this release!
		/* 4. OK, now use cloned image for analysis */

		// Start processing
		cv::Mat matGray;
		cv::cvtColor(matToBeProcessed, matGray, CV_BGR2GRAY);
		equalizeHist(matGray, matGray);
		vector<Rect_<int> > vFaces;
		pHaarCascade->detectMultiScale(matGray, vFaces, _dScaleFactor, _iMinNeighbors, 0|CV_HAAR_SCALE_IMAGE, _minSize, _maxSize);
		for (size_t i = 0; i < vFaces.size(); ++i) {
			Rect recFace = vFaces[i];
			Mat matFace = matGray(recFace);
			rectangle(matToBeProcessed, recFace, CV_RGB(0, 255, 0), 1);
			matFace.release();
		}

		if(_bDisplayOutput)
		{
			cv::imshow("Output", matToBeProcessed);
			cv::waitKey(1);
		}

		// freeing generated Mats
		matGray.release();
		matToBeProcessed.release();

		/* 5. set output */
		if(vFaces.size() > 0)
		{
			image.bGenerateAnalyticEvent = true;
			resultXml(vFaces, image.sCustomTextResult);
		}
		/* 6. push into output queue */
		pOutputQueue->push(image);
	}
}
示例#4
0
void tst_QXmppMessage::testDelayWithMultipleStamp()
{
    // the XEP-0203 should override XEP-0091's value since XEP-0091 was no more standard protocol
    QByteArray xml(
        "<message type=\"normal\">"
            "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06.123Z\"/>"
            "<x xmlns=\"jabber:x:delay\" stamp=\"20100629T08:23:06\"/>"
        "</message>");
    QByteArray resultXml(
        "<message type=\"normal\">"
            "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06.123Z\"/>"
        "</message>");

    QXmppMessage message;
    parsePacket(message, xml);
    qDebug() << message.stamp();
    QCOMPARE(message.stamp(), QDateTime(QDate(2010, 06, 29), QTime(8, 23, 6, 123), Qt::UTC));
    serializePacket(message, resultXml);
}