Ejemplo n.º 1
0
// Invoke Function
bb::cascades::Image PictureHelper::getImage() {
	// Get random image from list and remove path
	if (m_imageCount == 0)
		initListImage();

	int rnd = rand() % m_imageCount;

	// Get imagedata and generate random width & height
	bb::ImageData img = fromQImage(loadQImage(listImg[rnd]));
	float ratio = (float)img.width() / (float)img.height();
	int max, min;	// max min to random width or height
	max = 700;
	min = 450;
	int rnd2 = (rand() % (max - min)) + min;
	if (ratio > 1) { //if width > height
		setImageWidth(rnd2);
		setImageHeight(rnd2 / ratio);
	} else {	// if width < height
		setImageHeight(rnd2);
		setImageWidth(rnd2 * ratio);
	}

	listImg.removeAt(rnd);
	setImageCount(listImg.count());

	return bb::cascades::Image(img);
}
Ejemplo n.º 2
0
 CVImage  CVImage::fromFile(const QString &fileName)
{
    QImage qImage;
    bool isSuccessfull = qImage.load(fileName);
    if(isSuccessfull)
    {

        return fromQImage(qImage);
    }
    else
    {
        std::cerr << "can't load image from file";
        return  CVImage(0,0);
    }
}
Ejemplo n.º 3
0
/**
 * ImageLoader::onImageProcessingFinished(const QImage&)
 *
 * Handler for the signal indicating the result of the image processing.
 */
void ImageLoader::onImageProcessingFinished(const QImage &image)
{
	try
	{
		if (!image.isNull()) {
			if (image.size().height() > 0) {
				m_image = bb::cascades::Image(fromQImage(image));
			}
			emit imageChanged();

			m_label.clear();
			emit labelChanged();
		}

		m_loading = false;

		emit loadingChanged();
	}
	catch (...)
	{
		qDebug() << "FMI ##### AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHH!!!!";
	}
}
Ejemplo n.º 4
0
Image * ImageFactory::fromFile(const QString & filename, MatrixType t){
	debug("in");
	QImage qimage(filename);
	if(qimage.isNull()) throw NoFileException(filename);
	return fromQImage(qimage,t);
}