Esempio n. 1
0
int main()
{
	BinaryOperation bin1("10101");
	BinaryOperation bin2(5);
	BinaryOperation bin3("11");
	BinaryOperation bin4 = bin1 + bin3;
	cout << bin4 << endl;
	cin.get();
}
Esempio n. 2
0
void FOEFinder::computeFoE(VelocityBuffer & vb, bool vis){


    //Step 1: Leaky Integaration
    bin2(vb);

    //Step 2: Find the patch of visual fiel with maximum value
   int centerX, centerY;
   double foeMaxValue;
   getFOEMapMax(centerX, centerY,  foeMaxValue);

   //Step 3: Shift teh FOE toward the maximum patch
   if (vb.getSize() < 20){
       foeX =int ( foeX + WEIGHT_FACTOR * (centerX - foeX) + .5 );
       foeY =int ( foeY + WEIGHT_FACTOR * (centerY - foeY) + .5 );

       if (foeX < 0) foeX = 0;
       if (foeY < 0 ) foeY = 0;
       if (foeX > X_DIM) foeX = X_DIM;
       if (foeY > Y_DIM) foeY = Y_DIM;
   }


   cout << foeX << " " << foeY << endl;
   //Send the FOE map to output port
   if (vis){
       yarp::sig::ImageOf<yarp::sig::PixelRgb>& img=outPort-> prepare();
       img.resize(X_DIM, Y_DIM);
       img.zero();


//       double normFactor = 254 / foeMaxValue;
//       for (int i = 0; i < X_DIM; ++i) {
//            for (int j = 0; j < Y_DIM; ++j) {
//                img(i,j) = yarp::sig::PixelRgb (0,0 , normFactor * foeMap(i,j) );
//            }
//        }

       for (int i = 0; i < vb.getSize(); ++i) {
           img(vb.getX(i), vb.getY(i)) = yarp::sig::PixelRgb ( 100, 100, 100 );
       }

       static const yarp::sig::PixelRgb pr(200,0,0);
       yarp::sig::draw::addCircle(img,pr,foeX,foeY,4);

       static const yarp::sig::PixelRgb pb(0,200,0);
       yarp::sig::draw::addCircle(img,pb,centerX,centerY,FOEMAP_MAXREG_SIZE);

       outPort -> write();
   }
}
Esempio n. 3
0
void Binomial::demo()
{
	std::cout << "------------Jackson Paul-------------" << std::endl;
	int three = 3;
	Binomial bin(6, 7, 8);
	Binomial bin2(bin);
	Binomial bin3 = bin + bin2;
	Binomial bin4 = bin * 3;
	bin.print();
	bin2.print();
	bin3.print();
	bin4.print();
	std::cout << "------------Jackson Paul-------------" << std::endl;
}
double bin(const double *knots,int ii,int n,double x)
{
    double delta = 1e-8;
    if(n == 0)
    {
        return bin0(knots,ii,n,x);
    }
    else if(n == 1)
    {
        return bin1(knots,ii,n,x);
    }
    else if(n == 2)
    {
        return bin2(knots,ii,n,x);
    }
    else
    {
        return (x-knots[ii])/(knots[ii+n]-knots[ii]+delta)*bin(knots,ii,n-1,x) + 
            (knots[ii+n+1] - x)/(knots[ii+n+1]-knots[ii+1]+delta)*bin(knots,ii+1,n-1,x);
    }
}
Esempio n. 5
0
void save_factors() {
    printf("Saving factors to files... ");

    std::stringstream ss;
    ss<<"../../user_factors_st="<<steps<<"_fn="<<fact_n<<"_a="<<alfa<<"_l="<<lambda;
    QString file_name = QString::fromStdString(ss.str());

    QFile binfile(file_name + ".bin");
    binfile.open(QFile::WriteOnly);
    QDataStream bin(&binfile);
    bin << user_factors;
    binfile.close();

    file_name = file_name.replace("user", "item");

    QFile binfile2(file_name + ".bin");
    binfile2.open(QFile::WriteOnly);
    QDataStream bin2(&binfile2);
    bin2 << item_factors;
    binfile2.close();

    printf("ok\n");
}