示例#1
0
void CvWindow_Sink::onNewImageN(int n) {
	CLOG(LTRACE) << name() << "::onNewImage(" << n << ")";

	try {
		if (!in_img[n]->empty()) {
			img[n] = in_img[n]->read().clone();
		}

		Types::DrawableContainer ctr;
		while (!in_draw[n]->empty()) {
			ctr.add(in_draw[n]->read()->clone());
			to_draw[n] = boost::shared_ptr<Types::Drawable>(ctr.clone());
		}

		if (to_draw[n]) {
			to_draw[n]->draw(img[n], CV_RGB(255,0,255));
			// TODO: dodać wygaszanie starszych drawable, np. przez 10 odświeżeń
			//to_draw[n] = boost::shared_ptr<Types::Drawable>();
		}

		// Display image.
		//onStep();
	} catch (std::exception &ex) {
		CLOG(LERROR) << "CvWindow::onNewImage failed: " << ex.what() << "\n";
	}
}
示例#2
0
void CvWindow_Sink::onNewImageN(int n) {
	CLOG(LTRACE) << name() << "::onNewImage(" << n << ")";

	try {
		if (!in_img[n]->empty()) {
			img[n] = in_img[n]->read().clone();
		}

		if (to_draw_timeout[n])
			--to_draw_timeout[n];

		Types::DrawableContainer ctr;
		while (!in_draw[n]->empty()) {
			ctr.add(in_draw[n]->read()->clone());
			to_draw[n] = boost::shared_ptr<Types::Drawable>(ctr.clone());
			to_draw_timeout[n] = 10;
		}

		if (to_draw[n]) {
			float opacity = 0.1 * to_draw_timeout[n];
			if (opacity > 0.01) {
				cv::Mat overlay;
				img[n].copyTo(overlay);
				to_draw[n]->draw(overlay, CV_RGB(255,0,255));
				cv::addWeighted(overlay, opacity, img[n], 1-opacity, 0, img[n]);
			}
		}

		// Display image.
		//onStep();
	} catch (std::exception &ex) {
		CLOG(LERROR) << "CvWindow::onNewImage failed: " << ex.what() << "";
	}
}