Exemple #1
0
double Fractais::press(Mat image, int op, int d)
{
    double c = (double)d/2;
    int pr = 0;
    switch (op) {
    case 1:
        pr = pressMax(c, image.cols/d);
        break;
    default:
        pr = pressMax(c, image.rows/d);
        break;
    }

    double   delta = 0;
    for(int i=0; i<(int)image.rows/d; i++){
        int op = 0;
        for(int j=0; j<(int)image.cols/d; j++){
            setRoi(Rect(j*d,i*d,d,d));
            op = countNonZero(image(roi))/image(roi).total();
            if(op){
                delta += op*(c+(j*d))/pr;
            }
        }
    }
    return delta;
}
Exemple #2
0
int Fractais::calculaN(Mat img, int d)
{
    Mat aux;
    threshold(img,aux,200.0,255.0,THRESH_BINARY);
    //cvtColor(aux,aux,CV_BGR2GRAY);
    int n = 0;
    unsigned noZeros;
    for(int i=0; i<d; i++){
        for(int j=0; j<d; j++){
            setRoi(Rect(j*aux.cols/d,i*aux.rows/d,(int)aux.cols/d,aux.rows/d));
            noZeros = countNonZero(aux(roi));
            if(noZeros < aux(roi).total()){
                n++;
            }
        }
    }

    return n;
}
Exemple #3
0
double Fractais::DiferentialBoxCounting(int r)
{
    r = r*2;
    double min, max;
    int mr;
    double lr = 0;
    double pN = 0;
    double pD = 0;
    int q = (image.rows/r)*(image.cols/r);
    Mat aux;
    cvtColor(image,aux,CV_BGR2GRAY);

    for(int i=0; i<aux.rows/r;i++){
        for(int j=0; j<aux.cols/r;j++){
            setRoi(Rect(j*r,i*r,r,r));
            minMaxLoc(aux(roi),&min,&max);
            mr = (int)(ceilf(max/r) - ceilf(min/r)) + 1;
            pN += (double)pow(mr,2);
            pD += (double)mr/q;
        }
    }
    lr = (pN/q)/pow(pD,2);
    return lr;
}
Exemple #4
0
pure::pure(QWidget *parent) : QMainWindow(parent) {
	//the meta types of the opencv datatypes have to be registered
	//that one can use them in Qt's signal and slot system
	qRegisterMetaType<cv::Rect>("cv::Rect");
	qRegisterMetaType<cv::Mat>("cv::Mat");

	ui.setupUi(this);
	//setAttribute(Qt::WA_DeleteOnClose);

	grabber = new Grabber();
	sigProc = new SignalProcessor();
	imgProc = new ImageProcessor(1);
	recorder = new RecorderWidget();

	//QThread is a thread handling class, that represents the thread
	//itself. The code that is run inside the thread is determined
	//by moving a QObject to the thread. once the thread is started
	//the QObject behaves as it normally would but runs inside the
	//thread.
	grabberThread = new QThread(this);
	imgProcThread = new QThread(this);
	sigProcThread = new QThread(this);
	recorderThread = new QThread(this);

	grabber->moveToThread(sigProcThread);
	imgProc->moveToThread(imgProcThread);
	sigProc->moveToThread(grabberThread);
	recorder->moveToThread(recorderThread);

	grabberThread->start();
	imgProcThread->start();
	sigProcThread->start();
	recorderThread->start();

	//the connections of the singal and slot system. when you connect two QObjects
	//using
	//    connect(sender, signal, receiver, slot)
	//the slot function gets called everytime the sender emits the signal.
	//signals can also carry data. datatypes unknown to Qt (here cv::Mat and cv::Rect)
	//must be declared and registered first.
	connect(grabber, SIGNAL(output(cv::Mat)), ui.display, SLOT(setFrame(cv::Mat)));
	connect(grabber, SIGNAL(output(cv::Mat)), imgProc, SLOT(input(cv::Mat)));

	connect(imgProc, SIGNAL(output(double, double, double)), sigProc, SLOT(input(double, double, double)));
	connect(imgProc, SIGNAL(output(double, double, double)), recorder, SLOT(input(double, double, double)));
	connect(imgProc, SIGNAL(output(double, double, double)), this, SLOT(onNewSamples(double, double, double)));
	connect(imgProc, SIGNAL(newRoi(cv::Rect)), ui.display, SLOT(setRoi(cv::Rect)));

	connect(sigProc, SIGNAL(output(double, double, double)), ui.meanPlot, SLOT(input(double, double, double)));
	connect(sigProc, SIGNAL(output(double, double, double)), ui.fftWidget, SLOT(addSamples(double, double, double)));
	
	connect(ui.fftWidget, SIGNAL(newHrEstimation(QString)), ui.labelHr, SLOT(setText(const QString &)));
	
	if(grabber->init(15,0) == 0) {
		//showFullScreen();
		grabber->start();
		showMaximized();
	}
	else {
		QMessageBox msgBox;
		msgBox.setText("No camera found, ending now.");
		msgBox.exec();
		close();
	}
}