bool MS_Barcode_Decide::onStep()
{
	blobs_ready = hue_ready = false;

	try {
		int i;
		IplImage h = IplImage(hue_img);
		Types::Blobs::Blob *currentBlob;
		Types::DrawableContainer signs;

		// iterate through all found blobs
		for (i = 0; i < blobs.GetNumBlobs(); i++ )
		{
			currentBlob = blobs.GetBlob(i);

			// get mean color from area coverd by blob (from hue component)
			double me = currentBlob->Mean(&h);
			double st = currentBlob->StdDev(&h);

			// get blob bounding rectangle and ellipse
			//CvBox2D be = currentBlob->GetEllipse();
			cv::Rect bb = currentBlob->GetBoundingBox();

			signs.add(new Types::Rectangle(bb.x, bb.y, bb.width, bb.height));

		}

		out_signs.write(signs);

		newImage->raise();

		return true;
	} catch (...) {
		LOG(LERROR) << "MS_Sign_Decide::onNewImage failed\n";
		return false;
	}
}
Esempio n. 2
0
bool ExtractBlocks_Processor::onStep()
{
	LOG(LTRACE) << "ExtractBlocks_Processor::step\n";
  
	blobs_ready = hue_ready = false;

	try {
		int id = 0;
		int i;
		IplImage h = IplImage(hue_img);
		Types::Blobs::Blob *currentBlob;
		Types::DrawableContainer blocks;

		// iterate through all found blobs
		for (i = 0; i < blobs.GetNumBlobs(); i++ )
		{
			currentBlob = blobs.GetBlob(i);

			// get blob bounding rectangle
			CvRect r2 = currentBlob->GetBoundingBox();

			++id;

			blocks.add(new Types::Rectangle(r2.x, r2.y, r2.width, r2.height));

			out_blocks.write(blocks);

			newImage->raise();
		}

		return true;
	}   catch (...) {
		LOG(LERROR) << "ExtractBlocks_Processor::onNewImage failed\n";
		return false;
  }
}