static void applyRelations(int id) { if (!bEnforceDep || !hasAssist || id < 0) { return; } int checked = _TreeView_GetCheckState(hIpsList, hPatchHandlesIndex[id]); string _datName = WtoA(szDataNames[id]); lowerString(_datName); itemStateTable[_datName] = checked ? 0 : 1; // validate relation validateConf(_datName); validateDep(_datName); // reset checkbox state string datName; for (int i = 0; i < nNumPatches; i++) { datName = WtoA(szDataNames[i]); lowerString(datName); checked = itemStateTable[datName]; _TreeView_SetCheckState(hIpsList, hPatchHandlesIndex[i], checked ? TRUE : FALSE); } // set reverse state to current checkbox checked = itemStateTable[_datName]; _TreeView_SetCheckState(hIpsList, hPatchHandlesIndex[id], checked ? FALSE : TRUE); }
bool Station::setOrientation(string str) { // case insensitive so convert it to lower case first str = lowerString(str); if (str.length() < 4) { if (isdigit(str[0])) { for (int i = 0; i < (int)str.length(); i++) { if (str[i] != '1' && str[i] != '2' && str[i] != '3') { return false; } } orientation = str; return true; } else if (islower(str[0])) { for (int i = 0; i < (int)str.length(); i++) { if (str[i] != 'n' && str[i] != 'e' && str[i] != 'z') { return false; } } orientation = str; return true; } } return false; }
// Utility // --- int Markovsky::FilterMessage(string &message) { int n; // MSVC doesn't like 'for' locality for (n = message.find('\n'); n != message.npos; n = message.find('\n', n)) { message.erase(n, 1); } for (n = message.find('\r'); n != message.npos; n = message.find('\r', n)) { message.erase(n, 1); } for (n = message.find('\"'); n != message.npos; n = message.find('\"', n)) { message.erase(n, 1); } for (n = message.find("? "); n != message.npos; n = message.find("? ", n)) { message.replace(n, 2, "?. "); } for (n = message.find("! "); n != message.npos; n = message.find("! ", n)) { message.replace(n, 2, "!. "); } lowerString (message); return true; }
static inline void lowerTrimmed(StringList& list) { StringList::iterator iter = list.begin(); for (; iter != list.end(); iter++) { lowerString(*iter); } }
int lowerString(string &str) { char* cmess = strdup(str.c_str()); lowerString (cmess); str = cmess; free(cmess); return true; }
static int parseRelations() { depTable.clear(); confTable.clear(); char assistName[MAX_PATH]; sprintf(assistName, "%s\\%s\\%s", WtoA(getMiscPath(PATH_IPS)), BurnDrvGetTextA(DRV_NAME), "assistant.txt"); //parse ips dat and update the treewidget FILE* fp = fopen(assistName, "rt"); if (!fp) { return 1; } char s[1024]; char* p = NULL; string line; size_t nLen = 0; size_t pos = string::npos; while (!feof(fp)) { if (fgets(s, sizeof s, fp) != NULL) { p = s; // skip UTF-8 sig if (strncmp(p, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE)) == 0) { p += strlen(UTF8_SIGNATURE); } if (p[0] == '#') { continue; // skip comment } getLine(p); line = p; pos = line.find(">"); if (pos != string::npos) { StringList depStrs = split2Str(line, ">"); string parent = *(depStrs.begin()); lowerString(parent); StringList children = stringSplit(depStrs.back(), ","); lowerTrimmed(children); depTable.insert(make_pair(parent, children)); } else { StringList conflicts = stringSplit(line, ","); lowerTrimmed(conflicts); confTable.push_back(conflicts); } } } return 0; }
string Markovsky::ParseCommands(const string cmd) { if (cmd[0] != '!') return ""; string command = cmd; lowerString(command); CMA_TokenizeString(command.c_str()); // CMA_TokenizeString(command.c_str()); for (int i = 0; i < numbotcmds; i++) { if (!strncmp(CMA_Argv(0) + 1, botcmds[i].command, strlen(botcmds[i].command))) { return botcmds[i].func(this, command); } } return ""; }
// find if gameinfo contain rom name static inline RomInfo* getSetHasRom(GameInfo* info, string romname) { if (!info || romname == "") return NULL; lowerString(romname); map<unsigned int, RomInfo>::iterator iter = info->roms.begin(); for (; iter != info->roms.end(); iter++) { if (iter->second.name == romname) return &(iter->second); } return NULL; }
static void initRelations() { // clear state itemStateTable.clear(); // reset checkbox state string datName; int nChecked = 0; for (int i = 0; i < nNumPatches; i++) { nChecked = _TreeView_GetCheckState(hIpsList, hPatchHandlesIndex[i]); datName = WtoA(szDataNames[i]); lowerString(datName); itemStateTable.insert(make_pair(datName, nChecked)); } }
std::string toLowercase(std::string str) { const char* cString = str.c_str(); char* newStr = new char[str.size() + 1]; int i; for(i = 0; i < str.size(); i++) { newStr[i] = tolower(cString[i]); } newStr[i] = '\0'; std::string lowerString(newStr); delete[] newStr; return lowerString; }
std::string Generator::attributeToHtmlElement(const Attribute &attr) { std::stringstream ss; std::string id = lowerString(attr.getIdentifier()); if (id == "truststore") { ss << "<textarea id=\"" << attr.getIdentifier() << "\" cols=\"80\" rows=\"10\" " << (attributeEnabled(attr) ? "" : "disabled") << "/></textarea>"; } else { ss << "<input id=\"" << attr.getIdentifier() << "\" type=\"" << (attr.getType() == Token::T_BOOLEAN ? "checkbox" : "text") <<"\" size=\"30\" " << attributeDefaultValue(attr) << (attributeEnabled(attr) ? "" : "disabled ") << "/>"; } return ss.str(); }
bool extractFeatures(char *type){ Ptr<FeatureDetector> detector; vector<KeyPoint> keypoints; string ImageID="left",outPath=directory+"keypoints.txt"; bool display=false; bool saveKpts=false; //read common key variables readConfigFile(filename,"ImageID",ImageID); readConfigFile(filename,"DisplayKeypoints",display); readConfigFile(filename,"SaveKeypoints",saveKpts); readConfigFile(filename,"SaveKeypointsPath",outPath); lowerString(ImageID); //set detector switch(type[0]) { case '1': {//Good feature to track cout<<"Feature Extraction:\tGood feature to track..."<<endl<<endl; /*GoodFeaturesToTrackDetector( int maxCorners, double qualityLevel, double minDistance, int blockSize=3,bool useHarrisDetector=false, double k=0.04 );*/ //initialize the parameters int maxCorners=1e8,blockSize=5; double qualityLevel=0.01,minDistance=5,k=0.04; bool useHarrisDEtector=false; //set parameters readConfigFile(filename,"maxCorners",maxCorners); readConfigFile(filename,"blockSize",blockSize); readConfigFile(filename,"qualityLevel",qualityLevel); readConfigFile(filename,"minDistance",minDistance); readConfigFile(filename,"k",k); readConfigFile(filename,"useHarrisDetector",useHarrisDEtector); //initialize feature detector detector=new GoodFeaturesToTrackDetector(maxCorners,qualityLevel,minDistance,blockSize,useHarrisDEtector,k); //detect if(ImageID=="left") detector->detect(img1,keypoints); else if(ImageID=="right") detector->detect(img2,keypoints); else{ detector->detect(img1,keypoints); cerr<<"Unknown option for the image_id, the left image was detected instead!"<<endl; } break; } case '2': {//Fast feature to track cout<<"Feature Extraction:\tFast feature to track..."<<endl<<endl; /* FastFeatureDetector(int threshold=10,bool nonmaxSuppression=true)*/ //initialize the parameters int threshold=1; bool nonmaxSuppression=true; //set parameters readConfigFile(filename,"threshold",threshold); readConfigFile(filename,"nonmaxSuppression",nonmaxSuppression); //initialize feature detector detector=new FastFeatureDetector(threshold, nonmaxSuppression); //detect if(ImageID=="left") detector->detect(img1,keypoints); else if(ImageID=="right") detector->detect(img2,keypoints); else{ detector->detect(img1,keypoints); cerr<<"Unknown option for the image_id, the left image was detected instead!"<<endl; } break; } case '3': {//Grid feature to track cout<<"Feature Extraction:\tGrid feature to track..."<<endl<<endl; /*DenseFeatureDetector(float initFeatureScale=1.f,int featureScaleLevels=1,float featureScaleMul=0.1f, int initXyStep=6,int initImgBound=0,bool varyXyStepWithScale=true,bool varyImgBoundWithScale=false)*/ float initFeatureScale=1.f,featureScaleMul=0.1f; int featureScaleLevels=1,initXyStep=6,initImgBound=0; bool varyXyStepWithScale=true,varyImgBoundWithScale=false; //set parameters readConfigFile(filename,"initFeatureScale",initFeatureScale); readConfigFile(filename,"featureScaleMul",featureScaleMul); readConfigFile(filename,"featureScaleLevels",featureScaleLevels); readConfigFile(filename,"initXyStep",initXyStep); readConfigFile(filename,"initImgBound",initImgBound); readConfigFile(filename,"varyXyStepWithScale",varyXyStepWithScale); readConfigFile(filename,"varyImgBoundWithScale",varyImgBoundWithScale); //initialize feature detector detector=new DenseFeatureDetector(initFeatureScale,featureScaleLevels,featureScaleMul, initXyStep,initImgBound,varyXyStepWithScale,varyImgBoundWithScale); //detect if(ImageID=="left") detector->detect(img1,keypoints); else if(ImageID=="right") detector->detect(img2,keypoints); else{ detector->detect(img1,keypoints); cerr<<"Unknown option for the image_id, the left image was detected instead!"<<endl; } break; } default: exitwithErrors("unknown type for feature extraction!"); } if(display) if(ImageID=="right") showKeypoints(img2,keypoints,imagescale); else showKeypoints(img1,keypoints,imagescale); if(saveKpts){ printKeypoints(outPath,keypoints); } }
int main( int argc, char **argv ) { IMAGE im; dsr myDSR; char inName[256]; int i; time_t correctedTime; unsigned long TimeOffset = 28800; // 8 hrs from GMT...? short minutes; OSErr error = noErr; if( argc == 1 ) { printf( "Enter the name of an image file ( xxx.img ): " ); scanf( "%s", inName ); } else { strcpy( inName, argv[1] ); } error = UC_Readheader( inName, &im ); ILError( error, "reading input header" ); printf( "\nImage file type: %s\n", ReportFileType( im.file_type )); printf( "Byte Order: " ); if( im.dim.flags & kmacByteOrder ) { printf( "Big Endian (like a Macintosh)\n" ); } else { printf( "Little Endian (like a pc)\n" ); } for( i=0; i<40; i++ ) printf( "-" ); printf( "\n" ); if( strlen( im.RawHdr )) printf( "Header name .............. %s\n", im.RawHdr ); if( im.acq.im_exno ) printf( "Exam number .............. %d\n", im.acq.im_exno ); if( im.acq.im_seno ) printf( "Series number ............ %d\n", im.acq.im_seno ); if( im.acq.im_no ) printf( "Image number ............. %d\n", im.acq.im_no ); if( im.acq.im_datetime ) { correctedTime = (time_t)(im.acq.im_datetime + TimeOffset); printf( "Date/time (?)............. %s", ctime( &correctedTime ) ); } if( im.acq.sctime > 0.0 ) { minutes = im.acq.sctime/60e6; printf( "Scan duration ............ %d:%0.2f min\n", minutes, ( im.acq.sctime - minutes * 60e6 )/1e6 ); } // Demographics if( strlen( im.subj.patname )) printf( "Subject Name ............. %s\n", im.subj.patname ); if( strlen( im.subj.patid )) printf( "Patient ID ............... %s\n", im.subj.patid ); if( strlen( im.subj.reqnum )) printf( "Requisition No ........... %s\n", im.subj.reqnum ); if( strlen( im.subj.HumanStudiesID )) printf( "Human Subjects ID ........ %s\n", im.subj.HumanStudiesID ); if( strlen( im.subj.ResearchProtocol )) printf( "Research Protocol ........ %s\n", im.subj.ResearchProtocol ); if( im.subj.patage ) printf( "Age ...................... %d years\n", im.subj.patage ); if( im.file_type == SIGNA ) { if( im.subj.male ) { printf( "Sex ...................... Male\n" ); } else { printf( "Sex ...................... Female or not specified\n" ); } } if( im.subj.patweight) printf( "Weight ................... %0.1f pounds\n", im.subj.patweight * .0022 ); if( strlen( im.subj.descr )) printf( "Scan description ......... %s\n", im.subj.descr ); if( strlen( im.subj.refphy )) printf( "Referring physicion....... %s\n", im.subj.refphy ); if( strlen( im.subj.diagrad )) printf( "Radiologist .............. %s\n", im.subj.diagrad ); if( strlen( im.subj.ex_op )) printf( "Operator ................. %s\n", im.subj.ex_op ); if( strlen( im.subj.hospname )) printf( "Hospital Name ............ %s\n", im.subj.hospname ); if( im.acq.fieldStrength > 0.0 ) { if( strcmp( im.subj.hospname, "UCLA Brain Mapping" )) { printf( "Field strength ........... 3.0 Tesla\n" ); } else { printf( "Field strength ........... %0.2f Tesla\n", im.acq.fieldStrength/10000.0 ); } } for( i=0; i<40; i++ ) printf( "-" ); printf( "\n" ); // section separator // Image Data if( strlen( im.acq.psdname )) printf( "pulse sequence name ...... %s\n", im.acq.psdname ); if( im.acq.nReadPoints && im.acq.nPhaseLines ) printf( "acq matrix ............... %hd x %hd\n", im.acq.nReadPoints, im.acq.nPhaseLines ); if( im.dim.acqpixsize_X > 0.0 && im.dim.acqpixsize_Y > 0.0 ) printf( "Resolution (x / y) ....... %0.3f x %0.3f mm\n", im.dim.acqpixsize_X, im.dim.acqpixsize_Y ); if( im.dim.dfov > 0.0 && im.dim.dfov_rect > 0.0 ) printf( "Display FoV (x / y) ...... %0.0f / %0.0f mm\n", im.dim.dfov, im.dim.dfov_rect ); if( im.dim.dpixsize_X > 0.0 && im.dim.dpixsize_Y > 0.0 ) printf( "Display Pixels (x / y) ... %0.3f / %0.3f mm\n", im.dim.dpixsize_X, im.dim.dpixsize_Y ); if( im.dim.x && im.dim.y ) printf( "Display matrix ........... %hd x %hd pixels\n", im.dim.x, im.dim.y ); if( im.dim.slthick > 0 ) { printf( "Slice thickness .......... %0.2f\n", im.dim.slthick ); printf( "Slice spacing ............ %0.2f\n", im.dim.scanspacing ); } /* RMD 1/7/02 */ if( im.loc.tlhc[0] ) printf( "Top left RAS coords ...... %0.2f %0.2f %0.2f\n", im.loc.tlhc[0], im.loc.tlhc[1], im.loc.tlhc[2] ); if( im.loc.trhc[0] ) printf( "Top right RAS coords ..... %0.2f %0.2f %0.2f\n", im.loc.trhc[0], im.loc.trhc[1], im.loc.trhc[2] ); if( im.loc.brhc[0] ) printf( "Bottom right RAS coords .. %0.2f %0.2f %0.2f\n", im.loc.brhc[0], im.loc.brhc[1], im.loc.brhc[2] ); if( im.loc.imgNorm[0] ) printf( "Normal RAS coords ........ %0.2f %0.2f %0.2f\n", im.loc.imgNorm[0], im.loc.imgNorm[1], im.loc.imgNorm[2] ); /* RMD end */ if( im.dim.n_slices ) printf( "Number of slices ......... %d\n", im.dim.n_slices ); if( im.dim.timePts ) printf( "Time Points .............. %d\n", im.dim.timePts ); if( im.fileData_type ) printf( "File data type ........... %s\n", ReportDataType( im.fileData_type )); if( im.acq.tr ) printf( "TR ....................... %0.1f msec\n", im.acq.tr/1000.0 ); if( im.acq.te ) { printf( "TE ....................... %0.2f msec", im.acq.te/1000.0 ); if( im.acq.frac_echo ) { printf( "(fractional)\n" ); } else { printf( "\n" ); } } if( im.acq.ti ) printf( "TI ....................... %0.2f msec\n", im.acq.ti/1000.0 ); if( im.acq.nex > 0.0 ) printf( "nex ...................... %0.1f\n", im.acq.nex ); if( im.acq.se_nacq ) printf( "acquisitions ............. %hd\n", im.acq.se_nacq ); if( im.acq.mr_flip ) printf( "Flip Angle ............... %d degrees\n", im.acq.mr_flip ); if( im.acq.vbw > 0.0 ) printf( "Acquisition bandwidth .... %0.3f kiloHertz\n", im.acq.vbw ); if( im.acq.numecho ) printf( "Echo ..................... %d of %d\n", im.acq.echonum, im.acq.numecho ); if( im.acq.echo_trn_len ) printf( "Echo train length ........ %d\n", im.acq.echo_trn_len ); if( im.acq.xmtgain ) printf( "Transmitter gain ......... %d\n", im.acq.xmtgain ); if( im.acq.rec1 ) printf( "Receiver gain (1) ........ %d\n", im.acq.rec1 ); if( im.acq.rec2 ) printf( "Receiver gain (2) ........ %d\n", im.acq.rec2 ); if( strlen( im.acq.prtcl )) printf( "Protocol name ............ %s\n", im.acq.prtcl ); if( im.theMinf < im.theMaxf ) printf( "Pixel min/max ............ %0.2f / %0.2f\n", im.theMinf, im.theMaxf ); if( im.file_type == ANALYZE ) { char response[2]; printf( "\n\nShow all Analyze header fields (y/n)?: " ); scanf( "%s", response ); lowerString( response ); if( !strcmp( response, "y" )) { error = MoreAnalyzeHeader( im.RawHdr ); ILError( error, "Showing extra analyze contents" ); } } return 0; }
// gets data from accelerometer static void data_handler(AccelData *data, uint32_t num_samples) { // Long lived buffer static char s_buffer[128]; // saple to log will make it so that its 1 log every second... 20 would be every 2.. etc. if (sampleToLog == 50) { // Compose string of all data snprintf(s_buffer, sizeof(s_buffer), "N X,Y,Z\n0 %d,%d,%d\n1 %d,%d,%d\n2 %d,%d,%d", data[0].x, data[0].y, data[0].z, data[1].x, data[1].y, data[1].z, data[2].x, data[2].y, data[2].z ); APP_LOG(APP_LOG_LEVEL_INFO, "%s", s_buffer); sampleToLog = 0; } else { sampleToLog ++; } // TODO - need to change the value of curlUpX, curlDownX and/or use ddiferent data depending on exercise lowerString(selected_exercise); int dataToScan = data[0].x; curlUpX = -2000; curlDownX = 2000; if (strstr(selected_exercise, "biceps curls") != NULL) { curlUpX = -850; curlDownX = 850; dataToScan = data[0].x; } else if (strstr(selected_exercise, "shoulder press") != NULL) { curlUpX = -15; curlDownX = 140; dataToScan = data[0].z; } else if (strstr(selected_exercise, "bench press") != NULL || strstr(selected_exercise, "benchpress") != NULL) { curlUpX = 120; curlDownX = 150; dataToScan = data[0].z; } else if (strstr(selected_exercise, "squat") != NULL) { curlUpX = -15; curlDownX = 140; dataToScan = data[0].z; } /* down up < -575 > - 180 // requires reverse */ if (dataToScan < curlUpX) { if (isDown) { repCount = repCount + 1; isUp = true; isDown = false; snprintf(s_buffer, sizeof(s_buffer), "REPS: %d", repCount); // need another layer text_layer_set_text(s_reps_layer, s_buffer); // could also buzz instead vibes_short_pulse(); // APP_LOG(APP_LOG_LEVEL_DEBUG, "%s", s_buffer); } } else if (dataToScan > curlDownX) { isDown = true; isUp = false; } // buzz 3 times when complete and stop logging. //TODO start with an exercise list / selection - call https://wger.de/en/software/api // demos API call using phone //Show the data //text_layer_set_text(s_output_layer, s_buffer); //use bits from here https://developer.getpebble.com/tutorials/watchface-tutorial/part3/ }
static int getArchiveInfo(const char* path, const char* name) { if (!name || !path) { return 1; } // omit extension string _name = name; lowerString(_name); // case-insensitive size_t pos = _name.rfind("."); _name = _name.substr(0, pos); // if (_name == "sf2m13") { // int dummy = 0; // } // set progress //checkScanThread(); //romsSetProgress(); // find name map<string, GameInfo*>::iterator _it = allGameMap.find(_name); if (_it == allGameMap.end()) { return 1; } GameInfo* gameInfo = _it->second; if (!gameInfo) { return 1; } static char fileName[MAX_PATH]; sprintf(fileName, "%s%s", path, name); if (archiveOpenA(fileName)) { return 1; } if (archiveGetList(&List, &listCount)) { freeArchiveList(); return 1; } RomInfo* romInfo = NULL; map<unsigned int, RomInfo>::iterator iter; for (int i = 0; i < listCount; i++) { // check roms iter = gameInfo->roms.find(List[i].nCrc); if (iter != gameInfo->roms.end()) { romInfo = &iter->second; if (!romInfo) { continue; } if (romInfo->size != List[i].nLen) { if (List[i].nLen < romInfo->size) { romInfo->state = STAT_SMALL; } else { romInfo->state = STAT_LARGE; } } else { romInfo->state = STAT_OK; } } else { // wrong CRC if (nLoadMenuShowX & DISABLECRC) { RomInfo* rom = getSetHasRom(gameInfo, List[i].szName); if (rom) { rom->state = STAT_OK; } } } // check all clones setCloneRomInfo(gameInfo, List[i]); } archiveClose(); freeArchiveList(); return 0; }
bool Generator::methodEnabled(const Method &method, const Method::MethodParam ¶m) { std::string id(lowerString(method.getIdentifier() + param.getIdentifier())); std::set<std::string>::iterator found = s_default_methods.find(id); return found != s_default_methods.end(); }
bool Generator::attributeEnabled(const Attribute &attr) { std::string id(lowerString(attr.getIdentifier())); std::set<std::string>::iterator found = s_default_attributes.find(id); return found != s_default_attributes.end(); }
std::string Generator::attributeDefaultValue(const Attribute &attr) { std::string id(lowerString(attr.getIdentifier())); std::map<std::string, std::string>::iterator found = s_default_attribute_values.find(id); return found != s_default_attribute_values.end() ? found->second : ""; }