yarp::sig::Matrix parzenWindowEstimator::getHist() { yarp::sig::Matrix Hist(binsNum[0],binsNum[1]); Hist.zero(); for (size_t i = 0; i < binsNum[0]; i++) { for (size_t j = 0; j < binsNum[1]; j++) { Hist(i,j)=getHist(i,j); } } return Hist; }
void MyZKbMain::keyPressEvent(QKeyEvent* k) { QPixmap pm; pm.load("ruleta_usr.png"); ZConfig Num(QString("numeros.cfg"), true); ZConfig Hist(QString("historial.cfg"), true); switch (k->key()) { case 0x1046: //Boton Verde break; case 0x1030: //Boton Verde calcular=0; reboot = new ZMessageDlg("zRoulette", QString("Sistema Ubeda 0.5\nBasado en el Sistema de Cuadros\n\nwww.developermoto.com/es\nwww.modmymoto.com\n\n(C)2009 RacingLocura07, CepiPerez"), (ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); break; case 0x1031: //Boton Rojo calcular=0; reboot = new ZMessageDlg("zRoulette", "Desea salir?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); if(reboot->exec()==1) { exit(); } else { update(); break; } case 0x1012: //Tecla de Navegacion De Izquierda calcular=0; if (current > 1 ) { --current; update(); break; } else { break; } case 0x1013: //Tecla de Navegacion De Arriba calcular=0; if ( current > 3 ) { ------current; update(); break; } else { break; } case 0x1014: //Tecla de Navegacion De Derecha calcular=0; if (current < 36 ) { ++current; update(); break; } else { break; } case 0x1015: //Tecla de Navegacion De Abajo calcular=0; if (current < 34 ) { ++++++current; update(); break; } else { break; } case 0x1038: //Softkey Izquierda calcular=0; reboot = new ZMessageDlg("zRoulette", "Desea reinciar la Ruleta?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); if(reboot->exec()==1) { system("rm numeros.cfg"); system("rm historial.cfg"); current = 1; jugadas = 0; lista.clear(); update(); break; } else { update(); break; } case 0x103a: //Softkey Derecha int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("18"), 0 ); if ( temp != 0 ) { reboot = new ZMessageDlg("zRoulette", "Desea limpiar las jugadas dejando las ultimas 18 solamente?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); if(reboot->exec()==1) { for ( int l=1; l<37; ++l) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(l), QString("0") ); } for ( int j=1; j<19; ++j) { int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 ); if ( temp > 0 ) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(temp), QString("1") ); } } calcular=1; update(); break; } else { break; } } else { reboot = new ZMessageDlg("zRoulette", "Deben haber mas de 18 bolas jugadas para el reinicio parcial.", (ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); break; } case 0x1004: //Boton Central valortemp = Num.readNumEntry(QString("NUMEROS"), QString("%1").arg(current), 0 ); if ( valortemp < 1 ) { valortemp=0; } ++valortemp; Num.writeEntry(QString("NUMEROS"), QString("%1").arg(current), valortemp); int lugar=0; for ( int j=18; j>0; --j) { int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 ); if ( temp==0 ) { lugar=j; } } if ( lugar > 0 ) { Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(lugar), QString("%1").arg(current) ); } else { for ( int j=1; j<18; ++j) { int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j+1), 0 ); Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(j), QString("%1").arg(temp) ); } Hist.writeEntry ( QString("HISTORIAL"), QString("18"), QString("%1").arg(current) ); } calcular=1; update(); } }
Hashing_Result* HashingHist(PCANet* PcaNet, vector<int>& ImgIdx, vector<cv::Mat>& Imgs){ Hashing_Result* ha_result = new Hashing_Result; int length = Imgs.size(); int NumFilters = PcaNet->NumFilters[PcaNet->NumStages - 1]; int NumImgin0 = length / NumFilters; cv::Mat T; int row = Imgs[0].rows; int col = Imgs[0].cols; int depth = Imgs[0].depth(); vector<double> map_weights; cv::Mat temp; for(int i=NumFilters - 1; i>=0; i--) map_weights.push_back(pow(2.0, (double)i)); vector<int> Ro_BlockSize; double rate = 1 - PcaNet->BlkOverLapRatio; for(int i=0 ;i<PcaNet->HistBlockSize.size(); i++) Ro_BlockSize.push_back(round(PcaNet->HistBlockSize[i] * rate)); cv::Mat BHist; int ImgIdx_length = ImgIdx.size(); int* new_idx = new int[ImgIdx_length]; for(int i=0; i<ImgIdx_length; i++) new_idx[ImgIdx[i]] = i; for(int i=0; i<NumImgin0; i++){ T = cv::Mat::zeros(row, col, depth); for(int j=0; j<NumFilters; j++){ temp = Heaviside(Imgs[NumFilters * new_idx[i] + j]); temp = temp * map_weights[j]; T = T + temp; } temp = im2col_general(T, PcaNet->HistBlockSize, Ro_BlockSize); temp = Hist(temp, (int)(pow(2.0, NumFilters)) - 1); temp = bsxfun_times(temp, NumFilters); if(i == 0) BHist = temp; else hconcat(BHist, temp, BHist); } int rows = BHist.rows; int cols = BHist.cols; ha_result->Features.create(1, rows * cols, BHist.type()); double *p_Fe = ha_result->Features.ptr<double>(0); double *p_Hi; for(int i=0; i<rows; i++){ p_Hi = BHist.ptr<double>(i); for(int j=0; j<cols; j++){ p_Fe[j * rows + i] = p_Hi[j]; } } return ha_result; }