void PredictResult::ReportResult() { if (y_true.size() != y_pred.size()) { throw; } for (std::map<int, std::string>::iterator itr = target_name.begin(); itr != target_name.end();++itr) { int label = itr->first; std::string label_name = itr->second; results.push_back(CalcResult(label,label_name)); } printf("%20s%9s %9s %11s\n\n","","precision","recall","F1-score"); for (std::vector<ResultInner>::iterator iter = results.begin(); iter != results.end(); ++iter) { printf("%15s %.8f %.8f %.8f\n",iter->lable_name.c_str(),iter->precision,iter->recall,iter->f1); } printf("\n"); return; }
bool ContoursProcessor::FindContours() { if (storage==NULL) { storage = cvCreateMemStorage(0); } else { cvClearMemStorage(storage); } cvFindContours( Tmp_img, storage, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) ); if(ImageResult) cvClearSeq(ImageResult); if (contours) { if (ResultsStorage==NULL) { ResultsStorage = cvCreateMemStorage(0); } else { cvClearMemStorage(ResultsStorage); } ImageResult = cvCreateSeq(0,sizeof(CvSeq),sizeof(T_MEAS_RESULTS_REC),ResultsStorage); T_MEAS_RESULTS_REC ContourResult; int Idx=1; for( CvSeq* c=contours; c!=NULL; c=c->h_next ) { //for (i=0;i<contours->total;i++) //ImageResult if (ImageResult) { cvContourMoments(c,&Moments); if ((Moments.m00>3000.0)&&(Moments.m00<8000.0)) { memset(&ContourResult,0,sizeof(ContourResult)); ContourResult.ObjNo=Idx; ContourResult.Area = Moments.m00; ContourResult.Center.x = Moments.m10/Moments.m00; ContourResult.Center.y = Moments.m01/Moments.m00; cvSeqPushFront(ImageResult,&ContourResult); Idx++; } } } CalcResult(ImageResult); //PrintResults(0, res_img,ImageResult); cvDrawContours( cnt_img, contours, CV_RGB(128,0,0), CV_RGB(0,128,0), 3, 1, CV_AA, cvPoint(0,0) ); } return true; }
void PrintResult(int res[], int resLen, int inputLen, int moves[]) { int i; printf("Input: "); printf("{"); for(i = 0; i < inputLen; i++) { printf("%d, ", moves[i]); } printf("}"); printf("\nCount: "); printf("%d\nResult: ", CalcResult(res, resLen)); printf("{"); for(i = 0; i < resLen; i++) { printf("%d, ", res[i]); } puts("}\n"); }
void BWindow_Result::OnOpened(){ ImportDollData(true); CalcResult(); }
//Головна функція int run(int moves[], int movesLen, int res[], int resLen) { int i; int currentVal = 0; //поточне вхідне значення int currentState = 0; //поточний стан int currentOperat = Push; //поточна операція int cntElem = 0; //к-сть заповнених елементів на даних момент int Y; //номер стовпчика for(i = 0; i < movesLen; i++) { //Визначаємо значення if(currentOperat != Repeat) currentVal = moves[i]; //Перевіряємо, чи підходить воно (входить до алфавіту) Y = FindEnableVal(currentVal, EnableVal, MAX_Enable_val); if(Y == -1) { //Очишуємо масив і закінчуємо роботу ClearResultArray(res, resLen); return 0; } //Знаходимо поточну операцію currentOperat = operationType[currentState][Y]; //Присвоюємо поточному стану новий стан currentState = newState[currentState][Y]; //Дивимось тип операції switch(currentOperat) { case Pop: if(cntElem == 0) return 0; res[cntElem - 1] = 0; cntElem--; break; case Continue: break; case Repeat: break; case Break: return (CalcResult(res, resLen)); //Push будь-яке число default: //Записуємо число у вихідний масив res[cntElem] = currentOperat; cntElem++; //Якщо весь масив заповнений if(cntElem == resLen) return (CalcResult(res, resLen)); break; } } return (CalcResult(res, resLen)); }
void SlotMachine::Update(Canvas *_canvas) { Canvas *canvas = _canvas; if (state == SlotMachineState::sl_inProcess) { // Все ли барабаны остановлены bool allStoped = true; // Обновляем и проверяем состояние барабанов TypeObjectsMap::iterator wit; // Итератор для карты с барабанами // Проверяем состояние барабанов for (wit = wheelsMap.begin(); wit != wheelsMap.end(); ++wit) { if (wit->second->getState() == WheelState::_running) { wit->second->Update(); allStoped = false; } } TypeObjectsMap::iterator bit; // Итератор для карты с кнопками // Все барабаны прекратили вращение if (allStoped) { bit = buttonsMap.find(ObjectRole::_start); if (bit != buttonsMap.end()) { Object *start = bit->second; if (start->getState() == ButtonState::_enabled) { // Закончили вращение. Возвращаемся в исходное состояние и проверяем результат if (result = CalcResult()) { showResultStartTime = currentTime = std::time(nullptr); state = SlotMachineState::sl_show_result; TextureMap * textureMap = canvas->getTextureMap(); TextureMap::iterator it; resultTexture = nullptr; // Обработка результатов костыль switch (result) { case r_slash: it = textureMap->find(TextureRole::_w_slash); resultTexture = it->second; break; case r_center: it = textureMap->find(TextureRole::_w_center); resultTexture = it->second; break; case r_backslah: it = textureMap->find(TextureRole::_w_backslash); resultTexture = it->second; break; } resultTexture->ena = true; } else { state = SlotMachineState::sl_waiting; start->Update(); } } } } } else if (state == SlotMachineState::sl_show_result) { currentTime = std::time(nullptr); int elapse = currentTime - showResultStartTime; if (elapse < SHOW_RESULT_DURATION) { //resultTexture->ena = true; } else { resultTexture->ena = false; state = SlotMachineState::sl_waiting; TypeObjectsMap::iterator bit; bit = buttonsMap.find(ObjectRole::_start); bit->second->Update(); } } }