int main(int argc, char **argv) { testInit(argc, argv, 400,400, "ShivaVG: Linear Gradient Test"); testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display); testCallback(TEST_CALLBACK_BUTTON, (CallbackFunc)click); testCallback(TEST_CALLBACK_DRAG, (CallbackFunc)drag); testCallback(TEST_CALLBACK_KEY, (CallbackFunc)key); testCallback(TEST_CALLBACK_RESHAPE, (CallbackFunc)reshape); p = testCreatePath(); org = testCreatePath(); blackFill = vgCreatePaint(); vgSetParameterfv(blackFill, VG_PAINT_COLOR, 4, black); backImage = createImageFromJpeg(IMAGE_DIR"test_img_violin.jpg"); patternImage = createImageFromJpeg(IMAGE_DIR"test_img_shivavg.jpg"); patternFill = vgCreatePaint(); createSquare(p); createOrigin(org); createPattern(); testOverlayString("Press H for a list of commands"); testOverlayColor(1,1,1,1); testRun(); return EXIT_SUCCESS; }
bool MkLocalDirMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock, char* respBuf, size_t bufLen, HighResolutionStats* stats) { const char* logContext = "MkLocalDirMsg incoming"; EntryInfo* entryInfo = getEntryInfo(); std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername(); LOG_DEBUG(logContext, 4, std::string("Received a MkLocalDirMsg from: ") + peer + std::string(" entryID: ") + entryInfo->getEntryID() + std::string(" entryName: ") + entryInfo->getFileName() ); IGNORE_UNUSED_VARIABLE(logContext); IGNORE_UNUSED_VARIABLE(entryInfo); FhgfsOpsErr mkRes = FhgfsOpsErr_INTERNAL; StripePattern* pattern = createPattern(); if(unlikely(pattern->getPatternType() == STRIPEPATTERN_Invalid) ) LogContext(logContext).logErr("Received an invalid stripe pattern from: " + peer); else mkRes = mkLocalDir(pattern); delete(pattern); MkLocalDirRespMsg respMsg(mkRes); respMsg.serialize(respBuf, bufLen); sock->sendto(respBuf, respMsg.getMsgLength(), 0, (struct sockaddr*)fromAddr, sizeof(struct sockaddr_in) ); return true; }
static void createPatterns( strus::PatternMatcherInstanceInterface* ptinst, const Pattern* patterns) { unsigned int pi=0; for (; patterns[pi].name; ++pi) { createPattern( ptinst, patterns[pi].name, patterns[pi].operations); } }
void key(unsigned char key, int x, int y) { glutPostRedisplay(); if (key == BACKSPACE) { /* Reset value */ switch (mode) { case 't': tx = 0; ty = 0; break; case 'x': sx = 1.0f; break; case 'y': sy = 1.0f; break; } updateOverlayString(); return; } switch (tolower(key)) { case 't': case 'x': case 'y': break; case TAB: /* Cycle spread mode */ tindex = (tindex+1) % tsize; createPattern(); switch(tindex) { case 0: testOverlayString("Pattern Tiling mode: FILL\n"); break; case 1: testOverlayString("Pattern Tiling mode: PAD\n"); break; case 2: testOverlayString("Pattern Tiling mode: REPEAT\n"); break; case 3: testOverlayString("Pattern Tiling mode: REFLECT\n"); break; }return; case 'h': /* Show help */ testOverlayString(commands); return; default: return; } /* Switch mode */ mode = tolower(key); updateOverlayString(); }
/** * Create an inode and directory-entry */ FhgfsOpsErr MkFileWithPatternMsgEx::mkMetaFile(DirInode* dir, std::string fileName, EntryInfo* outEntryInfo) { // note: to guarantee amtomicity of file creation (from the view of a client), we have // to create the inode first and insert the directory entry afterwards LogContext log("MkFileWithPatternMsg::mkMetaFile"); App* app = Program::getApp(); TargetCapacityPools* capacityPools = app->getStorageCapacityPools(); MetaStore* metaStore = Program::getApp()->getMetaStore(); // check stripe pattern StripePattern* stripePattern = createPattern(); UInt16Vector stripeTargets; UInt16List preferredTargets(stripePattern->getStripeTargetIDs()->begin(), stripePattern->getStripeTargetIDs()->end() ); unsigned numDesiredTargets = stripePattern->getDefaultNumTargets(); unsigned minNumRequiredTargets = stripePattern->getMinNumTargets(); // choose targets based on preference setting of given stripe pattern capacityPools->chooseStorageTargets( numDesiredTargets, minNumRequiredTargets, &preferredTargets, &stripeTargets); // check availability of stripe nodes if(stripeTargets.empty() || (stripeTargets.size() < stripePattern->getMinNumTargets() ) ) { log.logErr(std::string("No (or not enough) storage targets available") ); delete(stripePattern); return FhgfsOpsErr_INTERNAL; } // swap given preferred targets of stripe pattern with chosen targets stripePattern->getStripeTargetIDsModifyable()->swap(stripeTargets); MkFileDetails mkDetails(fileName, this->getUserID(), this->getGroupID(), this->getMode(), 0); FileInodeStoreData inodeDiskData; FhgfsOpsErr makeRes = metaStore->mkNewMetaFile(dir, &mkDetails, stripePattern, outEntryInfo, &inodeDiskData); // (note: internally deletes stripePattern) return makeRes; }
int SkyDetect::detect() { QString saveLocation = "C:\\Users\\Durcak\\Desktop\\SLICO\\"; QString filename = "C:\\Users\\Durcak\\Desktop\\SLICO\\05.jpg"; openImage( filename ); applyFiltersBefore(); doSlico( filename, saveLocation); initSPixelsFromLabels( mLabels); createPattern(); initSPixelAdj16(); //mergeSP(); classificate(); createClassImage1(); classificate2(); createClassImage2(); cv::waitKey(0); return 0; }
int main(int argc, char **argv) { Perceptron perceptron; FILE *output = NULL; FILE *input = NULL; float fractionLearn = 0; float learnRate = 0.1; float errorTolerance = 0.1; int i; float threshold = 0.8; Pattern patterns; /* comprueba la linea de comandos */ for (i = 1; i < argc; i++) { if (strcmp("-input", argv[i])==0) { input = fopen(argv[i+1], "r"); } else if (strcmp("-output", argv[i])==0) { output = fopen(argv[i+1], "w"); } else if (strcmp("-part", argv[i])==0) { fractionLearn = atof(argv[i+1]); } else if (strcmp("-learnrate", argv[i])==0) { learnRate = atof(argv[i+1]); } else if (strcmp("-threshold", argv[i])==0) { threshold = atof(argv[i+1]); } else if (strcmp("-tolerance", argv[i])==0) { errorTolerance = atof(argv[i+1]); } } if (input == NULL || output == NULL) { printf("USO: %s -input <f_entrada> -output <f_salida> [-part <porcentaje_aprendizaje>] [-learnrate <tasa_aprendizaje>] [-threshold <umbral>]\n", argv[0]); exit(0); } if ((fractionLearn < 0.0 || fractionLearn > 1) || (learnRate <= 0)) { fprintf(stderr, "ERROR: Valor de porcentaje de aprendizaje (0,1] o factor de aprendizaje ( >0 )\n"); exit(0); } if (!createPattern(input, &patterns)) { fprintf(stderr, "ERROR: Error en la lectura de patrones\n"); exit(0); } fclose(input); fclose(output); createPerceptron(&perceptron, 0, patterns.numAttributes, 1); initWeightsAdaline(&perceptron); printf("\n##################LEARN##################\n"); learnAdaline(&perceptron, learnRate, threshold, &patterns, patterns.numPatterns*fractionLearn, errorTolerance); printf("\n##################TEST##################\n"); test(&perceptron, &patterns, ((int)(patterns.numPatterns*fractionLearn)) % patterns.numPatterns); deletePerceptron(&perceptron); freePattern(&patterns); return 0; }
SmallExploder::SmallExploder() { createPattern(); centered = true; }